Skip to content

Commit

Permalink
feat: Add routing key to event
Browse files Browse the repository at this point in the history
RoutingKey is an optional key that is used by the event bus to determining how/where to route the event.

Set the routing key to be the CSL URL for credential status update events.

Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
  • Loading branch information
bstasyszyn committed Oct 10, 2023
1 parent bf33da5 commit 9084f63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions component/credentialstatus/credentialstatus_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,15 @@ func (s *Service) createStatusUpdatedEvent(
return nil, fmt.Errorf("unable to marshal UpdateCredentialStatusEventPayload: %w", err)
}

return spi.NewEventWithPayload(
evt := spi.NewEventWithPayload(
uuid.NewString(),
credentialStatusEventSource,
spi.CredentialStatusStatusUpdated,
payload), nil
payload)

// Set the routing key to the CSL URL to give the event bus a hint
// on how/where to route the event.
evt.RoutingKey = cslURL

return evt, nil
}
3 changes: 3 additions & 0 deletions pkg/event/spi/spi.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ type Event struct {

// Tracing defines tracing information(optional).
Tracing string `json:"tracing,omitempty"`

// RoutingKey is an optional key that is used by the event bus to determining how/where to route the event.
RoutingKey string `json:"-"`
}

// Copy an event.
Expand Down

0 comments on commit 9084f63

Please sign in to comment.