Skip to content

Commit

Permalink
allow getting the saga id of the current invoked saga (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Baron authored Sep 25, 2019
1 parent 80161c6 commit 0f43814
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gbus/abstractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ type SagaInvocation interface {
ReplyToInitiator(ctx context.Context, message *BusMessage) error
//HostingSvc returns the svc name that is executing the service
HostingSvc() string

//SagaID returns the saga id of the currently invoked saga instance
SagaID() string
}

//Serializer is the base interface for all message serializers
Expand Down
5 changes: 5 additions & 0 deletions gbus/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (bm *BusMessage) SetPayload(payload Message) {
bm.Payload = payload
}

//TargetSaga allows sending the message to a specific Saga instance
func (bm *BusMessage) TargetSaga(sagaID string) {
bm.SagaID = sagaID
}

//GetTraceLog returns an array of log entires containing all of the message properties
func (bm *BusMessage) GetTraceLog() (fields []log.Field) {
return []log.Field{
Expand Down
4 changes: 4 additions & 0 deletions gbus/saga/invocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,7 @@ func (si *sagaInvocation) Routing() (exchange, routingKey string) {
func (si *sagaInvocation) DeliveryInfo() gbus.DeliveryInfo {
return si.decoratedInvocation.DeliveryInfo()
}

func (si *sagaInvocation) SagaID() string {
return si.sagaID
}

0 comments on commit 0f43814

Please sign in to comment.