Skip to content
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

Behaviour specs #19

Open
srstrong opened this issue Jan 14, 2022 · 1 comment
Open

Behaviour specs #19

srstrong opened this issue Jan 14, 2022 · 1 comment

Comments

@srstrong
Copy link

I don't know if I'm reading this wrong, but it doesn't look to me like the generated callbacks in the behaviour modules have the correct type specifications. For example, for a unary call the behaviour says:

-callback unary(ctx:ctx(), my_pb:my_input()) ->
    {ok, my_pb:my_output(), ctx:ctx()} | grpcbox_stream:grpc_error_response().

where grpc_error_response is defined as:

-type grpc_error_response() :: {error, grpc_error(), #{headers => map(),
                                                       trailers => #{}}} |
                               {http_error, {http_status(), unicode:chardata()}, #{headers => map(),
                                                                                   trailers => #{}}} |
                               {error, term()}.

but the code in grpxbox_stream:handle_unary is doing:

    case [make the call] of
        {ok, Response, Ctx2} ->
            State1 = from_ctx(Ctx2),
            send(falsoe, Response, State1);
        E={grpc_error, _} ->
            throw(E);
        E={grpc_extended_error, _} ->
            throw(E)
    end.

when doesn't match a grpc_error_response. I'm using master for both grpcbox_plugin and grpcbox - should these two line up? If so, then I'm happy to do a PR to make the behaviours match the code

@tsloughter
Copy link
Owner

Thanks, you are right, something is wrong here, there was another issue with the error type specs fixed recently tsloughter/grpcbox#79 -- so seems I need to look at all of these :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants