Module workflow_rpc::server

source ·
Expand description

RPC server module (native only). This module encapsulates server-side types used to create an RPC server: RpcServer, RpcHandler, Messenger, Interface and the protocol handlers: BorshProtocol and JsonProtocol.

Re-exports§

Modules§

  • Error declarations for the server module
  • WebSocket handshake helpers
  • Convenience module exporting all types required for using the RpcServer
  • Protocol module containing protocol handlers in charge of incoming and outgoing message serialization and RPC method and notification dispatch.
  • Result enum encapsulating server Error enum.

Macros§

  • method!() macro for declaration of RPC method handlers
  • notification!() macro for declaration of RPC notification handlers

Structs§

  • Interface struct carries a mapping of RPC methods and notifications, used by protocols to dispatch calls to their respective handlers.
  • The Messenger struct is supplied to the RpcHandler::handshake() call at the connection negotiation time. This structure comes in as Arc<Messenger> and can be retained for later processing. It provides two methods: Messenger::notify that can be used asynchronously to dispatch RPC notifications to the client and Messenger::close that can be used to terminate the RPC connection with the client.
  • RPC method wrapper. Contains the method closure function.
  • RPC notification wrapper. Contains the notification closure function.
  • A basic example RpcContext, can be used to keep track of connected peers.
  • RpcServer - a server-side object that listens for incoming websocket connections and delegates interaction with them to the supplied interfaces: RpcHandler (for RPC server management) and Interface (for method and notification dispatch).
  • A TCP socket server, listening for connections.
  • Send values to the associated UnboundedReceiver.
  • The configuration for WebSocket connection.
  • Atomic counters that allow tracking connection counts and cumulative message sizes in bytes (bandwidth consumption without accounting for the websocket framing overhead). These counters can be created and supplied externally or supplied as None.
  • WebSocketServer that provides the main websocket connection and message processing loop that delivers messages to the installed WebSocketHandler trait.

Enums§

Traits§

  • RpcHandler - a server-side event handler for RPC connections.
  • WebSocketHandler trait that represents the WebSocket processor functionality. This trait is supplied to the WebSocket which subsequently invokes it’s functions during websocket connection and messages. The trait can override with_handshake() method to enable invocation of the handshake() method upon receipt of the first valid websocket message from the incoming connection.
  • Base WebSocketServer trait allows the WebSocketServer<T> struct to be retained by the trait reference by casting it to the trait as follows:

Functions§

Type Aliases§