diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdf274a..cfbe496 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: - name: Set up Golang uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' - name: Test run: go test -v -p 1 -parallel 1 -failfast ./... @@ -80,7 +80,7 @@ jobs: - name: Set up Golang uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' - name: Test run: go test -v -p 1 -parallel 1 -failfast ./... @@ -113,7 +113,7 @@ jobs: - name: Set up Golang uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' - name: Get dependencies run: | diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8952732..83e8100 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Golang uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' # despite the fact docker will build binary internally # we want to stop workflow in case of any error before pushing to registry diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d988266..f733bfc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Set up Golang uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' - name: Check out code into the Go module directory uses: actions/checkout@v3 diff --git a/go.mod b/go.mod index dfabe19..c2c6ea5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cybertec-postgresql/pg_timetable -go 1.20 +go 1.21 require ( github.com/cavaliercoder/grab v2.0.0+incompatible diff --git a/go.sum b/go.sum index a4a27f9..af268bc 100644 --- a/go.sum +++ b/go.sum @@ -58,6 +58,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -100,6 +101,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -140,9 +142,11 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -163,6 +167,7 @@ github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnH github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec= github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -495,6 +500,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/internal/scheduler/chain.go b/internal/scheduler/chain.go index 44e649b..225b410 100644 --- a/internal/scheduler/chain.go +++ b/internal/scheduler/chain.go @@ -167,7 +167,7 @@ func (sch *Scheduler) chainWorker(ctx context.Context, chains <-chan Chain) { } func getTimeoutContext(ctx context.Context, t1 int, t2 int) (context.Context, context.CancelFunc) { - timeout := Max(t1, t2) + timeout := max(t1, t2) if timeout > 0 { return context.WithTimeout(ctx, time.Millisecond*time.Duration(timeout)) } diff --git a/internal/scheduler/scheduler.go b/internal/scheduler/scheduler.go index 3f19895..f87dde2 100644 --- a/internal/scheduler/scheduler.go +++ b/internal/scheduler/scheduler.go @@ -47,21 +47,13 @@ type Scheduler struct { status RunStatus } -// Max returns the maximum number of two arguments -func Max(x, y int) int { - if x < y { - return y - } - return x -} - // New returns a new instance of Scheduler func New(pge *pgengine.PgEngine, logger log.LoggerIface) *Scheduler { return &Scheduler{ l: logger, pgengine: pge, - chainsChan: make(chan Chain, Max(minChannelCapacity, pge.Resource.CronWorkers*2)), - ichainsChan: make(chan IntervalChain, Max(minChannelCapacity, pge.Resource.IntervalWorkers*2)), + chainsChan: make(chan Chain, max(minChannelCapacity, pge.Resource.CronWorkers*2)), + ichainsChan: make(chan IntervalChain, max(minChannelCapacity, pge.Resource.IntervalWorkers*2)), activeChains: make(map[int]func()), //holds cancel() functions to stop chains intervalChains: make(map[int]IntervalChain), shutdown: make(chan struct{}), diff --git a/internal/scheduler/scheduler_test.go b/internal/scheduler/scheduler_test.go index d97f297..072028b 100644 --- a/internal/scheduler/scheduler_test.go +++ b/internal/scheduler/scheduler_test.go @@ -63,8 +63,8 @@ func TestRun(t *testing.T) { time.Sleep(10 * time.Second) sch.Shutdown() }() - assert.Equal(t, 1, Max(0, 1)) - assert.Equal(t, 1, Max(1, 0)) + assert.Equal(t, 1, max(0, 1)) + assert.Equal(t, 1, max(1, 0)) assert.True(t, sch.IsReady()) assert.Equal(t, ShutdownStatus, sch.Run(context.Background())) }