Skip to content

Commit

Permalink
chore: add serve response type (#180)
Browse files Browse the repository at this point in the history
Signed-off-by: Yashash H L <[email protected]>
  • Loading branch information
yhl25 authored Feb 24, 2025
1 parent ea9640b commit 4b9eb5b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
33 changes: 19 additions & 14 deletions pkg/apis/proto/sink/v1/sink.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/proto/sink/v1/sink.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum Status {
SUCCESS = 0;
FAILURE = 1;
FALLBACK = 2;
SERVE = 3;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions pkg/sinker/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ func (fs *Service) processData(ctx context.Context, stream sinkpb.Sink_SinkFnSer
Status: sinkpb.Status_SUCCESS,
ServeResponse: msg.ServeResponse,
})
} else if msg.Serve {
resultList = append(resultList, &sinkpb.SinkResponse_Result{
Id: msg.ID,
Status: sinkpb.Status_SERVE,
ServeResponse: msg.ServeResponse,
})
} else {
resultList = append(resultList, &sinkpb.SinkResponse_Result{
Id: msg.ID,
Expand Down
7 changes: 5 additions & 2 deletions pkg/sinker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ type Response struct {
// Err represents the error message when "success" is false.
Err string `json:"err,omitempty"`
// Fallback is true if the message to be sent to the fallback sink.
Fallback bool `json:"fallback,omitempty"`
Fallback bool `json:"fallback,omitempty"`
// Serve is true if the message to be sent to serving store.
Serve bool `json:"serve,omitempty"`
// ServeResponse is the response that will be sent to the serving store.
ServeResponse []byte `json:"serve_reponse,omitempty"`
}

Expand Down Expand Up @@ -50,5 +53,5 @@ func ResponseFallback(id string) Response {
}

func ResponseServe(id string, result []byte) Response {
return Response{ID: id, Success: true, ServeResponse: result}
return Response{ID: id, Serve: true, ServeResponse: result}
}

0 comments on commit 4b9eb5b

Please sign in to comment.