Skip to content

Commit

Permalink
Small QOL improvmeent - allow returning values from streaming handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
wokalski committed Apr 17, 2024
1 parent 1a0e2be commit 9313451
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/eio/client/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let bidirectional_streaming (type headers response conn_error) ~sw
}
in

let () =
let res =
f ~writer ~take:(fun () ->
match Eio.Stream.take reader with
| None -> None
Expand All @@ -85,7 +85,7 @@ let bidirectional_streaming (type headers response conn_error) ~sw
| None -> (
let status = Eio.Promise.await grpc_status in
match Grpc.Status.code status with
| Grpc.Status.OK -> Ok ()
| Grpc.Status.OK -> Ok res
| _ -> Error (`Rpc (response, status))))
else Error (`Rpc (response, Eio.Promise.await grpc_status))
| Error e -> Error (`Connection e))
Expand Down
4 changes: 2 additions & 2 deletions lib/eio/client/client.mli
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ val bidirectional_streaming :
decode:(string -> ('response, 'decoding_error) result) ->
encode:('request -> string) ->
headers:Grpc_client.request_headers ->
(writer:'request writer -> take:(unit -> 'response option) -> unit) ->
(unit, 'decoding_error, 'conn_error, 'net_response) rpc_result
(writer:'request writer -> take:(unit -> 'response option) -> 'a) ->
('a, 'decoding_error, 'conn_error, 'net_response) rpc_result

0 comments on commit 9313451

Please sign in to comment.