Skip to content

Commit

Permalink
Add more docs on requeue
Browse files Browse the repository at this point in the history
  • Loading branch information
m110 committed Oct 25, 2024
1 parent 545295b commit 18e2699
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 15 deletions.
4 changes: 2 additions & 2 deletions _examples/real-world-examples/delayed-messages/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module delayed-messsages
go 1.23.0

require (
github.com/ThreeDotsLabs/watermill v1.4.0-rc.1.0.20241024100330-cb068b72e948
github.com/ThreeDotsLabs/watermill v1.4.0-rc.2
github.com/ThreeDotsLabs/watermill-redisstream v1.4.2
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024102321-584a6f7dab93
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-rc.1
github.com/brianvoe/gofakeit/v6 v6.28.0
github.com/google/uuid v1.6.0
github.com/lib/pq v1.10.2
Expand Down
3 changes: 3 additions & 0 deletions _examples/real-world-examples/delayed-messages/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc=
github.com/Rican7/retry v0.3.1/go.mod h1:CxSDrhAyXmTMeEuRAnArMu1FHu48vtfjLREWqVl7Vw0=
github.com/ThreeDotsLabs/watermill v1.4.0-rc.1.0.20241024100330-cb068b72e948 h1:b8qRHpWtlO94x6dVzSulrO2znSQqz8iYsxUyrdTixHo=
github.com/ThreeDotsLabs/watermill v1.4.0-rc.1.0.20241024100330-cb068b72e948/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to=
github.com/ThreeDotsLabs/watermill v1.4.0-rc.2/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to=
github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 h1:FY6tsBcbhbJpKDOssU4bfybstqY0hQHwiZmVq9qyILQ=
github.com/ThreeDotsLabs/watermill-redisstream v1.4.2/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024101952-75257d7d0602 h1:CKdW3wb3+C36mMa44DF53KUyM5L6mGOjI3hikBOlAl4=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024101952-75257d7d0602/go.mod h1:GMWcpauehgI40EeoKPxLnXBWjT7oOm7dJfzk5uU4IOc=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024102321-584a6f7dab93 h1:KeRk2EG5AtdxfpjqIVPigZqscMvIcy0E2h8k7y38OAE=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024102321-584a6f7dab93/go.mod h1:GMWcpauehgI40EeoKPxLnXBWjT7oOm7dJfzk5uU4IOc=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-rc.1 h1:uYfnh1EoqXrzHu+bX/TboRyv4ou+EFcmkC1MABeQ0lI=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-rc.1/go.mod h1:ttA/lhzSh0YyDkosq1Cgc7IYz6Arrba0jIWfdnON0WA=
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
Expand Down
4 changes: 2 additions & 2 deletions _examples/real-world-examples/delayed-requeue/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module delayed-requeue
go 1.23.0

require (
github.com/ThreeDotsLabs/watermill v1.4.0-rc.1.0.20241024100330-cb068b72e948
github.com/ThreeDotsLabs/watermill v1.4.0-rc.2
github.com/ThreeDotsLabs/watermill-redisstream v1.4.2
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024102321-584a6f7dab93
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-rc.1
github.com/brianvoe/gofakeit/v6 v6.28.0
github.com/lib/pq v1.10.9
github.com/redis/go-redis/v9 v9.7.0
Expand Down
3 changes: 3 additions & 0 deletions _examples/real-world-examples/delayed-requeue/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc=
github.com/Rican7/retry v0.3.1/go.mod h1:CxSDrhAyXmTMeEuRAnArMu1FHu48vtfjLREWqVl7Vw0=
github.com/ThreeDotsLabs/watermill v1.4.0-rc.1.0.20241024100330-cb068b72e948 h1:b8qRHpWtlO94x6dVzSulrO2znSQqz8iYsxUyrdTixHo=
github.com/ThreeDotsLabs/watermill v1.4.0-rc.1.0.20241024100330-cb068b72e948/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to=
github.com/ThreeDotsLabs/watermill v1.4.0-rc.2/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to=
github.com/ThreeDotsLabs/watermill-redisstream v1.4.2 h1:FY6tsBcbhbJpKDOssU4bfybstqY0hQHwiZmVq9qyILQ=
github.com/ThreeDotsLabs/watermill-redisstream v1.4.2/go.mod h1:69++855LyB+ckYDe60PiJLBcUrpckfDE2WwyzuVJRCk=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024101952-75257d7d0602 h1:CKdW3wb3+C36mMa44DF53KUyM5L6mGOjI3hikBOlAl4=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024101952-75257d7d0602/go.mod h1:GMWcpauehgI40EeoKPxLnXBWjT7oOm7dJfzk5uU4IOc=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024102321-584a6f7dab93 h1:KeRk2EG5AtdxfpjqIVPigZqscMvIcy0E2h8k7y38OAE=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-20241024102321-584a6f7dab93/go.mod h1:GMWcpauehgI40EeoKPxLnXBWjT7oOm7dJfzk5uU4IOc=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-rc.1 h1:uYfnh1EoqXrzHu+bX/TboRyv4ou+EFcmkC1MABeQ0lI=
github.com/ThreeDotsLabs/watermill-sql/v4 v4.0.0-rc.1/go.mod h1:ttA/lhzSh0YyDkosq1Cgc7IYz6Arrba0jIWfdnON0WA=
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
Expand Down
10 changes: 10 additions & 0 deletions docs/content/advanced/requeuing-after-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
+++
title = "Requeuing After Error"
description = "How to requeue a message after it fails to process"
weight = -20
draft = false
bref = "How to requeue a message after it fails to process"
+++



1 change: 0 additions & 1 deletion docs/content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ if err != nil {
}
```


{{< tabs "publishing" >}}

{{< tab "Go Channel" "go-channel" >}}
Expand Down
35 changes: 27 additions & 8 deletions docs/content/pubsubs/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ go get github.com/ThreeDotsLabs/watermill-sql/v3

### Characteristics

| Feature | Implements | Note |
|---------------------|------------|-------------------------------------------|
| ConsumerGroups | yes | See `ConsumerGroup` in `SubscriberConfig` |
| ExactlyOnceDelivery | yes* | Just for MySQL implementation |
| GuaranteedOrder | yes | |
| Persistent | yes | |
| Feature | Implements | Note |
|---------------------|------------|-------------------------------------------------------------------------------|
| ConsumerGroups | yes | See `ConsumerGroup` in `SubscriberConfig` (not supported by the queue schema) |
| ExactlyOnceDelivery | yes* | Just for MySQL implementation |
| GuaranteedOrder | yes | |
| Persistent | yes | |

### Schema

Expand Down Expand Up @@ -83,7 +83,7 @@ constructor. You have to create one publisher for each transaction.
Example:
{{% load-snippet-partial file="src-link/_examples/real-world-examples/transactional-events/main.go" first_line_contains="func simulateEvents" last_line_contains="return pub.Publish(" padding_after="3" %}}

### Subscribing
## Subscribing

To create a subscriber, you need to pass not only proper schema adapter, but also an offsets adapter.

Expand All @@ -97,9 +97,28 @@ Example:

{{% load-snippet-partial file="src-link/watermill-sql/pkg/sql/subscriber.go" first_line_contains="func (s *Subscriber) Subscribe" last_line_contains="func (s *Subscriber) Subscribe" %}}

### Offsets Adapter
## Offsets Adapter

The logic for storing offsets of messages is provided by the `OffsetsAdapter`. If your schema uses auto-incremented integer as the row ID,
it should work out of the box with default offset adapters.

{{% load-snippet-partial file="src-link/watermill-sql/pkg/sql/offsets_adapter.go" first_line_contains="type OffsetsAdapter" %}}


## Queue

Instead of the default Pub/Sub schema, you can use the queue schema and offsets adapters.

It's a simpler version of schema that doesn't support consumer groups.
However, it has other advantages.
It lets you specify a custom `WHERE` clause for getting the messages.
You can use it to filter messages by some condition in the payload or in the metadata.

Additionally, you can choose to delete messages from the table after they are acknowledged.
Thanks to this, the table doesn't grow in size of time.

Currently, this schema is supported only for PostgreSQL.

{{% load-snippet-partial file="src-link/watermill-sql/pkg/sql/queue_schema_adapter_postgresql.go" first_line_contains="// PostgreSQLQueueSchema" last_line_contains="}" %}}

{{% load-snippet-partial file="src-link/watermill-sql/pkg/sql/queue_offsets_adapter_postgresql.go" first_line_contains="// PostgreSQLQueueOffsetsAdapter" last_line_contains="}" %}}
1 change: 1 addition & 0 deletions docs/hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
"publishing-multiple-messages",
"pubsubs",
"query",
"queue",
"randomfail",
"receiving-acknack",
"recoverer",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Target":"main.e18d306ea87fc31ccdc18bc02f9617933c7a3056a2ba2de6830a8ba47283543cbbd494e24b7d778b41d54d3074f438879353bddabcc0bd0d0389eb3d84f0aa38.css","MediaType":"text/css","Data":{"Integrity":"sha512-4Y0wbqh/wxzNwYvAL5YXkzx6MFaiui3mgwqLpHKDVDy71JTiS313i0HVTTB09DiHk1O92rzAvQ0Dies9hPCqOA=="}}
{"Target":"main.3e9cfa18ef8eea818e5322c5eccce2bcedbda0100f6cc0469a0d0d315f86d01a5e46c2424f782e7e0c2e12da5c5afc98309d50b5aa60f98949293da86193c731.css","MediaType":"text/css","Data":{"Integrity":"sha512-Ppz6GO+O6oGOUyLF7MzivO29oBAPbMBGmg0NMV+G0BpeRsJCT3gufgwuEtpcWvyYMJ1Qtapg+YlJKT2oYZPHMQ=="}}

0 comments on commit 18e2699

Please sign in to comment.