Skip to content

CROSSLINK-252 Add option to broadcast all event states#522

Open
JanisSaldabols wants to merge 1 commit intomainfrom
CROSSLINK-252
Open

CROSSLINK-252 Add option to broadcast all event states#522
JanisSaldabols wants to merge 1 commit intomainfrom
CROSSLINK-252

Conversation

@JanisSaldabols
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 15, 2026 08:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an option to broadcast task state transitions (begin/complete) across all EventBus instances by persisting the event.broadcast flag during status transitions, and wiring new “broadcast” variants into task processing.

Changes:

  • Extend UpdateEventStatus SQL to also update the broadcast column.
  • Add BeginTaskBroadcast / CompleteTaskBroadcast / ProcessTaskBroadcast to the EventBus API and implement them in PostgresEventBus.
  • Switch ISO18626 client task processing for message tasks to use ProcessTaskBroadcast.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
broker/sqlc/event_query.sql Updates UpdateEventStatus to persist broadcast during status changes.
broker/events/eventbus.go Adds broadcast variants for begin/complete/process task flows and refactors shared logic.
broker/client/client.go Uses broadcast task processing for message-requester and message-supplier tasks.

func (c *Iso18626Client) MessageSupplier(ctx common.ExtendedContext, event events.Event) {
ctx = ctx.WithArgs(ctx.LoggerArgs().WithComponent(CLIENT_COMP))
_, _ = c.eventBus.ProcessTask(ctx, event, c.createAndSendRequestOrRequestingAgencyMessage)
_, _ = c.eventBus.ProcessTaskBroadcast(ctx, event, c.createAndSendRequestOrRequestingAgencyMessage)
}

func (p *PostgresEventBus) ProcessTaskBroadcast(ctx common.ExtendedContext, event Event, h func(common.ExtendedContext, Event) (EventStatus, *EventResult)) (Event, error) {
return p.processTask(ctx, event, h, p.BeginTaskBroadcast, p.CompleteTaskBroadcast)
Comment on lines +390 to +392
func (p *PostgresEventBus) ProcessTaskBroadcast(ctx common.ExtendedContext, event Event, h func(common.ExtendedContext, Event) (EventStatus, *EventResult)) (Event, error) {
return p.processTask(ctx, event, h, p.BeginTaskBroadcast, p.CompleteTaskBroadcast)
}
func (c *Iso18626Client) MessageRequester(ctx common.ExtendedContext, event events.Event) {
ctx = ctx.WithArgs(ctx.LoggerArgs().WithComponent(CLIENT_COMP))
_, _ = c.eventBus.ProcessTask(ctx, event, c.createAndSendSupplyingAgencyMessage)
_, _ = c.eventBus.ProcessTaskBroadcast(ctx, event, c.createAndSendSupplyingAgencyMessage)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JanisSaldabols we need to test this somehow

@@ -75,7 +75,7 @@ DELETE FROM event
WHERE ill_transaction_id = $1;

-- name: UpdateEventStatus :one
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this to something like UpdateEventLifecycle

func (p *PostgresEventBus) processTask(ctx common.ExtendedContext, event Event, h func(common.ExtendedContext, Event) (EventStatus, *EventResult), b func(eventId string) (Event, error), c func(eventId string, result *EventResult, status EventStatus) (Event, error)) (Event, error) {
inEvent := &event
event, err := p.BeginTask(event.ID)
event, err := b(event.ID)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we call these handlers something more readable like begin and complete?

@jakub-id
Copy link
Copy Markdown
Contributor

@JanisSaldabols I am not sure this is gonna work as-is. Workflow OnRequester/SupplierMessage handler already broadcast the confirmation task so we will have a double broadcast. If we wanna do it this way we would need to get rid of the confirmation task and confirm directly in these handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants