Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 5177791

Browse files
authored
Merge pull request #21 from compose/scaledetail
Scalings now explain themselves
2 parents 5b71a06 + c1f0dd5 commit 5177791

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

cmd/print.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,42 @@ func printDatabase(database composeAPI.Database) {
171171
}
172172
}
173173

174-
func printScalings(scalings composeAPI.Scalings) {
174+
func printRawScalings(scalings composeAPI.Scalings) {
175175
fmt.Printf("%15s: %d\n", "Allocated Units", scalings.AllocatedUnits)
176176
fmt.Printf("%15s: %d\n", "Used Units", scalings.UsedUnits)
177177
fmt.Printf("%15s: %d\n", "Starting Units", scalings.StartingUnits)
178178
fmt.Printf("%15s: %d\n", "Minimum Units", scalings.MinimumUnits)
179+
fmt.Printf("%15s: %d\n", "Unit size in MB", scalings.UnitSizeInMB)
180+
fmt.Printf("%15s: %s\n", "Unit Type", scalings.UnitType)
181+
}
182+
183+
func plural(value int, singtemplate string, pluraltemplate string) string {
184+
if value == 1 {
185+
return fmt.Sprintf(singtemplate, value)
186+
}
187+
188+
return fmt.Sprintf(pluraltemplate, value)
189+
}
190+
191+
func printScalings(scalings composeAPI.Scalings) {
192+
if scalings.UnitType == "memory" {
193+
fmt.Println("This is a memory scaled deployment.")
194+
totalRAM := scalings.AllocatedUnits * scalings.UnitSizeInMB
195+
fmt.Printf("There %s of %dMB RAM allocated to it.\n", plural(scalings.AllocatedUnits, "is %d unit", "are %d units"), scalings.UnitSizeInMB)
196+
fmt.Printf("This means that each database node has of %dMB of RAM.\n", totalRAM)
197+
totalStorage := totalRAM * 4
198+
fmt.Printf("The allocated units give %dMB of storage to the deployment.", totalStorage)
199+
} else if scalings.UnitType == "data" {
200+
fmt.Println("This is a storage scaled deployment.")
201+
totalStorage := scalings.AllocatedUnits * scalings.UnitSizeInMB
202+
usedStorage := scalings.UsedUnits * scalings.UnitSizeInMB
203+
fmt.Printf("There %s of %d MB storage allocated to it.\n", plural(scalings.AllocatedUnits, "is %d unit", "are %d units"), scalings.UnitSizeInMB)
204+
fmt.Printf("This means a storage of %dMB is available of which, %dMB is used.\n", totalStorage, usedStorage)
205+
totalRAM := int(totalStorage / 10)
206+
fmt.Printf("The allocated units give each database node %dMB of RAM.\n", totalRAM)
207+
} else {
208+
fmt.Println("Unknown unit type - contact support.")
209+
}
179210
}
180211

181212
func printTeam(team composeAPI.Team) {

0 commit comments

Comments
 (0)