Skip to content

Commit 4bb0ac7

Browse files
committed
utils: Drop MaxInt
A generic max function was added to Go in version 1.21[0], making the utils.MaxInt obsolete. Outside, it was not used in neither icingadb, icinga-notifications nor icinga-kubernetes. > $ for project in icingadb icinga-notifications icinga-kubernetes; do pushd "$project"; git checkout main; git pull; grep -r "MaxInt"; popd; done > ~/git/github.com/Icinga/icingadb ~/git/github.com/Icinga > Already on 'main' > Your branch is up to date with 'origin/main'. > Already up to date. > cmd/icingadb-migrate/cache.go: checkpoint = math.MaxInt64 // start from the largest (possible) ID > cmd/icingadb-migrate/main.go: ht.fromId = math.MaxInt64 > grep: icingadb-migrate: binary file matches > grep: icingadb: binary file matches > ~/git/github.com/Icinga > ~/git/github.com/Icinga/icinga-notifications ~/git/github.com/Icinga > Already on 'main' > Your branch is up to date with 'origin/main'. > Already up to date. > internal/rule/condition.go:const RetryNever = time.Duration(math.MaxInt64) > ~/git/github.com/Icinga > ~/git/github.com/Icinga/icinga-kubernetes ~/git/github.com/Icinga > Already on 'main' > Your branch is up to date with 'origin/main'. > Already up to date. > pkg/schema/v1/pod.go: p.CpuLimits = MaxInt(p.CpuLimits, container.Resources.Limits.Cpu().MilliValue()) > pkg/schema/v1/pod.go: p.CpuRequests = MaxInt(p.CpuRequests, container.Resources.Requests.Cpu().MilliValue()) > pkg/schema/v1/pod.go: p.MemoryLimits = MaxInt(p.MemoryLimits, container.Resources.Limits.Memory().MilliValue()) > pkg/schema/v1/pod.go: p.MemoryRequests = MaxInt(p.MemoryRequests, container.Resources.Requests.Memory().MilliValue()) > pkg/schema/v1/utils.go:func MaxInt[T constraints.Integer](x, y T) T { > ~/git/github.com/Icinga [0]: https://pkg.go.dev/builtin#max
1 parent 715b56e commit 4bb0ac7

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

redis/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func NewClientFromConfig(c *Config, logger *logging.Logger) (*Client, error) {
7373

7474
client := redis.NewClient(options)
7575
options = client.Options()
76-
options.PoolSize = utils.MaxInt(32, options.PoolSize)
76+
options.PoolSize = max(32, options.PoolSize)
7777
options.MaxRetries = options.PoolSize + 1 // https://github.com/go-redis/redis/issues/1737
7878

7979
return NewClient(redis.NewClient(options), logger, &c.Options), nil

utils/utils.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ func AppName() string {
124124
return filepath.Base(exe)
125125
}
126126

127-
// MaxInt returns the larger of the given integers.
128-
func MaxInt(x, y int) int {
129-
if x > y {
130-
return x
131-
}
132-
133-
return y
134-
}
135-
136127
// IsUnixAddr indicates whether the given host string represents a Unix socket address.
137128
//
138129
// A host string that begins with a forward slash ('/') is considered Unix socket address.

0 commit comments

Comments
 (0)