Skip to content

Commit

Permalink
Update grpc completepromise
Browse files Browse the repository at this point in the history
  • Loading branch information
dfarr committed Sep 19, 2023
1 parent 1ad9f62 commit 2c7daa9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/app/subsystems/api/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,18 @@ func (s *server) CompletePromise(ctx context.Context, req *grpcApi.CompletePromi
cq := make(chan *bus.CQE[types.Request, types.Response])
defer close(cq)

var state promise.State
switch req.State {
case grpcApi.State_RESOLVED:
state = promise.Resolved
case grpcApi.State_REJECTED:
state = promise.Rejected
case grpcApi.State_REJECTED_CANCELED:
state = promise.Canceled
default:
return nil, grpcStatus.Error(codes.InvalidArgument, "state must be one of resolved, rejected, or canceled")
}

var headers map[string]string
if req.Value != nil && req.Value.Headers != nil {
headers = req.Value.Headers
Expand Down Expand Up @@ -391,7 +403,7 @@ func (s *server) CompletePromise(ctx context.Context, req *grpcApi.CompletePromi
Ikey: ikey,
Data: data,
},
State: promise.State(req.State),
State: state,
},
},
Callback: s.sendOrPanic(cq),
Expand Down

0 comments on commit 2c7daa9

Please sign in to comment.