Skip to content

Commit 0f43814

Browse files
author
Guy Baron
authored
allow getting the saga id of the current invoked saga (#168)
1 parent 80161c6 commit 0f43814

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

gbus/abstractions.go

+3
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ type SagaInvocation interface {
241241
ReplyToInitiator(ctx context.Context, message *BusMessage) error
242242
//HostingSvc returns the svc name that is executing the service
243243
HostingSvc() string
244+
245+
//SagaID returns the saga id of the currently invoked saga instance
246+
SagaID() string
244247
}
245248

246249
//Serializer is the base interface for all message serializers

gbus/messages.go

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ func (bm *BusMessage) SetPayload(payload Message) {
8181
bm.Payload = payload
8282
}
8383

84+
//TargetSaga allows sending the message to a specific Saga instance
85+
func (bm *BusMessage) TargetSaga(sagaID string) {
86+
bm.SagaID = sagaID
87+
}
88+
8489
//GetTraceLog returns an array of log entires containing all of the message properties
8590
func (bm *BusMessage) GetTraceLog() (fields []log.Field) {
8691
return []log.Field{

gbus/saga/invocation.go

+4
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,7 @@ func (si *sagaInvocation) Routing() (exchange, routingKey string) {
115115
func (si *sagaInvocation) DeliveryInfo() gbus.DeliveryInfo {
116116
return si.decoratedInvocation.DeliveryInfo()
117117
}
118+
119+
func (si *sagaInvocation) SagaID() string {
120+
return si.sagaID
121+
}

0 commit comments

Comments
 (0)