package async_rpc_websocket

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Connection_source : sig ... end
module Connection_initiated_from : sig ... end
type http_handler = body:Cohttp_async.Body.t -> Async.Socket.Address.Inet.t -> Cohttp_async.Request.t -> Cohttp_async.Server.response Async.Deferred.t
type raw_http_handler = body:Cohttp_async.Body.t -> Async.Socket.Address.Inet.t -> Cohttp_async.Request.t -> Cohttp_async.Server.response_action Async.Deferred.t
type should_process_request = Async.Socket.Address.Inet.t -> (Cohttp.Header.t * [ `is_websocket_request of bool ]) Connection_source.t -> unit Core.Or_error.t
type ('s, 'c, 'r) common_args = implementations:'s Async.Rpc.Implementations.t -> initial_connection_state: ('c -> Connection_initiated_from.t -> Async.Socket.Address.Inet.t -> Async.Rpc.Connection.t -> 's) -> ?http_handler:('c -> http_handler) -> ?handshake_timeout:Core.Time.Span.t -> ?heartbeat_config:Async.Rpc.Connection.Heartbeat_config.t -> ?should_process_request:should_process_request -> ?on_handshake_error:Async.Rpc.Connection.on_handshake_error -> 'r

The 'c argument allows a wrapper for handler to pass extra information to the initial_connection_state and http_handler handlers. This parameter is fixed to unit in the functions other than handler.

type ('s, 'r, 'l) serve_args = where_to_listen:(Async.Socket.Address.Inet.t, 'l) Async.Tcp.Where_to_listen.t -> ('s, unit, ?on_handler_error: [ `Raise | `Ignore | `Call of Async.Socket.Address.Inet.t -> exn -> unit ] -> ?mode:Conduit_async.server -> ?backlog:int -> ?max_connections:int -> unit -> 'r) common_args
type 'l tcp_server = (Async.Socket.Address.Inet.t, 'l) Async.Tcp.Server.t Async.Deferred.t
type 'l ws_server = (Async.Socket.Address.Inet.t, 'l) Cohttp_async.Server.t Async.Deferred.t
val handler : ?description:Core.Info.t -> ('s, 'c, 'c -> raw_http_handler) common_args

This returns a http handler that can be added into an existing cohttp server

val serve_with_tcp_server : where_to_listen_for_tcp: (Async.Socket.Address.Inet.t, 'l) Async.Tcp.Where_to_listen.t -> ?max_message_size:int -> ?make_transport:Async.Rpc.Connection.transport_maker -> ('s, 'l tcp_server * 'l ws_server, 'l) serve_args

Serves both HTTP/Websockets and regular RPCs via TCP server.

val serve : ('s, 'l ws_server, 'l) serve_args

Serves HTTP/Websockets only

val client : ?headers:Cohttp.Header.t -> ?handshake_timeout:Core.Time_ns.Span.t -> ?heartbeat_config:Async.Rpc.Connection.Heartbeat_config.t -> Uri.t -> Async.Rpc.Connection.t Async.Deferred.Or_error.t

Connect to a Websockets RPC server at the given URI.

OCaml

Innovation. Community. Security.