Skip to main content

synapse_rpc/
lib.rs

1//! Synapse RPC Runtime
2//!
3//! Core RPC types and runtime for Synapse services.
4//!
5//! This crate provides:
6//! - Codec layer for JSON and Protobuf serialization
7//! - HTTP client for making RPC calls
8//! - Interface registry for routing requests
9//! - Typed handler system for type-safe request handling
10
11pub mod codec;
12pub mod error;
13pub mod http_client;
14pub mod message;
15pub mod method_router;
16pub mod registry;
17pub mod server;
18pub mod typed_handler;
19
20// Codec layer exports
21pub use codec::{Codec, ContentType, JsonCodec, ProtobufCodec, decode_message, encode_message};
22// Error types
23pub use error::{IntoServiceError, RpcResult, ServiceError, TransportError};
24// HTTP client exports
25pub use http_client::HttpRpcClient;
26// Message helpers
27pub use message::{
28    MAX_BATCH_PAYLOAD_SIZE,
29    MAX_RPC_PAYLOAD_SIZE,
30    PROTOCOL_VERSION,
31    ParsedMessage,
32    // Health
33    create_health_pull,
34    create_health_response,
35    // HTTP endpoint registration
36    create_http_endpoint_deregister,
37    create_http_endpoint_register,
38    create_http_registration_ack,
39    create_interface_deregister,
40    // Registration
41    create_interface_register,
42    create_registration_ack,
43    // RPC
44    create_rpc_request,
45    create_rpc_response,
46    error_response,
47    extract_health_pull,
48    extract_health_response,
49    extract_http_registration_ack,
50    extract_interface_deregister,
51    extract_interface_register,
52    extract_registration_ack,
53    extract_rpc_request,
54    extract_rpc_response,
55    ok_response,
56    // Routing
57    parse_message,
58};
59// Handler and routing
60pub use method_router::MethodRouter;
61pub use registry::{FunctionHandler, InterfaceRegistration, InterfaceRegistry, RpcHandler};
62pub use server::RpcServer;
63// Re-export derive macro
64pub use synapse_macros::RpcError;
65// Re-export proto types for convenience
66pub use synapse_proto::{
67    HeaderEntry, InstanceCapabilities, InterfaceRegister, MessageKind, RpcError as ProtoRpcError,
68    RpcRequest, RpcResponse, RpcStatus, SynapseMessage, synapse_message,
69};
70pub use typed_handler::{TypedHandler, TypedRpcHandler};