GRPC.Client.Adapter behaviour (gRPC v0.11.5)

View Source

HTTP client adapter for GRPC.

Summary

Types

Determines if the headers have finished being read.

Callbacks

Cancel a stream in a streaming client.

Similarly to the option sent on send_data/2 - :send_end_stream - this callback will end request stream

Check GRPC.Stub.recv/2 for more context about the return types

This callback will be responsible to send data to the server on a stream request is open using send_headers/2 Opts

This callback is used to open a stream connection to the server. Mostly used when the payload for this request is streamed. To send data using the open stream request, you should use send_data/3

Types

fin()

@type fin() :: :fin | :nofin

Determines if the headers have finished being read.

Callbacks

cancel(stream)

@callback cancel(stream :: GRPC.Client.Stream.t()) :: :ok | {:error, any()}

Cancel a stream in a streaming client.

connect(channel, opts)

@callback connect(channel :: GRPC.Channel.t(), opts :: keyword()) ::
  {:ok, GRPC.Channel.t()} | {:error, any()}

disconnect(channel)

@callback disconnect(channel :: GRPC.Channel.t()) ::
  {:ok, GRPC.Channel.t()} | {:error, any()}

end_stream(stream)

@callback end_stream(stream :: GRPC.Client.Stream.t()) :: GRPC.Client.Stream.t()

Similarly to the option sent on send_data/2 - :send_end_stream - this callback will end request stream

receive_data(stream, opts)

@callback receive_data(stream :: GRPC.Client.Stream.t(), opts :: keyword()) ::
  GRPC.Stub.receive_data_return() | {:error, any()}

Check GRPC.Stub.recv/2 for more context about the return types

send_data(stream, message, opts)

@callback send_data(
  stream :: GRPC.Client.Stream.t(),
  message :: iodata(),
  opts :: keyword()
) ::
  GRPC.Client.Stream.t()

This callback will be responsible to send data to the server on a stream request is open using send_headers/2 Opts:

- :send_end_stream (optional) - ends the request stream

send_headers(stream, opts)

@callback send_headers(stream :: GRPC.Client.Stream.t(), opts :: keyword()) ::
  GRPC.Client.Stream.t()

This callback is used to open a stream connection to the server. Mostly used when the payload for this request is streamed. To send data using the open stream request, you should use send_data/3

send_request(stream, contents, opts)

@callback send_request(
  stream :: GRPC.Client.Stream.t(),
  contents :: iodata(),
  opts :: keyword()
) ::
  GRPC.Client.Stream.t()