feat(stovepipe): add commit ingestion abstractions#200
Conversation
|
|
|
|
||
| // PushEvent represents a git push to a branch detected from a webhook event. | ||
| // Fields are immutable after construction. | ||
| type PushEvent struct { |
There was a problem hiding this comment.
do we need to be git aware? @mnoah1
SQ currently is not git aware in general for most part, so my general thought here would be to keep that semantics similar and define abstractions that can allow us to work with git or some other vcs, specific impl could be left to the implementer to decide
There was a problem hiding this comment.
This case seems very close to SubmitQueue's ChangeInfo struct, so maybe we could leverage that:
- Internal extension subscribes to the events and translates them into a shape similar to
ChangeInfo- maybe even reuse the existing entity altogether. - Similarly to the
github.com://schema, add a rawgit://schema that identifies the path to the change on a git remote or other vcs - at this point, it doesn't matter which code review system was used, just where to find the change on remote. - Will work well as an identifier in the db like the existing change table - easy to provide two uri's and compare them.
@behinddwalls does this make sense?
There was a problem hiding this comment.
Yes, this seems fine. We can think about whether to re-use the Change entity...we might have to move it out of SQ domain and into the top level
64a6c14 to
9bbb8f9
Compare
| // Example: "git://github.com/uber/go-code/refs/heads/main/c3a4d5e6f789..." | ||
| // | ||
| // Fields are immutable after construction. | ||
| type CommitEvent struct { |
There was a problem hiding this comment.
Let's use the ChangeInfo naming from our earlier chat (and can use Change similarly throughout the PR where it says Commit currently).
|
|
||
| "github.com/uber/submitqueue/stovepipe/entity" | ||
| ) | ||
|
|
There was a problem hiding this comment.
Add a New() function to enforce interface compliance here (and you can accept the logger as a param)
| func (LoggingHandler) HandlePushEvent(ctx context.Context, event entity.PushEvent) error { | ||
| // Caller (the Kafka consumer in go-code) is responsible for actual logging. | ||
| // This stub is intentionally a no-op at the OSS layer. | ||
| return nil |
There was a problem hiding this comment.
Add an actual log line here - once we get this wired into the internal service we can deploy and confirm it emits real events.
|
|
||
| // CommitEventHandler processes a single commit event received from the ingester. | ||
| type CommitEventHandler interface { | ||
| HandleCommitEvent(ctx context.Context, event entity.CommitEvent) error |
There was a problem hiding this comment.
I think naming has diverged a bit here - we have HandleCommitEvent, HandlePushEvent. Let's go with something that mirrors our "Change" terminology - how about IngestChange
9bbb8f9 to
9bfce3e
Compare
| // URI is the canonical VCS identifier for this change. | ||
| // Scheme is "git://"; path encodes host, repo, ref, and new revision. | ||
| // This mirrors the ChangeInfo.URI pattern used in SubmitQueue. | ||
| URI string `json:"uri"` |
There was a problem hiding this comment.
a single push event can have multiple commits?
There was a problem hiding this comment.
@behinddwalls that is how I interpreted the ERD saying that batches of commits will be validated. @mnoah1 has this changed?
| // PreviousURI is the URI of the prior revision on the same ref, if known. | ||
| // Empty string if unavailable. | ||
| // Example: "git://github.com/uber/go-code/refs/heads/main/aabbccdd..." | ||
| PreviousURI string `json:"previous_uri,omitempty"` | ||
|
|
||
| // Author is the identity of the person who authored the change. | ||
| Author Author `json:"author"` |
There was a problem hiding this comment.
do we care about these? I am wondering if we can just promote the Change entity from submitqueue to the top and use the same here?
There was a problem hiding this comment.
@behinddwalls I am keep consistent with what I saw in submitqueue/entity. Otherwise, there's no strong reason to pull it out into its own type — it adds indirection without adding clarity.
4dda171 to
0239b4a
Compare
21bd79f to
eadd973
Compare
| // start topic. A trunk change is one commit, so the event carries one git-backed URI. It is | ||
| // source-agnostic: both the webhook and the reconciliation poller emit it. Additional fields | ||
| // (e.g. source, committer time) can be added later as ingestion needs them. | ||
| type ChangeEvent struct { |
There was a problem hiding this comment.
maybe we start from the proto for gateway what will be the shape of Request and Response for API, in general ChangeEvent is not needed as Change entity captures this already
eadd973 to
8b2ce3e
Compare
Introduce ChangeInfo, ChangeIngester/ChangeHandler, a no-op logging handler stub, and URI watch filtering for downstream ingestion.
Co-authored-by: Preetam Dwivedi <behinddwalls@gmail.com>
Add Commit and Batch as the core domain entities the validation pipeline operates on, each with status types and optimistic-locking Version fields. Add CommitStore and BatchStore extension interfaces scoped to their respective service owners (gateway and orchestrator). Fix missing BUILD.bazel files for the filter and changeingester packages. Flatten ChangeInfo.Author into AuthorName/AuthorEmail fields directly.
8b2ce3e to
95e8d29
Compare
Replace ChangeInfo with ChangeEvent as the ingestion payload type and introduce ChangeURI as the lightweight pipeline reference. Update Commit entity and create CommitStatusentity. Update ChangeHandler and the filter to accept ChangeEvent. Remove the storage extension and Batch entity, which belong to the orchestrator.
95e8d29 to
3e26387
Compare
Summary
entity.PushEventto represent a branch push (repo, branch, SHAs, pusher) for webhook/Kafka-driven ingestion.CommitIngesterandPushEventHandlerinstovepipe/extensionso a consumer can subscribe to push events and dispatch work.stovepipe/core/filterwithConfig/ShouldProcessto gate processing by watched repo and optional branch list (empty list = all branches for that repo).commitingester.LoggingHandleras a no-opPushEventHandlerstub until persistence/pipeline wiring lands.Test plan
make test(or targeted tests if added in a follow-up)make lintMade with Cursor