Skip to content

Commit

Permalink
require go 1.22, add ENV flag for 2.x breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Apr 25, 2024
1 parent 79bac56 commit 023773f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ clean: ## Clean the project, set it up for a new build
@mkdir -p packaging/output/upstart
@mkdir -p packaging/output/systemd
@mkdir -p tmp/linux
@go clean -testcache

run: clean generate ## Run Faktory daemon locally
FAKTORY_PASSWORD=${PASSWORD} go run cmd/faktory/daemon.go -l debug -e development
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/contribsys/faktory

go 1.21
go 1.22

require (
github.com/BurntSushi/toml v0.4.1
Expand Down
9 changes: 8 additions & 1 deletion util/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import (
"encoding/json"
)

func Must[T any](obj T, err error) T {
if err != nil {
panic(err)
}
return obj
}

var (
// If true, activates encoding/json's Decoder and its UseNumber()
// option to preserve number precision.
// Defaults to false in Faktory 1.x.
// Will default to true in Faktory 2.x
JsonUseNumber bool = false
JsonUseNumber bool = Faktory2Preview
)

func JsonUnmarshal(data []byte, target any) error {
Expand Down
7 changes: 7 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package util

import (
"cmp"

Check failure on line 4 in util/util.go

View workflow job for this annotation

GitHub Actions / build

package cmp is not in GOROOT (/opt/hostedtoolcache/go/1.20.14/x64/src/cmp)
"context"
cryptorand "crypto/rand"
"encoding/base64"
"fmt"
"math/big"
"os"
"runtime"
"strconv"
"time"
)

Expand All @@ -20,6 +22,11 @@ const (
maxInt63 = int64(^uint64(0) >> 1)
)

var (
// Set FAKTORY2_PREVIEW=true to enable breaking changes coming in Faktory 2.0.
Faktory2Preview bool = Must(strconv.ParseBool(cmp.Or(os.Getenv("FAKTORY2_PREVIEW"), "false")))
)

func Retryable(ctx context.Context, name string, count int, fn func() error) error {
var err error
for i := 0; i < count; i++ {
Expand Down

0 comments on commit 023773f

Please sign in to comment.