-
Notifications
You must be signed in to change notification settings - Fork 38
gRPC reference documentation
This is the interface for grpc.
This is the interface for grpc.
This module contains the functions to start and stop an Erlang gRPC server, as well as the functions that can be used by the programmer who implements the services that are provided by that server.
See the Readme in the root folder of the repository for a more general (tutorial-style) introduction.
compression_method() = none | gzip
error_code() = integer()
error_message() = binary()
error_response() = {error, error_code(), error_message(), stream()}
handler_state() = any()
This term is passed to the handler module. It will show up as the value of the 'State' parameter that is passed to the first invocation (per stream) of the generated RPC skeleton functions. The default value is undefined. See the implementation of 'RecordRoute' in the tutorial for an example.
metadata() = #{metadata_key() => metadata_value()}
metadata_key() = binary()
metadata_value() = binary()
option() = {transport_options, [ranch_ssl:ssl_opt()]} | {num_acceptors, integer()} | {handler_state, handler_state()}
abstract datatype: stream()
authority/1 | Get the value for the :authority header. |
compile/1 | Equivalent to compile(FileName, []). |
compile/2 | Compile a .proto file to generate server side skeleton code and a module to encode and decode the protobuf messages. |
metadata/1 | Get the metadata that was sent by the client. |
method/1 | Get the value for the :method header. |
path/1 | Get the value for the :path header. |
scheme/1 | Get the value for the :scheme header. |
send/2 | Send one or more messages from the server to the client. |
send_headers/1 | |
send_headers/2 | |
set_compression/2 | Enable compression of response messages. |
set_headers/2 | Set metadata to be sent in headers. |
set_trailers/2 | Set metadata to be sent in trailers. |
start_server/4 | Equivalent to start_server(Name, Transport, Port, Handler, []). |
start_server/5 | Start a gRPC server. |
stop_server/1 | Stop a gRPC server. |
authority(Stream::stream()) -> binary()
Get the value for the :authority header.
compile(FileName::string()) -> ok
Equivalent to compile(FileName, []).
compile(FileName::string(), Options::gbp_compile:opts()) -> ok
Compile a .proto file to generate server side skeleton code and a module to encode and decode the protobuf messages.
Refer to gbp for the options. gRPC will always use the options 'maps' (so that the protobuf messages are translated to and from maps) and the option '{i, "."}' (so that .proto files in the current working directory will be found).
metadata(Stream::stream()) -> metadata()
Get the metadata that was sent by the client.
Note that this will in fact provide all the headers (so not just the metadata), except for :method, :authority, :scheme and :path (there are separate functions to get access to those). But if there is for example a grpc-timeout header this will also be returned as metadata.
method(Stream::stream()) -> binary()
Get the value for the :method header.
path(Stream::stream()) -> binary()
Get the value for the :path header.
scheme(Stream::stream()) -> binary()
Get the value for the :scheme header.
Send one or more messages from the server to the client.
This function can be used in the service implementation to send one or more messages to the client via a stream.
send_headers(Stream::stream(), Headers::metadata()) -> stream()
set_compression(Stream::stream(), Method::compression_method()) -> stream()
Enable compression of response messages. Currently only gzip or none (no compression, the default) are supported.
set_headers(Stream::stream(), Headers::metadata()) -> stream()
Set metadata to be sent in headers. Fails if headers have already been sent.
This function can be used in the service implementation to add metadata to a stream. The metadata will be sent to the client (as HTTP/2 headers) before the response message(s) is/are sent.
set_trailers(Stream::stream(), Trailers::metadata()) -> stream()
Set metadata to be sent in trailers.
This function can be used in the service implementation to add metadata to a stream. The metadata will be sent to the client (as HTTP/2 end headers) after the response message(s) has/have been sent.
start_server(Name::term(), Transport::ssl | tcp, Port::integer(), Handler::module()) -> {ok, CowboyListenerPid::pid()} | {error, any()}
Equivalent to start_server(Name, Transport, Port, Handler, []).
start_server(Name::term(), Transport::ssl | tcp, Port::integer(), Handler::module(), Options::[option()]) -> {ok, CowboyListenerPid::pid()} | {error, any()}
Start a gRPC server.
The Name is used to identify this server in future calls, in particular when stopping the server.
The Handler module must export functions to provide the name of the server and the module to encode and decode the messages, and a function for each of the RPCs. Typically this module is generated from the .proto file using grpc:compile/1. The generated module contains skeleton functions for the RPCs, these must be extended with the actual implementation of the service.
stop_server(Name::term()) -> ok | {error, not_found}
Stop a gRPC server.
Generated by EDoc, Aug 21 2017, 17:04:43.