You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* inceased outbox VARCHAR column length to 2048 (#155)
* added reply to initiator functionality to sagas (#157)
* added generic handler metrics with message type as the label (#144)
* added generic handler metrics with message type as the label
* add handler name label to the metrics
* adding new metrics to the read me
* Fix handle empty body (#156)
* set the correct Type and Content-Type headers on out going messages (#160)
* set the correct Type and Content-Type headers on out going messages
* refactoring
* fixing ReplyToInitiator not working when initiator sends a message via the RPC interface (#163)
* fixing ReplyToInitiator not working when initiator sends a message via the RPC interface
* Improved wording of saga documentation article (#164)
* better wording for documentation
* added golangcli lint configuration and fixed linting failures (#165)
* fixed logging issues (#167)
* allow getting the saga id of the current invoked saga (#168)
* setting the target saga id on the saga correlation id field (#171)
* support emperror (#174)
* setting the target saga id on the saga correlation id field
* added emperror support
* Fix logging and added logging documentation (#176)
* fixed logging issues and added documentation
logging via the invocation interface was broken and did not add
contextual data related to the invocation due to a bug in the way the Glogged structure is currently implemented.
Also added documentation on how logging should be done within a
handler including adding context to returned errors so that data gets logged
* added missing documentation file
* added documentation on serialization support (#177)
* fixed emperror url format
* added serialization documentation
grabbit makes it easier handling these cases and reduce the repetitive task of logging
53
+
these custom contextual attributes in cases of errors by integrating the [emperror errors package](https://github.com/emperror/errors).
54
+
emperror drop-in replacement for the default errors package allows developers to add the needed contextual data on the error instance and have graabit log the error with all contextual attribute.
Copy file name to clipboardExpand all lines: docs/SAGA.md
+55-3Lines changed: 55 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ type BookVacationSaga struct {
22
22
BookingIdstring
23
23
GotCarSvcResponsebool
24
24
GotHotelSvcResponsebool
25
+
SomeConfigDatastring
25
26
}
26
27
```
27
28
@@ -171,7 +172,7 @@ func (s *BookVacationSaga) HandleBookFlightResponse(invocation gbus.Invocation,
171
172
172
173
}
173
174
```
174
-
### Step 4 - Handling the timeout requirement
175
+
### Step 4 - Handling the timeout requirement
175
176
176
177
In order to define a timeout for the saga and have grabbit call the saga instance once that timeout is reached (assuming the saga hasn't completed yet) the saga needs to implement the gbus.RequestSagaTimeout interface
177
178
@@ -191,7 +192,7 @@ func (s *BookVacationSaga) TimeoutDuration() time.Duration {
@@ -218,3 +219,54 @@ It is recommended to follow [semantic versioning](https://semver.org/) of the go
218
219
219
220
grabbit automatically implements an optimistic concurrency model when processing a message and persisting saga instances, detecting when the saga state turns stale due to processing concurrently a different message.
220
221
When the above is detected grabbit will rollback the bounded transaction and retry the execution of the saga.
222
+
223
+
### Configuring a Saga Instance
224
+
225
+
It is sometimes necessary to configure a saga instance with some data before it gets executed.
226
+
grrabit allows you to do so by providing a saga configuration function when registering the saga.
227
+
Each time a saga instance gets created or inflated from the persistent store the configuration function will be executed.
228
+
229
+
The saga configuration function accepts a single gbus.Saga parameter and returns a single gbus.Saga return value.
230
+
The passed in gbus.Saga is the instance that will be executed and will be the type of the saga being registered meaning it can safely be casted to your specific saga type.
231
+
Once you casted to the specific saga type you can configure the instance and access its fields as needed.
232
+
After the instance is configured the function returns the configured saga instance so grabbit can proceed and execute it.
233
+
234
+
The following snippet is an example of how to pass in a saga configuration function
It is common that during its life cycle a saga will need to report back and send messages with the service that initiated it (sent the command that started the saga).
248
+
In the example above when the booking has completed we would like to send a message to the service which initiated the booking saga.
249
+
The way we have implemented this in the example above is by publishing an event which the service which initiated the saga would need to subscribe to and handle to get notified when the booking is complete.
250
+
251
+
Although the above would work it won't be an elegant solution especially if the initiator of the saga is another saga since it means that the initiating saga will need to filter all events and select the single event that correlates to that particular instance.
252
+
To relive client code to do so grabbit provides a way for a saga to directly send a message to its initiator, and if the initiator is another saga grabbit will automatically correlate the message with the correct saga instance and invoke the relevant handler.
253
+
254
+
To send a message to the saga initiator the message handler attached to the saga instance will need to cast the passed in gbus.Invocation argument to a gbus.SagaInvocation and then invoke the ReplyToInitiator function.
255
+
We can replace the following code from the above example
grabbit supports out of the box three serializers to format messages over the wire
4
+
5
+
- gob (defualt)
6
+
- protobuf
7
+
- avro (experimental)
8
+
9
+
To configure a bus to work with a different serializer than the default one you must call the WithSerializer function call on the builder interface passing it an instance of a gbus.Serializer.
10
+
11
+
The following example configures the bus to work with the protobuf serializer
0 commit comments