diff --git a/gbus/abstractions.go b/gbus/abstractions.go index c449961..1aa3ffc 100644 --- a/gbus/abstractions.go +++ b/gbus/abstractions.go @@ -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 diff --git a/gbus/messages.go b/gbus/messages.go index 6c78c60..a436cd0 100644 --- a/gbus/messages.go +++ b/gbus/messages.go @@ -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{ diff --git a/gbus/saga/invocation.go b/gbus/saga/invocation.go index ffd29d8..2bb7967 100644 --- a/gbus/saga/invocation.go +++ b/gbus/saga/invocation.go @@ -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 +}