Adding Cloud Events support to EventStore

The original implementation was in !228912 (diffs). This MR is extracted from there with feedback addressed

Addressing the issue: #593564 (closed)

Add Cloud Events support to existing EventStore

Description

This MR adds support for new type of EventStore events that adhere to the CloudEvents specs. We are testing that with the Merge Requests Assigned Reviewers event, which already has a AI Flow Trigger. So that we can later connect this cloud event with the AI Flow Triggers using this event instead.

Validate locally

  • Assigning new reviewers on MRs should work without any errors.

  • Via Rails Console

MergeRequests::AssignedReviewersEvent.build(current_user: User.first, merge_request: MergeRequest.first, new_reviewers: User.all.sample(2)).data

Should return

{"specversion"=>"1.0",
 "type"=>"com.gitlab.merge_requests.assigned_reviewers",
 "dataschema"=>"https://gitlab.com/schemas/merge_requests/assigned_reviewers/v1.0",
 "id"=>"ae2dc888-5602-4987-bfb5-a7143d4e30b9",
 "datacontenttype"=>"application/json",
 "time"=>"2026-05-06T12:32:36Z",
 "source"=>"projects/1",
 "subject"=>"merge_requests/1",
 "gitlab_user_id"=>1,
 "gitlab_user_username"=>"root",
 "gitlab_organization_id"=>1,
 "data"=>{"merge_request_id"=>1, "merge_request_iid"=>1, "project_id"=>1, "new_reviewer_ids"=>[1, 69], "new_reviewer_user_types"=>["human", "service_account"]}}

Outside the scope of this MR

  • Documentation to be added as part of #597603 as a followup
  • We are not adding a new consumer workers yet. Because this is done in separate issues that implement the flow triggers. See here (gitlab-org#20465)
  • We are not publishing events to Relay. This will be done only for the events that need to be consumed outside of Rails. See here: gitlab-org#21346
  • We are not migrating existing events to CloudEvent. This is to be done after adding documentation and then #598979

Follow up issues

  • Adding documentation #597603
  • (High priority) Implement Merge Requests Code Conflict using a Cloud Event #592455

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Omar Qunsul

Merge request reports

Loading