diff --git a/consumer.go b/consumer.go index 73af3db..3b2da94 100644 --- a/consumer.go +++ b/consumer.go @@ -1,12 +1,13 @@ package redisqueue import ( + "context" "net" "os" "sync" "time" - "github.com/go-redis/redis/v7" + "github.com/go-redis/redis/v8" "github.com/pkg/errors" ) @@ -98,15 +99,15 @@ var defaultConsumerOptions = &ConsumerOptions{ // to the hostname, GroupName to "redisqueue", VisibilityTimeout to 60 seconds, // BufferSize to 100, and Concurrency to 10. In most production environments, // you'll want to use NewConsumerWithOptions. -func NewConsumer() (*Consumer, error) { - return NewConsumerWithOptions(defaultConsumerOptions) +func NewConsumer(ctx context.Context) (*Consumer, error) { + return NewConsumerWithOptions(ctx, defaultConsumerOptions) } // NewConsumerWithOptions creates a Consumer with custom ConsumerOptions. If // Name is left empty, it defaults to the hostname; if GroupName is left empty, // it defaults to "redisqueue"; if BlockingTimeout is 0, it defaults to 5 // seconds; if ReclaimInterval is 0, it defaults to 1 second. -func NewConsumerWithOptions(options *ConsumerOptions) (*Consumer, error) { +func NewConsumerWithOptions(ctx context.Context, options *ConsumerOptions) (*Consumer, error) { hostname, _ := os.Hostname() if options.Name == "" { @@ -130,7 +131,7 @@ func NewConsumerWithOptions(options *ConsumerOptions) (*Consumer, error) { r = newRedisClient(options.RedisOptions) } - if err := redisPreflightChecks(r); err != nil { + if err := redisPreflightChecks(ctx, r); err != nil { return nil, err } @@ -190,7 +191,7 @@ func (c *Consumer) Run() { for stream, consumer := range c.consumers { c.streams = append(c.streams, stream) - err := c.redis.XGroupCreateMkStream(stream, c.options.GroupName, consumer.id).Err() + err := c.redis.XGroupCreateMkStream(context.Background(), stream, c.options.GroupName, consumer.id).Err() // ignoring the BUSYGROUP error makes this a noop if err != nil && err.Error() != "BUSYGROUP Consumer Group name already exists" { c.Errors <- errors.Wrap(err, "error creating consumer group") @@ -256,7 +257,7 @@ func (c *Consumer) reclaim() { end := "+" for { - res, err := c.redis.XPendingExt(&redis.XPendingExtArgs{ + res, err := c.redis.XPendingExt(context.Background(), &redis.XPendingExtArgs{ Stream: stream, Group: c.options.GroupName, Start: start, @@ -276,7 +277,7 @@ func (c *Consumer) reclaim() { for _, r := range res { if r.Idle >= c.options.VisibilityTimeout { - claimres, err := c.redis.XClaim(&redis.XClaimArgs{ + claimres, err := c.redis.XClaim(context.Background(), &redis.XClaimArgs{ Stream: stream, Group: c.options.GroupName, Consumer: c.options.Name, @@ -297,7 +298,7 @@ func (c *Consumer) reclaim() { // exists, the only way we can get it out of the // pending state is to acknowledge it. if err == redis.Nil { - err = c.redis.XAck(stream, c.options.GroupName, r.ID).Err() + err = c.redis.XAck(context.Background(), stream, c.options.GroupName, r.ID).Err() if err != nil { c.Errors <- errors.Wrapf(err, "error acknowledging after failed claim for %q stream and %q message", stream, r.ID) continue @@ -335,7 +336,7 @@ func (c *Consumer) poll() { } return default: - res, err := c.redis.XReadGroup(&redis.XReadGroupArgs{ + res, err := c.redis.XReadGroup(context.Background(), &redis.XReadGroupArgs{ Group: c.options.GroupName, Consumer: c.options.Name, Streams: c.streams, @@ -389,7 +390,7 @@ func (c *Consumer) work() { c.Errors <- errors.Wrapf(err, "error calling ConsumerFunc for %q stream and %q message", msg.Stream, msg.ID) continue } - err = c.redis.XAck(msg.Stream, c.options.GroupName, msg.ID).Err() + err = c.redis.XAck(context.Background(), msg.Stream, c.options.GroupName, msg.ID).Err() if err != nil { c.Errors <- errors.Wrapf(err, "error acknowledging after success for %q stream and %q message", msg.Stream, msg.ID) continue diff --git a/consumer_test.go b/consumer_test.go index 844ae6f..2b5a655 100644 --- a/consumer_test.go +++ b/consumer_test.go @@ -1,11 +1,12 @@ package redisqueue import ( + "context" "os" "testing" "time" - "github.com/go-redis/redis/v7" + "github.com/go-redis/redis/v8" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -13,7 +14,7 @@ import ( func TestNewConsumer(t *testing.T) { t.Run("creates a new consumer", func(tt *testing.T) { - c, err := NewConsumer() + c, err := NewConsumer(context.Background()) require.NoError(tt, err) assert.NotNil(tt, c) @@ -22,14 +23,14 @@ func TestNewConsumer(t *testing.T) { func TestNewConsumerWithOptions(t *testing.T) { t.Run("creates a new consumer", func(tt *testing.T) { - c, err := NewConsumerWithOptions(&ConsumerOptions{}) + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{}) require.NoError(tt, err) assert.NotNil(tt, c) }) t.Run("sets defaults for Name, GroupName, BlockingTimeout, and ReclaimTimeout", func(tt *testing.T) { - c, err := NewConsumerWithOptions(&ConsumerOptions{}) + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{}) require.NoError(tt, err) hostname, err := os.Hostname() @@ -44,7 +45,7 @@ func TestNewConsumerWithOptions(t *testing.T) { t.Run("allows override of Name, GroupName, BlockingTimeout, ReclaimTimeout, and RedisClient", func(tt *testing.T) { rc := newRedisClient(nil) - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ Name: "test_name", GroupName: "test_group_name", BlockingTimeout: 10 * time.Second, @@ -61,7 +62,7 @@ func TestNewConsumerWithOptions(t *testing.T) { }) t.Run("bubbles up errors", func(tt *testing.T) { - _, err := NewConsumerWithOptions(&ConsumerOptions{ + _, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ RedisOptions: &RedisOptions{Addr: "localhost:0"}, }) require.Error(tt, err) @@ -76,7 +77,7 @@ func TestRegister(t *testing.T) { } t.Run("set the function", func(tt *testing.T) { - c, err := NewConsumer() + c, err := NewConsumer(context.Background()) require.NoError(tt, err) c.Register(tt.Name(), fn) @@ -114,7 +115,7 @@ func TestRegisterWithLastID(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - c, err := NewConsumer() + c, err := NewConsumer(context.Background()) require.NoError(t, err) c.RegisterWithLastID("test", tt.id, fn) @@ -129,7 +130,7 @@ func TestRegisterWithLastID(t *testing.T) { func TestRun(t *testing.T) { t.Run("sends an error if no ConsumerFuncs are registered", func(tt *testing.T) { - c, err := NewConsumer() + c, err := NewConsumer(context.Background()) require.NoError(tt, err) go func() { @@ -143,7 +144,7 @@ func TestRun(t *testing.T) { t.Run("calls the ConsumerFunc on for a message", func(tt *testing.T) { // create a consumer - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ VisibilityTimeout: 60 * time.Second, BlockingTimeout: 10 * time.Millisecond, BufferSize: 100, @@ -152,15 +153,15 @@ func TestRun(t *testing.T) { require.NoError(tt, err) // create a producer - p, err := NewProducer() + p, err := NewProducer(context.Background()) require.NoError(tt, err) // create consumer group - c.redis.XGroupDestroy(tt.Name(), c.options.GroupName) - c.redis.XGroupCreateMkStream(tt.Name(), c.options.GroupName, "$") + c.redis.XGroupDestroy(context.Background(), tt.Name(), c.options.GroupName) + c.redis.XGroupCreateMkStream(context.Background(), tt.Name(), c.options.GroupName, "$") // enqueue a message - err = p.Enqueue(&Message{ + err = p.Enqueue(context.Background(), &Message{ Stream: tt.Name(), Values: map[string]interface{}{"test": "value"}, }) @@ -186,7 +187,7 @@ func TestRun(t *testing.T) { t.Run("reclaims pending messages according to ReclaimInterval", func(tt *testing.T) { // create a consumer - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ VisibilityTimeout: 5 * time.Millisecond, BlockingTimeout: 10 * time.Millisecond, ReclaimInterval: 1 * time.Millisecond, @@ -196,19 +197,19 @@ func TestRun(t *testing.T) { require.NoError(tt, err) // create a producer - p, err := NewProducer() + p, err := NewProducer(context.Background()) require.NoError(tt, err) // create consumer group - c.redis.XGroupDestroy(tt.Name(), c.options.GroupName) - c.redis.XGroupCreateMkStream(tt.Name(), c.options.GroupName, "$") + c.redis.XGroupDestroy(context.Background(), tt.Name(), c.options.GroupName) + c.redis.XGroupCreateMkStream(context.Background(), tt.Name(), c.options.GroupName, "$") // enqueue a message msg := &Message{ Stream: tt.Name(), Values: map[string]interface{}{"test": "value"}, } - err = p.Enqueue(msg) + err = p.Enqueue(context.Background(), msg) require.NoError(tt, err) // register a handler that will assert the message and then shut down @@ -220,7 +221,7 @@ func TestRun(t *testing.T) { }) // read the message but don't acknowledge it - res, err := c.redis.XReadGroup(&redis.XReadGroupArgs{ + res, err := c.redis.XReadGroup(context.Background(), &redis.XReadGroupArgs{ Group: c.options.GroupName, Consumer: "failed_consumer", Streams: []string{tt.Name(), ">"}, @@ -247,7 +248,7 @@ func TestRun(t *testing.T) { t.Run("doesn't reclaim if there is no VisibilityTimeout set", func(tt *testing.T) { // create a consumer - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ BlockingTimeout: 10 * time.Millisecond, ReclaimInterval: 1 * time.Millisecond, BufferSize: 100, @@ -256,15 +257,15 @@ func TestRun(t *testing.T) { require.NoError(tt, err) // create a producer - p, err := NewProducerWithOptions(&ProducerOptions{ + p, err := NewProducerWithOptions(context.Background(), &ProducerOptions{ StreamMaxLength: 2, ApproximateMaxLength: false, }) require.NoError(tt, err) // create consumer group - c.redis.XGroupDestroy(tt.Name(), c.options.GroupName) - c.redis.XGroupCreateMkStream(tt.Name(), c.options.GroupName, "$") + c.redis.XGroupDestroy(context.Background(), tt.Name(), c.options.GroupName) + c.redis.XGroupCreateMkStream(context.Background(), tt.Name(), c.options.GroupName, "$") // enqueue a message msg1 := &Message{ @@ -275,7 +276,7 @@ func TestRun(t *testing.T) { Stream: tt.Name(), Values: map[string]interface{}{"test": "value2"}, } - err = p.Enqueue(msg1) + err = p.Enqueue(context.Background(), msg1) require.NoError(tt, err) // register a handler that will assert the message and then shut down @@ -287,7 +288,7 @@ func TestRun(t *testing.T) { }) // read the message but don't acknowledge it - res, err := c.redis.XReadGroup(&redis.XReadGroupArgs{ + res, err := c.redis.XReadGroup(context.Background(), &redis.XReadGroupArgs{ Group: c.options.GroupName, Consumer: "failed_consumer", Streams: []string{tt.Name(), ">"}, @@ -299,7 +300,7 @@ func TestRun(t *testing.T) { require.Equal(tt, msg1.ID, res[0].Messages[0].ID) // add another message to the stream to let the consumer consume it - err = p.Enqueue(msg2) + err = p.Enqueue(context.Background(), msg2) require.NoError(tt, err) // watch for consumer errors @@ -312,7 +313,7 @@ func TestRun(t *testing.T) { c.Run() // check if the pending message is still there - pendingRes, err := c.redis.XPendingExt(&redis.XPendingExtArgs{ + pendingRes, err := c.redis.XPendingExt(context.Background(), &redis.XPendingExtArgs{ Stream: tt.Name(), Group: c.options.GroupName, Start: "-", @@ -326,7 +327,7 @@ func TestRun(t *testing.T) { t.Run("acknowledges pending messages that have already been deleted", func(tt *testing.T) { // create a consumer - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ VisibilityTimeout: 5 * time.Millisecond, BlockingTimeout: 10 * time.Millisecond, ReclaimInterval: 1 * time.Millisecond, @@ -336,22 +337,22 @@ func TestRun(t *testing.T) { require.NoError(tt, err) // create a producer - p, err := NewProducerWithOptions(&ProducerOptions{ + p, err := NewProducerWithOptions(context.Background(), &ProducerOptions{ StreamMaxLength: 1, ApproximateMaxLength: false, }) require.NoError(tt, err) // create consumer group - c.redis.XGroupDestroy(tt.Name(), c.options.GroupName) - c.redis.XGroupCreateMkStream(tt.Name(), c.options.GroupName, "$") + c.redis.XGroupDestroy(context.Background(), tt.Name(), c.options.GroupName) + c.redis.XGroupCreateMkStream(context.Background(), tt.Name(), c.options.GroupName, "$") // enqueue a message msg := &Message{ Stream: tt.Name(), Values: map[string]interface{}{"test": "value"}, } - err = p.Enqueue(msg) + err = p.Enqueue(context.Background(), msg) require.NoError(tt, err) // register a noop handler that should never be called @@ -361,7 +362,7 @@ func TestRun(t *testing.T) { }) // read the message but don't acknowledge it - res, err := c.redis.XReadGroup(&redis.XReadGroupArgs{ + res, err := c.redis.XReadGroup(context.Background(), &redis.XReadGroupArgs{ Group: c.options.GroupName, Consumer: "failed_consumer", Streams: []string{tt.Name(), ">"}, @@ -373,7 +374,7 @@ func TestRun(t *testing.T) { require.Equal(tt, msg.ID, res[0].Messages[0].ID) // delete the message - err = c.redis.XDel(tt.Name(), msg.ID).Err() + err = c.redis.XDel(context.Background(), tt.Name(), msg.ID).Err() require.NoError(tt, err) // watch for consumer errors @@ -392,7 +393,7 @@ func TestRun(t *testing.T) { c.Run() // check that there are no pending messages - pendingRes, err := c.redis.XPendingExt(&redis.XPendingExtArgs{ + pendingRes, err := c.redis.XPendingExt(context.Background(), &redis.XPendingExtArgs{ Stream: tt.Name(), Group: c.options.GroupName, Start: "-", @@ -405,7 +406,7 @@ func TestRun(t *testing.T) { t.Run("returns an error on a string panic", func(tt *testing.T) { // create a consumer - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ VisibilityTimeout: 60 * time.Second, BlockingTimeout: 10 * time.Millisecond, BufferSize: 100, @@ -414,15 +415,15 @@ func TestRun(t *testing.T) { require.NoError(tt, err) // create a producer - p, err := NewProducer() + p, err := NewProducer(context.Background()) require.NoError(tt, err) // create consumer group - c.redis.XGroupDestroy(tt.Name(), c.options.GroupName) - c.redis.XGroupCreateMkStream(tt.Name(), c.options.GroupName, "$") + c.redis.XGroupDestroy(context.Background(), tt.Name(), c.options.GroupName) + c.redis.XGroupCreateMkStream(context.Background(), tt.Name(), c.options.GroupName, "$") // enqueue a message - err = p.Enqueue(&Message{ + err = p.Enqueue(context.Background(), &Message{ Stream: tt.Name(), Values: map[string]interface{}{"test": "value"}, }) @@ -449,7 +450,7 @@ func TestRun(t *testing.T) { t.Run("returns an error on an error panic", func(tt *testing.T) { // create a consumer - c, err := NewConsumerWithOptions(&ConsumerOptions{ + c, err := NewConsumerWithOptions(context.Background(), &ConsumerOptions{ VisibilityTimeout: 60 * time.Second, BlockingTimeout: 10 * time.Millisecond, BufferSize: 100, @@ -458,15 +459,15 @@ func TestRun(t *testing.T) { require.NoError(tt, err) // create a producer - p, err := NewProducer() + p, err := NewProducer(context.Background()) require.NoError(tt, err) // create consumer group - c.redis.XGroupDestroy(tt.Name(), c.options.GroupName) - c.redis.XGroupCreateMkStream(tt.Name(), c.options.GroupName, "$") + c.redis.XGroupDestroy(context.Background(), tt.Name(), c.options.GroupName) + c.redis.XGroupCreateMkStream(context.Background(), tt.Name(), c.options.GroupName, "$") // enqueue a message - err = p.Enqueue(&Message{ + err = p.Enqueue(context.Background(), &Message{ Stream: tt.Name(), Values: map[string]interface{}{"test": "value"}, }) diff --git a/go.mod b/go.mod index c798d27..bff9134 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,61 @@ -module github.com/robinjoseph08/redisqueue/v2 +module github.com/Preciselyco/redisqueue/v2 -go 1.12 +go 1.18 require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.7.0 // indirect - github.com/git-chglog/git-chglog v0.0.0-20190611050339-63a4e637021f - github.com/go-redis/redis/v7 v7.3.0 - github.com/golang/protobuf v1.3.3 // indirect - github.com/imdario/mergo v0.3.7 // indirect - github.com/mattn/go-colorable v0.1.2 // indirect - github.com/mattn/goveralls v0.0.2 - github.com/pborman/uuid v1.2.0 // indirect + github.com/git-chglog/git-chglog v0.15.1 + github.com/go-redis/redis/v8 v8.11.5 + github.com/mattn/goveralls v0.0.11 github.com/pkg/errors v0.9.1 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.7.0 +) + +require ( + github.com/AlecAivazis/survey/v2 v2.3.2 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.2 // indirect + github.com/andygrunwald/go-jira v1.14.0 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/fatih/color v1.13.0 // indirect + github.com/fatih/structs v1.1.0 // indirect + github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/google/go-cmp v0.5.7 // indirect + github.com/google/go-querystring v1.0.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/huandu/xstrings v1.3.1 // indirect + github.com/imdario/mergo v0.3.12 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/kr/pty v1.1.5 // indirect + github.com/kyokomi/emoji/v2 v2.2.8 // indirect + github.com/mattn/go-colorable v0.1.11 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect + github.com/mitchellh/copystructure v1.0.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.6.2 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/shopspring/decimal v1.2.0 // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/spf13/cast v1.3.1 // indirect + github.com/trivago/tgo v1.0.7 // indirect github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df // indirect - github.com/urfave/cli v1.20.0 // indirect - golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db // indirect - gopkg.in/AlecAivazis/survey.v1 v1.8.5 // indirect - gopkg.in/kyokomi/emoji.v1 v1.5.1 // indirect - gopkg.in/yaml.v2 v2.3.0 // indirect + github.com/urfave/cli/v2 v2.3.0 // indirect + golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect + golang.org/x/mod v0.4.2 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/tools v0.1.5 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index 2208032..7c403e9 100644 --- a/go.sum +++ b/go.sum @@ -1,108 +1,144 @@ +github.com/AlecAivazis/survey/v2 v2.3.2 h1:TqTB+aDDCLYhf9/bD2TwSO8u8jDSmMUd2SUVO4gCnU8= +github.com/AlecAivazis/survey/v2 v2.3.2/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= +github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw= github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/andygrunwald/go-jira v1.14.0 h1:7GT/3qhar2dGJ0kq8w0d63liNyHOnxZsUZ9Pe4+AKBI= +github.com/andygrunwald/go-jira v1.14.0/go.mod h1:KMo2f4DgMZA1C9FdImuLc04x4WQhn5derQpnsuBFgqE= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= 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/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/git-chglog/git-chglog v0.0.0-20190611050339-63a4e637021f h1:8l4Aw3Jmx0pLKYMkY+1b6yBPgE+rzRtA5T3vqFyI2Z8= -github.com/git-chglog/git-chglog v0.0.0-20190611050339-63a4e637021f/go.mod h1:Dcsy1kii/xFyNad5JqY/d0GO5mu91sungp5xotbm3Yk= -github.com/go-redis/redis/v7 v7.3.0 h1:3oHqd0W7f/VLKBxeYTEpqdMUsmMectngjM9OtoRoIgg= -github.com/go-redis/redis/v7 v7.3.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/git-chglog/git-chglog v0.15.1 h1:s4FqW1jQ8ZVb3M6p9uMZDvspm4zkatVJcyG0p/Q4h7U= +github.com/git-chglog/git-chglog v0.15.1/go.mod h1:ODSB06FDj/KND1ul+aBOqETRy5tvs+Kk4YdDmD7soeU= +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= -github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.5 h1:hyz3dwM5QLc1Rfoz4FuWJQG5BN7tc6K1MndAUnGpQr4= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kyokomi/emoji/v2 v2.2.8 h1:jcofPxjHWEkJtkIbcLHvZhxKgCPl6C7MyjTrD4KDqUE= +github.com/kyokomi/emoji/v2 v2.2.8/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/goveralls v0.0.2 h1:7eJB6EqsPhRVxvwEXGnqdO2sJI0PTsrWoTMXEk9/OQc= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= -github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/goveralls v0.0.11 h1:eJXea6R6IFlL1QMKNMzDvvHv/hwGrnvyig4N+0+XiMM= +github.com/mattn/goveralls v0.0.11/go.mod h1:gU8SyhNswsJKchEV93xRQxX6X3Ei4PJdQk/6ZHvrvRk= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= +github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/trivago/tgo v1.0.7 h1:uaWH/XIy9aWYWpjm2CU3RpcqZXmX2ysQ9/Go+d9gyrM= +github.com/trivago/tgo v1.0.7/go.mod h1:w4dpD+3tzNIIiIfkWWa85w5/B77tlvdZckQ+6PkFnhc= github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df h1:Y2l28Jr3vOEeYtxfVbMtVfOdAwuUqWaP9fvNKiBVeXY= github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df/go.mod h1:pnyouUty/nBr/zm3GYwTIt+qFTLWbdjeLjZmJdzJOu8= -github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY= -golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= +golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db h1:9hRk1xeL9LTT3yX/941DqeBz87XgHAQuj+TbimYJuiw= -golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= -gopkg.in/AlecAivazis/survey.v1 v1.8.5 h1:QoEEmn/d5BbuPIL2qvXwzJdttFFhRQFkaq+tEKb7SMI= -gopkg.in/AlecAivazis/survey.v1 v1.8.5/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/kyokomi/emoji.v1 v1.5.1 h1:beetH5mWDMzFznJ+Qzd5KVHp79YKhVUMcdO8LpRLeGw= -gopkg.in/kyokomi/emoji.v1 v1.5.1/go.mod h1:N9AZ6hi1jHOPn34PsbpufQZUcKftSD7WgS2pgpmH4Lg= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/producer.go b/producer.go index b52c028..a957a5e 100644 --- a/producer.go +++ b/producer.go @@ -1,7 +1,9 @@ package redisqueue import ( - "github.com/go-redis/redis/v7" + "context" + + "github.com/go-redis/redis/v8" ) // ProducerOptions provide options to configure the Producer. @@ -46,12 +48,12 @@ var defaultProducerOptions = &ProducerOptions{ // NewProducer uses a default set of options to create a Producer. It sets // StreamMaxLength to 1000 and ApproximateMaxLength to true. In most production // environments, you'll want to use NewProducerWithOptions. -func NewProducer() (*Producer, error) { - return NewProducerWithOptions(defaultProducerOptions) +func NewProducer(ctx context.Context) (*Producer, error) { + return NewProducerWithOptions(ctx, defaultProducerOptions) } // NewProducerWithOptions creates a Producer using custom ProducerOptions. -func NewProducerWithOptions(options *ProducerOptions) (*Producer, error) { +func NewProducerWithOptions(ctx context.Context, options *ProducerOptions) (*Producer, error) { var r redis.UniversalClient if options.RedisClient != nil { @@ -60,7 +62,7 @@ func NewProducerWithOptions(options *ProducerOptions) (*Producer, error) { r = newRedisClient(options.RedisOptions) } - if err := redisPreflightChecks(r); err != nil { + if err := redisPreflightChecks(ctx, r); err != nil { return nil, err } @@ -74,7 +76,7 @@ func NewProducerWithOptions(options *ProducerOptions) (*Producer, error) { // msg.Stream. While you can set msg.ID, unless you know what you're doing, you // should let Redis auto-generate the ID. If an ID is auto-generated, it will be // set on msg.ID for your reference. msg.Values is also required. -func (p *Producer) Enqueue(msg *Message) error { +func (p *Producer) Enqueue(ctx context.Context, msg *Message) error { args := &redis.XAddArgs{ ID: msg.ID, Stream: msg.Stream, @@ -85,7 +87,7 @@ func (p *Producer) Enqueue(msg *Message) error { } else { args.MaxLen = p.options.StreamMaxLength } - id, err := p.redis.XAdd(args).Result() + id, err := p.redis.XAdd(ctx, args).Result() if err != nil { return err } diff --git a/producer_test.go b/producer_test.go index 6c00b9a..2e3125a 100644 --- a/producer_test.go +++ b/producer_test.go @@ -1,6 +1,7 @@ package redisqueue import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -9,7 +10,7 @@ import ( func TestNewProducer(t *testing.T) { t.Run("creates a new producer", func(tt *testing.T) { - p, err := NewProducer() + p, err := NewProducer(context.Background()) require.NoError(tt, err) assert.NotNil(tt, p) @@ -18,7 +19,7 @@ func TestNewProducer(t *testing.T) { func TestNewProducerWithOptions(t *testing.T) { t.Run("creates a new producer", func(tt *testing.T) { - p, err := NewProducerWithOptions(&ProducerOptions{}) + p, err := NewProducerWithOptions(context.Background(), &ProducerOptions{}) require.NoError(tt, err) assert.NotNil(tt, p) @@ -27,7 +28,7 @@ func TestNewProducerWithOptions(t *testing.T) { t.Run("allows custom *redis.Client", func(tt *testing.T) { rc := newRedisClient(nil) - p, err := NewProducerWithOptions(&ProducerOptions{ + p, err := NewProducerWithOptions(context.Background(), &ProducerOptions{ RedisClient: rc, }) require.NoError(tt, err) @@ -37,7 +38,7 @@ func TestNewProducerWithOptions(t *testing.T) { }) t.Run("bubbles up errors", func(tt *testing.T) { - _, err := NewProducerWithOptions(&ProducerOptions{ + _, err := NewProducerWithOptions(context.Background(), &ProducerOptions{ RedisOptions: &RedisOptions{Addr: "localhost:0"}, }) require.Error(tt, err) @@ -48,29 +49,29 @@ func TestNewProducerWithOptions(t *testing.T) { func TestEnqueue(t *testing.T) { t.Run("puts the message in the stream", func(tt *testing.T) { - p, err := NewProducerWithOptions(&ProducerOptions{}) + p, err := NewProducerWithOptions(context.Background(), &ProducerOptions{}) require.NoError(t, err) msg := &Message{ Stream: tt.Name(), Values: map[string]interface{}{"test": "value"}, } - err = p.Enqueue(msg) + err = p.Enqueue(context.Background(), msg) require.NoError(tt, err) - res, err := p.redis.XRange(msg.Stream, msg.ID, msg.ID).Result() + res, err := p.redis.XRange(context.Background(), msg.Stream, msg.ID, msg.ID).Result() require.NoError(tt, err) assert.Equal(tt, "value", res[0].Values["test"]) }) t.Run("bubbles up errors", func(tt *testing.T) { - p, err := NewProducerWithOptions(&ProducerOptions{ApproximateMaxLength: true}) + p, err := NewProducerWithOptions(context.Background(), &ProducerOptions{ApproximateMaxLength: true}) require.NoError(t, err) msg := &Message{ Stream: tt.Name(), } - err = p.Enqueue(msg) + err = p.Enqueue(context.Background(), msg) require.Error(tt, err) assert.Contains(tt, err.Error(), "wrong number of arguments") diff --git a/redis.go b/redis.go index 0a5a68c..9716f0b 100644 --- a/redis.go +++ b/redis.go @@ -1,12 +1,13 @@ package redisqueue import ( + "context" "fmt" "regexp" "strconv" "strings" - "github.com/go-redis/redis/v7" + "github.com/go-redis/redis/v8" "github.com/pkg/errors" ) @@ -29,8 +30,8 @@ func newRedisClient(options *RedisOptions) *redis.Client { // offers the functionality we need. Specifically, it also that it can connect // to the actual instance and that the instance supports Redis streams (i.e. // it's at least v5). -func redisPreflightChecks(client redis.UniversalClient) error { - info, err := client.Info("server").Result() +func redisPreflightChecks(ctx context.Context, client redis.UniversalClient) error { + info, err := client.Info(ctx, "server").Result() if err != nil { return err } diff --git a/redis_test.go b/redis_test.go index 4614ab7..10dc2fa 100644 --- a/redis_test.go +++ b/redis_test.go @@ -1,6 +1,7 @@ package redisqueue import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -12,14 +13,14 @@ func TestNewRedisClient(t *testing.T) { options := &RedisOptions{} r := newRedisClient(options) - err := r.Ping().Err() + err := r.Ping(context.Background()).Err() assert.NoError(tt, err) }) t.Run("defaults options if it's nil", func(tt *testing.T) { r := newRedisClient(nil) - err := r.Ping().Err() + err := r.Ping(context.Background()).Err() assert.NoError(tt, err) }) } @@ -29,7 +30,7 @@ func TestRedisPreflightChecks(t *testing.T) { options := &RedisOptions{Addr: "localhost:0"} r := newRedisClient(options) - err := redisPreflightChecks(r) + err := redisPreflightChecks(context.Background(), r) require.Error(tt, err) assert.Contains(tt, err.Error(), "dial tcp")