Object.NetworkTransport (object v0.1.2)
Network transport layer abstraction for Object communication.
Provides a unified interface for multiple transport protocols including TCP, UDP, WebSockets, and gRPC. Handles connection management, pooling, multiplexing, and encryption.
Features
- Multiple transport protocol support
- Connection pooling and reuse
- Automatic reconnection with exponential backoff
- TLS/SSL encryption
- Message framing and fragmentation
- Bandwidth throttling and QoS
- Circuit breaker pattern
Summary
Functions
Returns a specification to start this module under a supervisor.
Establishes a connection to a remote endpoint.
Closes a specific connection.
Gets metrics for the transport layer.
Sends data over a specific connection.
Sends data to a specific endpoint, using connection pooling.
Starts the network transport service.
Types
@type circuit_breaker_state() :: %{ state: :closed | :open | :half_open, failure_count: non_neg_integer(), last_failure: DateTime.t() | nil, success_count: non_neg_integer() }
@type connection() :: %{ id: connection_id(), socket: port() | pid(), transport: transport_type(), host: String.t(), port: non_neg_integer(), state: :connected | :disconnected | :connecting, last_activity: DateTime.t(), bytes_sent: non_neg_integer(), bytes_received: non_neg_integer(), message_count: non_neg_integer(), error_count: non_neg_integer(), circuit_breaker: circuit_breaker_state() }
@type connection_id() :: String.t()
@type connection_opts() :: [ host: String.t(), port: non_neg_integer(), transport: transport_type(), ssl: boolean(), pool_size: pos_integer(), timeout: timeout(), reconnect_interval: pos_integer(), max_reconnect_attempts: pos_integer() ]
@type transport_metrics() :: %{ total_connections: non_neg_integer(), active_connections: non_neg_integer(), total_bytes_sent: non_neg_integer(), total_bytes_received: non_neg_integer(), total_messages: non_neg_integer(), avg_latency_ms: float() }
@type transport_state() :: %{ connections: %{required(connection_id()) => connection()}, pools: %{required(String.t()) => [connection()]}, config: connection_opts(), metrics: transport_metrics() }
@type transport_type() :: :tcp | :udp | :websocket | :grpc
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec connect(String.t(), non_neg_integer(), Keyword.t()) :: {:ok, connection_id()} | {:error, term()}
Establishes a connection to a remote endpoint.
@spec disconnect(connection_id()) :: :ok
Closes a specific connection.
@spec get_metrics() :: transport_metrics()
Gets metrics for the transport layer.
@spec send_data(connection_id(), binary()) :: :ok | {:error, term()}
Sends data over a specific connection.
@spec send_to(String.t(), non_neg_integer(), binary(), Keyword.t()) :: :ok | {:error, term()}
Sends data to a specific endpoint, using connection pooling.
Starts the network transport service.