gleamrpc
Types
pub type GleamRPCError(error) {
GleamRPCError(error: error)
}
Constructors
-
GleamRPCError(error: error)
pub type GleamRPCServerError(error) {
WrongProcedure
ProcedureExecError(error: ProcedureError)
GetIdentityError(error)
GetParamsError(errors: List(dynamic.DecodeError))
}
Constructors
-
WrongProcedure
-
ProcedureExecError(error: ProcedureError)
-
GetIdentityError(error)
-
GetParamsError(errors: List(dynamic.DecodeError))
pub type Procedure(params, return) {
Procedure(
name: String,
router: option.Option(Router),
type_: ProcedureType,
params_type: convert.Converter(params),
return_type: convert.Converter(return),
)
}
Constructors
-
Procedure( name: String, router: option.Option(Router), type_: ProcedureType, params_type: convert.Converter(params), return_type: convert.Converter(return), )
pub type ProcedureCall(params, return, error) {
ProcedureCall(
procedure: Procedure(params, return),
client: ProcedureClient(params, return, error),
)
}
Constructors
-
ProcedureCall( procedure: Procedure(params, return), client: ProcedureClient(params, return, error), )
pub type ProcedureClient(params, return, error) {
ProcedureClient(
call: fn(
Procedure(params, return),
params,
fn(Result(return, GleamRPCError(error))) -> Nil,
) ->
Nil,
)
}
Constructors
-
ProcedureClient( call: fn( Procedure(params, return), params, fn(Result(return, GleamRPCError(error))) -> Nil, ) -> Nil, )
pub type ProcedureError {
ProcedureError(message: String)
}
Constructors
-
ProcedureError(message: String)
pub type ProcedureHandler(context, error) =
fn(
ProcedureIdentity,
fn(convert.GlitrType) ->
Result(convert.GlitrValue, GleamRPCServerError(error)),
context,
) ->
Result(convert.GlitrValue, GleamRPCServerError(error))
pub type ProcedureIdentity {
ProcedureIdentity(
name: String,
router: option.Option(Router),
type_: ProcedureType,
)
}
Constructors
-
ProcedureIdentity( name: String, router: option.Option(Router), type_: ProcedureType, )
pub type ProcedureServer(transport_in, transport_out, error) {
ProcedureServer(
get_identity: fn(transport_in) ->
Result(ProcedureIdentity, GleamRPCServerError(error)),
get_params: fn(transport_in) ->
fn(convert.GlitrType) ->
Result(convert.GlitrValue, GleamRPCServerError(error)),
recover_error: fn(GleamRPCServerError(error)) ->
transport_out,
encode_result: fn(convert.GlitrValue) -> transport_out,
)
}
Constructors
-
ProcedureServer( get_identity: fn(transport_in) -> Result(ProcedureIdentity, GleamRPCServerError(error)), get_params: fn(transport_in) -> fn(convert.GlitrType) -> Result(convert.GlitrValue, GleamRPCServerError(error)), recover_error: fn(GleamRPCServerError(error)) -> transport_out, encode_result: fn(convert.GlitrValue) -> transport_out, )
pub type ProcedureServerInstance(
transport_in,
transport_out,
context,
error,
) {
ProcedureServerInstance(
server: ProcedureServer(transport_in, transport_out, error),
handler: ProcedureHandler(context, error),
context_factory: fn(transport_in) -> context,
)
}
Constructors
-
ProcedureServerInstance( server: ProcedureServer(transport_in, transport_out, error), handler: ProcedureHandler(context, error), context_factory: fn(transport_in) -> context, )
pub type ProcedureType {
Query
Mutation
}
Constructors
-
Query
-
Mutation
Functions
pub fn call(
procedure_call: ProcedureCall(a, b, c),
params: a,
callback: fn(Result(b, GleamRPCError(c))) -> Nil,
) -> Nil
pub fn params(
procedure: Procedure(a, b),
params_converter: Converter(a),
) -> Procedure(a, b)
pub fn returns(
procedure: Procedure(a, b),
return_converter: Converter(b),
) -> Procedure(a, b)
pub fn with_client(
procedure: Procedure(a, b),
client: ProcedureClient(a, b, c),
) -> ProcedureCall(a, b, c)
pub fn with_context(
server: ProcedureServerInstance(a, b, c, d),
context_factory: fn(a) -> c,
) -> ProcedureServerInstance(a, b, c, d)
pub fn with_implementation(
server: ProcedureServerInstance(a, b, c, d),
procedure: Procedure(e, f),
implementation: fn(e, c) -> Result(f, ProcedureError),
) -> ProcedureServerInstance(a, b, c, d)
pub fn with_server(
server: ProcedureServer(a, b, c),
) -> ProcedureServerInstance(a, b, a, c)