thrift_runtime_service behaviour (thrift_runtime v0.7.0)
View SourceBehaviour of a service description module.
The generated <service>_server module (or a hand-written one) exports
service_info/0, giving the runtime everything it needs to frame
calls: parameter descriptors for decoding, the reply type for encoding
and the declared exceptions.
Handler functions are called as Handler:Function(Args...) with
arguments in declaration order. They answer:
{ok, Value}— the reply value (undefinedforvoidfunctions);{error, {exception, Value}}— a declared exception, identified by the value's representation tag (record tag,__struct__map or native record) and encoded under its throw-field id;{error, {exception, Name, Value}}— the same with an explicit wire name, for hand-written descriptors and map-representation exceptions (plain maps carry no identity);- anything else that raises — the runtime answers with
TApplicationException(INTERNAL_ERROR).
Summary
Callbacks
The single callback of the behaviour: returns the service descriptor.
Types
-type function_info() :: #{name := binary(), oneway := boolean(), params := thrift_runtime_binary:type_desc(), reply => thrift_runtime_binary:type_desc() | undefined, exceptions => [thrift_runtime_binary:field_desc()]}.
-type handler_result() :: {ok, term()} | {error, {exception, thrift_runtime_binary:struct_value()}} | {error, {exception, Name :: binary(), thrift_runtime_binary:struct_value()}}.
-type service_info() :: #{binary() := function_info()}.
Callbacks
-callback service_info() -> service_info().
The single callback of the behaviour: returns the service descriptor.