From 507d09111cfd375f86c969fb8007f3bbd31cc19f Mon Sep 17 00:00:00 2001 From: Marco Tusa Date: Wed, 18 Oct 2023 16:39:46 +0200 Subject: [PATCH] Fr 14 (#16) * start modification * DONE Add constants as idioms DONE Functions to get params as string directly from Family object * Implementing also the auto calculation for the connections * Update README.md * Update README.md * Update README.md * Update help * grouping constants * Adjust several calculation to better represent the load scenarios. add the CpuConncetionMillFactor const which is the key to tune the load factor * Adjust several calculation to better represent the load scenarios. add the CpuConncetionMillFactor const which is the key to tune the load factor * some comments for future development * Version fix * missing go.mod :/ * readme fix * Update README.md --- README.md | 11 +++++++++-- go.mod | 8 +++++--- go.sum | 8 ++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 78f0baa..9d1cf94 100644 --- a/README.md +++ b/README.md @@ -552,7 +552,14 @@ func testGetconfiguration(moc MO.MysqlOperatorCalculator) { var err error myRequest.LoadType = MO.LoadType{Id: 2} - myRequest.Dimension = MO.Dimension{Id: 999, Cpu: 4000, Memory: 2.5} + myRequest.Dimension = MO.Dimension{Id: 999, Cpu: 4000, Memory: "2.5GB"} + var errConv error + myRequest.Dimension.MemoryBytes, errConv = myRequest.Dimension.ConvertMemoryToBytes(myRequest.Dimension.Memory) + // If any error then do what you want ... + if errConv != nil { + println(errConv.Error()) + syscall.Exit(1) + } myRequest.DBType = "group_replication" //"pxc" myRequest.Output = "human" //"human" myRequest.Connections = 70 @@ -591,7 +598,7 @@ The first object we need to create is the ConfigurationRequest: then we can populate it, in this case we DO NOT set a supported environment but an open scope: ```go myRequest.LoadType = MO.LoadType{Id: 2} - myRequest.Dimension = MO.Dimension{Id: 999, Cpu: 4000, Memory: 2.5} + myRequest.Dimension = MO.Dimension{Id: 999, Cpu: 4000, MemoryBytes: 2684354560} myRequest.DBType = "group_replication" //"pxc" myRequest.Output = "human" //"human" myRequest.Connections = 70 diff --git a/go.mod b/go.mod index 0a2c753..534518b 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,14 @@ module github.com/Tusamarco/mysqloperatorcalculator -go 1.20 +go 1.21 -require github.com/sirupsen/logrus v1.9.0 +require github.com/sirupsen/logrus v1.9.3 require ( + code.cloudfoundry.org/bytefmt v0.0.0-20230612151507-41ef4d1f67a4 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect + github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf // indirect + golang.org/x/sys v0.13.0 // indirect ) //require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect diff --git a/go.sum b/go.sum index 087e828..5b88ee9 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,25 @@ +code.cloudfoundry.org/bytefmt v0.0.0-20230612151507-41ef4d1f67a4 h1:9G5F8zgma5v0GdDvNz6iZwwJp3RS/z0SY/aHGfVwvTo= +code.cloudfoundry.org/bytefmt v0.0.0-20230612151507-41ef4d1f67a4/go.mod h1:wYHCXH/gI19ujoFVuMkY48qPpPCoHLKBKXPkn67h/Yc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf h1:FtEj8sfIcaaBfAKrE1Cwb61YDtYq9JxChK1c7AKce7s= +github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf/go.mod h1:yrqSXGoD/4EKfF26AOGzscPOgTTJcyAwM2rpixWT+t4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=