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

Commit

Permalink
Merge pull request #21 from compose/scaledetail
Browse files Browse the repository at this point in the history
Scalings now explain themselves
  • Loading branch information
codepope authored Jun 6, 2018
2 parents 5b71a06 + c1f0dd5 commit 5177791
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,42 @@ func printDatabase(database composeAPI.Database) {
}
}

func printScalings(scalings composeAPI.Scalings) {
func printRawScalings(scalings composeAPI.Scalings) {
fmt.Printf("%15s: %d\n", "Allocated Units", scalings.AllocatedUnits)
fmt.Printf("%15s: %d\n", "Used Units", scalings.UsedUnits)
fmt.Printf("%15s: %d\n", "Starting Units", scalings.StartingUnits)
fmt.Printf("%15s: %d\n", "Minimum Units", scalings.MinimumUnits)
fmt.Printf("%15s: %d\n", "Unit size in MB", scalings.UnitSizeInMB)
fmt.Printf("%15s: %s\n", "Unit Type", scalings.UnitType)
}

func plural(value int, singtemplate string, pluraltemplate string) string {
if value == 1 {
return fmt.Sprintf(singtemplate, value)
}

return fmt.Sprintf(pluraltemplate, value)
}

func printScalings(scalings composeAPI.Scalings) {
if scalings.UnitType == "memory" {
fmt.Println("This is a memory scaled deployment.")
totalRAM := scalings.AllocatedUnits * scalings.UnitSizeInMB
fmt.Printf("There %s of %dMB RAM allocated to it.\n", plural(scalings.AllocatedUnits, "is %d unit", "are %d units"), scalings.UnitSizeInMB)
fmt.Printf("This means that each database node has of %dMB of RAM.\n", totalRAM)
totalStorage := totalRAM * 4
fmt.Printf("The allocated units give %dMB of storage to the deployment.", totalStorage)
} else if scalings.UnitType == "data" {
fmt.Println("This is a storage scaled deployment.")
totalStorage := scalings.AllocatedUnits * scalings.UnitSizeInMB
usedStorage := scalings.UsedUnits * scalings.UnitSizeInMB
fmt.Printf("There %s of %d MB storage allocated to it.\n", plural(scalings.AllocatedUnits, "is %d unit", "are %d units"), scalings.UnitSizeInMB)
fmt.Printf("This means a storage of %dMB is available of which, %dMB is used.\n", totalStorage, usedStorage)
totalRAM := int(totalStorage / 10)
fmt.Printf("The allocated units give each database node %dMB of RAM.\n", totalRAM)
} else {
fmt.Println("Unknown unit type - contact support.")
}
}

func printTeam(team composeAPI.Team) {
Expand Down

0 comments on commit 5177791

Please sign in to comment.