Skip to content

Conversation

@EricGusmao
Copy link

Motivation / Background

Google Cloud Pub Sub client supports batch messaging, but the previous Watermill Publish implementation was synchronous. By publishing messages serially and waiting for acknowledgement each time. This PR tries to be as backwards compatible as possible

Details

The process is split into three phases:

Preparation: Marshals all messages. Validates messages before network requests, aborting early on failure.

Dispatch (Async): Calls topic.Publish() for each message without waiting. This allows the client to fill internal buffers and trigger batch uploads based on configured settings.

Collection (Sync): Waits for acknowledgements using .Get(ctx), updates metadata with server IDs, and accumulates errors instead of failing fast. Preserves ordering key resumption logic.

Alternative approaches considered (if applicable)

An errgroup could be used instead.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant