diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..01fffd3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4d8f12a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Go + +on: + push: + branches: [v3] + pull_request: + branches: [v3] + +jobs: + build: + name: build + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.16.x] + + services: + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 + ports: + - 6379:6379 + + steps: + - name: Set up ${{ matrix.go-version }} + uses: actions/setup-go@v2 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Test + run: make test diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..6c12b83 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,19 @@ +name: golangci-lint + +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5e4b7dd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,15 @@ +name: Releases + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ncipollo/release-action@v1 + with: + body: Check CHANGELOG.md for details diff --git a/.prettierrc b/.prettierrc index 3032bde..13ebff2 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,2 +1,2 @@ proseWrap: always -printWidth: 80 +printWidth: 100 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5025ae2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: go - -services: - - redis-server - -go: - - 1.12.x - - 1.13.x - - 1.14.x - - tip - -matrix: - allow_failures: - - go: tip - -env: - - GO111MODULE=on - -go_import_path: github.com/vmihailenco/taskq - -before_install: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0 diff --git a/Makefile b/Makefile index c041851..78925a3 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,5 @@ all: go test ./... -run=NONE -bench=. -benchmem golangci-lint run -tag: - git tag $(VERSION) - git tag extra/taskqotel/$(VERSION) +test: + go test diff --git a/README.md b/README.md index bdd0dbf..6bfa354 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,20 @@ # Golang asynchronous task/job queue with Redis, SQS, IronMQ, and in-memory backends -[![Build Status](https://travis-ci.org/vmihailenco/taskq.svg)](https://travis-ci.org/vmihailenco/taskq) -[![GoDoc](https://godoc.org/github.com/vmihailenco/taskq?status.svg)](https://pkg.go.dev/github.com/vmihailenco/taskq/v3?tab=doc) +![build workflow](https://github.com/vmihailenco/taskq/actions/workflows/build.yml/badge.svg) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/vmihailenco/taskq/v3)](https://pkg.go.dev/github.com/vmihailenco/taskq/v3?tab=doc) ## Installation taskq supports 2 last Go versions and requires a Go version with -[modules](https://github.com/golang/go/wiki/Modules) support. So make sure to -initialize a Go module: +[modules](https://github.com/golang/go/wiki/Modules) support. So make sure to initialize a Go +module: ```shell go mod init github.com/my/repo ``` -And then install taskq/v3 (note _v3_ in the import; omitting it is a popular -mistake): +And then install taskq/v3 (note _v3_ in the import; omitting it is a popular mistake): ```shell go get github.com/vmihailenco/taskq/v3 @@ -29,16 +28,14 @@ go get github.com/vmihailenco/taskq/v3 ## Features - Redis, SQS, IronMQ, and in-memory backends. -- Automatically scaling number of goroutines used to fetch (fetcher) and process - messages (worker). +- Automatically scaling number of goroutines used to fetch (fetcher) and process messages (worker). - Global rate limiting. - Global limit of workers. - Call once - deduplicating messages with same name. - Automatic retries with exponential backoffs. - Automatic pausing when all messages in queue fail. - Fallback handler for processing failed messages. -- Message batching. It is used in SQS and IronMQ backends to add/delete messages - in batches. +- Message batching. It is used in SQS and IronMQ backends to add/delete messages in batches. - Automatic message compression using snappy / s2. ## Quickstart @@ -54,8 +51,8 @@ This way you can: - Scale API and worker separately. - Have different configs for API and worker (like timeouts). -There is an [api_worker example](example/api_worker) that demonstrates this -approach using Redis as a backend: +There is an [api_worker example](example/api_worker) that demonstrates this approach using Redis as +a backend: ```bash cd example/api_worker @@ -166,33 +163,28 @@ for i := 0; i < 100; i++ { ## Message deduplication -If a `Message` has a `Name` then this will be used as unique identifier and -messages with the same name will be deduplicated (i.e. not processed again) -within a 24 hour period (or possibly longer if not evicted from local cache -after that period). Where `Name` is omitted then non deduplication occurs and -each message will be processed. `Task`'s `WithMessage` and `WithArgs` both -produces messages with no `Name` so will not be deduplicated. `OnceWithArgs` -sets a name based off a consistent hash of the arguments and a quantised period -of time (i.e. 'this hour', 'today') passed to `OnceWithArgs` a `period`. This -guarantees that the same function will not be called with the same arguments -during `period'. +If a `Message` has a `Name` then this will be used as unique identifier and messages with the same +name will be deduplicated (i.e. not processed again) within a 24 hour period (or possibly longer if +not evicted from local cache after that period). Where `Name` is omitted then non deduplication +occurs and each message will be processed. `Task`'s `WithMessage` and `WithArgs` both produces +messages with no `Name` so will not be deduplicated. `OnceWithArgs` sets a name based off a +consistent hash of the arguments and a quantised period of time (i.e. 'this hour', 'today') passed +to `OnceWithArgs` a `period`. This guarantees that the same function will not be called with the +same arguments during `period'. ## Handlers -A `Handler` and `FallbackHandler` are supplied to `RegisterTask` in the -`TaskOptions`. +A `Handler` and `FallbackHandler` are supplied to `RegisterTask` in the `TaskOptions`. There are three permitted types of signature: 1. A zero-argument function -2. A function whose arguments are assignable in type from those which are passed - in the message +2. A function whose arguments are assignable in type from those which are passed in the message 3. A function which takes a single `*Message` argument -If a task is registered with a handler that takes a Go `context.Context` as its -first argument then when that handler is invoked it will be passed the same -`Context` that was passed to `Consumer.Start(ctx)`. This can be used to transmit -a signal to abort to all tasks being processed: +If a task is registered with a handler that takes a Go `context.Context` as its first argument then +when that handler is invoked it will be passed the same `Context` that was passed to +`Consumer.Start(ctx)`. This can be used to transmit a signal to abort to all tasks being processed: ```go var AbortableTask = MainQueue.RegisterTask(&taskq.TaskOptions{ @@ -214,8 +206,8 @@ var AbortableTask = MainQueue.RegisterTask(&taskq.TaskOptions{ ## Custom message delay -If error returned by handler implements `Delay() time.Duration` interface then -that delay is used to postpone message processing. +If error returned by handler implements `Delay() time.Duration` interface then that delay is used to +postpone message processing. ```go type RateLimitError string @@ -235,9 +227,8 @@ func handler() error { ## Tracing -taskq supports tracing out-of-the-box using -[OpenTelemetry](https://opentelemetry.io/) API. To instrument a queue, use the -following code: +taskq supports tracing out-of-the-box using [OpenTelemetry](https://opentelemetry.io/) API. To +instrument a queue, use the following code: ```go import "github.com/vmihailenco/taskq/extra/taskqotel/v3" @@ -257,5 +248,4 @@ factory.Range(func(q taskq.Queue) bool { }) ``` -We recommend using [Uptrace.dev](https://github.com/uptrace/uptrace-go) as a -tracing backend. +We recommend using [Uptrace.dev](https://github.com/uptrace/uptrace-go) as a tracing backend. diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..1115db4 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,15 @@ +# Releasing + +1. Run `release.sh` script which updates versions in go.mod files and pushes a new branch to GitHub: + +```shell +TAG=v1.0.0 ./scripts/release.sh +``` + +2. Open a pull request and wait for the build to finish. + +3. Merge the pull request and run `tag.sh` to create tags for packages: + +```shell +TAG=v1.0.0 ./scripts/tag.sh +``` diff --git a/azsqs_test.go b/azsqs_test.go index c6d6704..654bc57 100644 --- a/azsqs_test.go +++ b/azsqs_test.go @@ -26,72 +26,96 @@ func azsqsFactory() taskq.Factory { } func TestSQSConsumer(t *testing.T) { + t.Skip() + testConsumer(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-consumer"), }) } func TestSQSUnknownTask(t *testing.T) { + t.Skip() + testUnknownTask(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-unknown-task"), }) } func TestSQSFallback(t *testing.T) { + t.Skip() + testFallback(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-fallback"), }) } func TestSQSDelay(t *testing.T) { + t.Skip() + testDelay(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-delay"), }) } func TestSQSRetry(t *testing.T) { + t.Skip() + testRetry(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-retry"), }) } func TestSQSNamedMessage(t *testing.T) { + t.Skip() + testNamedMessage(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-named-message"), }) } func TestSQSCallOnce(t *testing.T) { + t.Skip() + testCallOnce(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-call-once"), }) } func TestSQSLen(t *testing.T) { + t.Skip() + testLen(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-queue-len"), }) } func TestSQSRateLimit(t *testing.T) { + t.Skip() + testRateLimit(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-rate-limit"), }) } func TestSQSErrorDelay(t *testing.T) { + t.Skip() + testErrorDelay(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-delayer"), }) } func TestSQSWorkerLimit(t *testing.T) { + t.Skip() + testWorkerLimit(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-worker-limit"), }) } func TestSQSInvalidCredentials(t *testing.T) { + t.Skip() + man := azsqs.NewFactory(awsSQS(), "123") testInvalidCredentials(t, man, &taskq.QueueOptions{ Name: queueName("sqs-invalid-credentials"), @@ -99,12 +123,16 @@ func TestSQSInvalidCredentials(t *testing.T) { } func TestSQSBatchConsumerSmallMessage(t *testing.T) { + t.Skip() + testBatchConsumer(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-batch-consumer-small-message"), }, 100) } func TestSQSBatchConsumerLarge(t *testing.T) { + t.Skip() + testBatchConsumer(t, azsqsFactory(), &taskq.QueueOptions{ Name: queueName("sqs-batch-processor-large-message"), }, 64000) diff --git a/go.mod b/go.mod index 649979e..df27ca4 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/iron-io/iron_go3 v0.0.0-20190916120531-a4a7f74b73ac github.com/jeffh/go.bdd v0.0.0-20120717032931-88f798ee0c74 // indirect github.com/klauspost/compress v1.12.2 + github.com/kr/pretty v0.2.1 // indirect github.com/onsi/ginkgo v1.15.0 github.com/onsi/gomega v1.10.5 github.com/satori/go.uuid v1.2.0 diff --git a/go.sum b/go.sum index 4026662..1afdeb8 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/aws/aws-sdk-go v1.35.28 h1:S2LuRnfC8X05zgZLC8gy/Sb82TGv2Cpytzbzz7tkeHc= -github.com/aws/aws-sdk-go v1.35.28/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= github.com/aws/aws-sdk-go v1.40.25 h1:Depnx7O86HWgOCLD5nMto6F9Ju85Q1QuFDnbpZYQWno= github.com/aws/aws-sdk-go v1.40.25/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/bsm/redislock v0.7.0 h1:RL7aZJhCKkuBjQbnSTKCeedTRifBWxd/ffP+GZ599Mo= @@ -29,12 +27,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-redis/redis/v8 v8.1.0/go.mod h1:isLoQT/NFSP7V67lyvM9GmdvLdyZ7pEhsXvvyQtnQTo= github.com/go-redis/redis/v8 v8.3.4/go.mod h1:jszGxBCez8QA1HWSmQxJO9Y82kNibbUmeYhKWrBejTU= -github.com/go-redis/redis/v8 v8.4.0 h1:J5NCReIgh3QgUJu398hUncxDExN4gMOHI11NVbVicGQ= -github.com/go-redis/redis/v8 v8.4.0/go.mod h1:A1tbYoHSa1fXwN+//ljcCYYJeLmVrwL9hbQN45Jdy0M= github.com/go-redis/redis/v8 v8.11.2 h1:WqlSpAwz8mxDSMCvbyz1Mkiqe0LE5OY4j3lgkvu1Ts0= github.com/go-redis/redis/v8 v8.11.2/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M= -github.com/go-redis/redis_rate/v9 v9.1.0 h1:5FOi8UWgxTQ2KlvUg25xPdv2UBxyeRIJJtMZJhBF78U= -github.com/go-redis/redis_rate/v9 v9.1.0/go.mod h1:jjU9YxOSZ3cz0yj1QJVAJiy5ueKmL9o4AySJHcKyTSE= github.com/go-redis/redis_rate/v9 v9.1.1 h1:7SIrbnhQ7zsTNEgIvprFhJf7/+l3wSpZc2iRVwUmaq8= github.com/go-redis/redis_rate/v9 v9.1.1/go.mod h1:jjU9YxOSZ3cz0yj1QJVAJiy5ueKmL9o4AySJHcKyTSE= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -59,8 +53,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -77,8 +70,9 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8= github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -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/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 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= @@ -87,14 +81,12 @@ github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.15.0 h1:1V1NfVQR87RtWAgp1lv9JZJ5Jap+XFGKPi00andXGi4= github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/onsi/gomega v1.10.5 h1:7n6FEkpFmfCoo2t+YYqXH0evK+a9ICQz0xcAy9dYcaQ= github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= @@ -107,19 +99,13 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/vmihailenco/msgpack/v5 v5.0.0 h1:nCaMMPEyfgwkGc/Y0GreJPhuvzqCqW+Ufq5lY7zLO2c= -github.com/vmihailenco/msgpack/v5 v5.0.0/go.mod h1:HVxBVPUK/+fZMonk4bi1islLa8V3cfnBug0+4dykPzo= github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc= github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= -github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vbd1qPqc= -github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/otel v0.11.0/go.mod h1:G8UCk+KooF2HLkgo8RHX9epABH/aRGYET7gQOqBVdB0= go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY= -go.opentelemetry.io/otel v0.14.0 h1:YFBEfjCk9MTjaytCNSUkp9Q8lF7QJezA06T71FbQxLQ= -go.opentelemetry.io/otel v0.14.0/go.mod h1:vH5xEuwy7Rts0GNtsCW3HYQoZDY+OmBJ6t1bFGGlxgw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -142,14 +128,11 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 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-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201027133719-8eef5233e2a1 h1:IEhJ99VWSYpHIxjlbu3DQyHegGPnQYAv0IaCX9KHyG0= -golang.org/x/net v0.0.0-20201027133719-8eef5233e2a1/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -168,17 +151,16 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -190,8 +172,8 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 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 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 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= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -212,7 +194,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= 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-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/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/ironmq_test.go b/ironmq_test.go index dbcc78b..94383ec 100644 --- a/ironmq_test.go +++ b/ironmq_test.go @@ -15,72 +15,96 @@ func ironmqFactory() taskq.Factory { } func TestIronmqConsumer(t *testing.T) { + t.Skip() + testConsumer(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-consumer"), }) } func TestIronmqUnknownTask(t *testing.T) { + t.Skip() + testUnknownTask(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-unknown-task"), }) } func TestIronmqFallback(t *testing.T) { + t.Skip() + testFallback(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-fallback"), }) } func TestIronmqDelay(t *testing.T) { + t.Skip() + testDelay(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-delay"), }) } func TestIronmqRetry(t *testing.T) { + t.Skip() + testRetry(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-retry"), }) } func TestIronmqNamedMessage(t *testing.T) { + t.Skip() + testNamedMessage(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-named-message"), }) } func TestIronmqCallOnce(t *testing.T) { + t.Skip() + testCallOnce(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-call-once"), }) } func TestIronmqLen(t *testing.T) { + t.Skip() + testLen(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-len"), }) } func TestIronmqRateLimit(t *testing.T) { + t.Skip() + testRateLimit(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-rate-limit"), }) } func TestIronmqErrorDelay(t *testing.T) { + t.Skip() + testErrorDelay(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-delayer"), }) } func TestIronmqWorkerLimit(t *testing.T) { + t.Skip() + testWorkerLimit(t, ironmqFactory(), &taskq.QueueOptions{ Name: queueName("ironmq-worker-limit"), }) } func TestIronmqInvalidCredentials(t *testing.T) { + t.Skip() + settings := &iron_config.Settings{ ProjectId: "123", } diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100644 index 0000000..3ae2ac5 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -e + +help() { + cat <<- EOF +Usage: TAG=tag $0 + +Updates version in go.mod files and pushes a new brash to GitHub. + +VARIABLES: + TAG git tag, for example, v1.0.0 +EOF + exit 0 +} + +if [ -z "$TAG" ] +then + printf "TAG is required\n\n" + help +fi + +TAG_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" +if ! [[ "${TAG}" =~ ${TAG_REGEX} ]]; then + printf "TAG is not valid: ${TAG}\n\n" + exit 1 +fi + +TAG_FOUND=`git tag --list ${TAG}` +if [[ ${TAG_FOUND} = ${TAG} ]] ; then + printf "tag ${TAG} already exists\n\n" + exit 1 +fi + +if ! git diff --quiet +then + printf "working tree is not clean\n\n" + git status + exit 1 +fi + +git checkout master + +PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; \ + | sed 's/^\.\///' \ + | sort) + +for dir in $PACKAGE_DIRS +do + sed --in-place \ + "s/vmihailenco\/taskq\([^ ]*\) v.*/vmihailenco\/taskq\1 ${TAG}/" "${dir}/go.mod" +done + +for dir in $PACKAGE_DIRS +do + printf "${dir}: go get -d && go mod tidy\n" + (cd ./${dir} && go get -d && go mod tidy) +done + +sed --in-place "s/\(return \)\"[^\"]*\"/\1\"${TAG#v}\"/" ./version.go + +git checkout -b release/${TAG} master +git add -u +git commit -m "Release $TAG (release.sh)" +git push origin release/${TAG} diff --git a/scripts/tag.sh b/scripts/tag.sh new file mode 100644 index 0000000..121f00e --- /dev/null +++ b/scripts/tag.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +help() { + cat <<- EOF +Usage: TAG=tag $0 + +Creates git tags for public Go packages. + +VARIABLES: + TAG git tag, for example, v1.0.0 +EOF + exit 0 +} + +if [ -z "$TAG" ] +then + printf "TAG env var is required\n\n"; + help +fi + +if ! grep -Fq "\"${TAG#v}\"" version.go +then + printf "version.go does not contain ${TAG#v}\n" + exit 1 +fi + +PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; \ + | grep -E -v "example|internal" \ + | sed 's/^\.\///' \ + | sort) + +git tag ${TAG} +git push origin ${TAG} + +for dir in $PACKAGE_DIRS +do + printf "tagging ${dir}/${TAG}\n" + git tag ${dir}/${TAG} + git push origin ${dir}/${TAG} +done diff --git a/version.go b/version.go new file mode 100644 index 0000000..4f8024e --- /dev/null +++ b/version.go @@ -0,0 +1,6 @@ +package taskq + +// Version is the current release version. +func Version() string { + return "0.0.0" +}