Skip to content

Commit 60b760a

Browse files
committed
Move the code location and put similar functions together.
1 parent 2d29ad3 commit 60b760a

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

Diff for: cmd/m3fs/architecture.go

+31-31
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,17 @@ func (g *ArchDiagram) renderClientSection(buffer *strings.Builder, clientNodes [
587587
buffer.WriteByte('\n')
588588
}
589589

590+
// renderClientNodes renders client nodes
591+
func (g *ArchDiagram) renderClientNodes(buffer *strings.Builder, clientNodes []string) {
592+
if len(clientNodes) == 0 {
593+
return
594+
}
595+
596+
g.renderer.RenderNodesRow(buffer, clientNodes, func(node string) []string {
597+
return []string{"[hf3fs_fuse]"}
598+
})
599+
}
600+
590601
// renderStorageSection renders the storage nodes section
591602
func (g *ArchDiagram) renderStorageSection(buffer *strings.Builder, storageNodes []string) {
592603
g.renderArrows(buffer, g.calculateArrowCount(len(storageNodes)))
@@ -661,17 +672,6 @@ func (g *ArchDiagram) getNodeServices(node string) []string {
661672
return services
662673
}
663674

664-
// renderClientNodes renders client nodes
665-
func (g *ArchDiagram) renderClientNodes(buffer *strings.Builder, clientNodes []string) {
666-
if len(clientNodes) == 0 {
667-
return
668-
}
669-
670-
g.renderer.RenderNodesRow(buffer, clientNodes, func(node string) []string {
671-
return []string{"[hf3fs_fuse]"}
672-
})
673-
}
674-
675675
// calculateArrowCount calculates the number of arrows to display
676676
func (g *ArchDiagram) calculateArrowCount(nodeCount int) int {
677677
if nodeCount <= 0 {
@@ -682,6 +682,26 @@ func (g *ArchDiagram) calculateArrowCount(nodeCount int) int {
682682
return nodeCount
683683
}
684684

685+
// renderArrows renders arrows for the specified count
686+
func (g *ArchDiagram) renderArrows(buffer *strings.Builder, count int) {
687+
if count <= 0 {
688+
return
689+
}
690+
691+
const arrowStr = " ↓ "
692+
totalLen := len(arrowStr) * count
693+
694+
arrowBuilder := g.renderer.GetStringBuilder()
695+
arrowBuilder.Grow(totalLen)
696+
697+
for i := 0; i < count; i++ {
698+
arrowBuilder.WriteString(arrowStr)
699+
}
700+
701+
buffer.WriteString(arrowBuilder.String())
702+
g.renderer.PutStringBuilder(arrowBuilder)
703+
}
704+
685705
// renderSummaryStatistics renders the summary statistics
686706
func (g *ArchDiagram) renderSummaryStatistics(
687707
buffer *strings.Builder,
@@ -859,26 +879,6 @@ func (g *ArchDiagram) prepareServiceNodesMap(clientNodes []string) map[config.Se
859879
return serviceNodesMap
860880
}
861881

862-
// renderArrows renders arrows for the specified count
863-
func (g *ArchDiagram) renderArrows(buffer *strings.Builder, count int) {
864-
if count <= 0 {
865-
return
866-
}
867-
868-
const arrowStr = " ↓ "
869-
totalLen := len(arrowStr) * count
870-
871-
arrowBuilder := g.renderer.GetStringBuilder()
872-
arrowBuilder.Grow(totalLen)
873-
874-
for i := 0; i < count; i++ {
875-
arrowBuilder.WriteString(arrowStr)
876-
}
877-
878-
buffer.WriteString(arrowBuilder.String())
879-
g.renderer.PutStringBuilder(arrowBuilder)
880-
}
881-
882882
// getNodeMap gets a map from the object pool
883883
func (g *ArchDiagram) getNodeMap() map[string]struct{} {
884884
if v := g.renderer.NodeMapPool.Get(); v != nil {

0 commit comments

Comments
 (0)