-
Notifications
You must be signed in to change notification settings - Fork 11
feat(stovepipe): request history api - entities/mappers #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,10 +83,6 @@ message HistoryEvent { | |
| // Event that occurred without changing the request state. | ||
| string event = 4; | ||
| } | ||
| // Newer request that caused a superseded state. Empty when not applicable. | ||
| string superseded_by_request_id = 5; | ||
| // Build associated with the occurrence. Empty when no build applies. | ||
| string build_id = 6; | ||
| // Stable domain reason for a terminal request outcome. Empty otherwise. | ||
| string outcome_reason = 7; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either change this ordinal to 5 (which will make it a breaking change) or reserve 5 and 6 |
||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) 2025 Uber Technologies, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package mapper | ||
|
|
||
| import ( | ||
| pb "github.com/uber/submitqueue/api/stovepipe/protopb" | ||
| "github.com/uber/submitqueue/stovepipe/entity" | ||
| ) | ||
|
|
||
| // ProtoToGetRequestHistoryByIDRequest maps a wire request to its domain value. | ||
| func ProtoToGetRequestHistoryByIDRequest(req *pb.GetRequestHistoryByIDRequest) entity.GetRequestHistoryByIDRequest { | ||
| return entity.GetRequestHistoryByIDRequest{ID: req.GetRequestId(), Queue: req.GetQueue()} | ||
| } | ||
|
|
||
| // ProtoToGetRequestHistoryByURIRequest maps a wire request to its domain value. | ||
| func ProtoToGetRequestHistoryByURIRequest(req *pb.GetRequestHistoryByURIRequest) entity.GetRequestHistoryByURIRequest { | ||
| return entity.GetRequestHistoryByURIRequest{URI: req.GetUri(), Queue: req.GetQueue()} | ||
| } | ||
|
|
||
| // HistoryEventsToProto maps retained request-log events to wire history events. | ||
| func HistoryEventsToProto(logs []entity.RequestLog) []*pb.HistoryEvent { | ||
| events := make([]*pb.HistoryEvent, len(logs)) | ||
| for i, log := range logs { | ||
| event := &pb.HistoryEvent{ | ||
| EventId: log.ID, | ||
| TimestampMs: log.TimestampMs, | ||
| OutcomeReason: string(log.OutcomeReason), | ||
| } | ||
| if log.State != entity.RequestStateUnknown { | ||
| event.Occurrence = &pb.HistoryEvent_RequestState{RequestState: string(log.State)} | ||
| } else { | ||
| event.Occurrence = &pb.HistoryEvent_Event{Event: string(log.Event)} | ||
| } | ||
| events[i] = event | ||
| } | ||
| return events | ||
| } | ||
|
|
||
| // RequestHistoriesToProto maps grouped retained histories to their wire representation. | ||
| func RequestHistoriesToProto(histories []entity.RequestHistory) []*pb.RequestHistory { | ||
| result := make([]*pb.RequestHistory, len(histories)) | ||
| for i, history := range histories { | ||
| result[i] = &pb.RequestHistory{ | ||
| RequestId: history.RequestID, | ||
| Events: HistoryEventsToProto(history.Events), | ||
| } | ||
| } | ||
| return result | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These haven't been used yet so deleting them here in backwards incompatible way. They're already unused elsewhere in the code/db schema.