executor.rs

Overview

The executor.rs file defines the core logic for running the network layer's message processing and connection management within a distributed system. It primarily handles incoming and outgoing network messages, manages subscriptions, and oversees incoming network connections. This file orchestrates asynchronous tasks that listen for new connections and process subscription requests, ensuring efficient message dispatching and network communication. The main entry point is the asynchronous run function, which sets up and coordinates the pub-sub mechanisms and network transport.

Types and Structures

IncomingSender Enum

IncomingSender abstracts over two types of message senders for incoming network messages:

Methods

Functions

async fn run<Transport>(...) -> anyhow::Result<()>

This is the main asynchronous executor function responsible for running the network server tasks.

Implementation Details and Algorithms

Interactions with Other System Components

Mermaid Diagram

classDiagram
class IncomingSender {
+send()
}
class PubSub {
+clone()
}
class run {
+async fn
}
run --> IncomingSender : uses
run --> PubSub : creates/clones
run --> listen_incoming_connections : spawns task
run --> handle_subscriptions : spawns task
listen_incoming_connections ..> IncomingSender : sends messages
handle_subscriptions ..> IncomingSender : accesses
run --> metrics : optional
run --> transport : uses

This diagram illustrates the relationships between the main entities and functions in the file, highlighting run as the orchestrator that creates and manages PubSub, IncomingSender, and spawns asynchronous tasks for connection and subscription handling.