-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use fleek_crypto::ClientPublicKey; | ||
use tokio::io::{AsyncRead, AsyncWrite}; | ||
|
||
use crate::CompressionAlgoSet; | ||
|
||
/// The connection type that is offered by the (HandshakeInterface)[crate::HandshakeInterface]. | ||
pub trait ConnectionInterface: Send + Sync { | ||
/// The writer half of this connection. | ||
type Writer: AsyncWrite + Unpin + Send + Sync; | ||
|
||
/// The reader half of this connection. | ||
type Reader: AsyncRead + Unpin + Send + Sync; | ||
|
||
/// Split the connection to the `writer` and `reader` half and returns a mutable reference to | ||
/// both sides. | ||
fn split(&mut self) -> (&mut Self::Writer, &mut Self::Reader); | ||
|
||
/// Returns a mutable reference to the writer half of this connection. | ||
fn writer(&mut self) -> &mut Self::Writer; | ||
|
||
/// Returns a mutable reference to the reader half of this connection. | ||
fn reader(&mut self) -> &mut Self::Reader; | ||
|
||
/// Returns the lane number associated with this connection. | ||
fn get_lane(&self) -> u8; | ||
|
||
/// Returns the ID of the client that has established this connection. | ||
fn get_client(&self) -> &ClientPublicKey; | ||
|
||
/// The compression algorithms the client does support. | ||
fn get_compression_set(&self) -> CompressionAlgoSet; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,12 @@ | ||
use async_trait::async_trait; | ||
use fleek_crypto::ClientPublicKey; | ||
use tokio::io::{AsyncRead, AsyncWrite}; | ||
|
||
use crate::{common::WithStartAndShutdown, config::ConfigConsumer, CompressionAlgoSet}; | ||
use crate::{common::WithStartAndShutdown, config::ConfigConsumer, ConnectionInterface}; | ||
|
||
#[async_trait] | ||
pub trait HandshakeInterface: ConfigConsumer + WithStartAndShutdown + Sized + Send + Sync { | ||
/// The connection type that this handshake implementation offers. | ||
type Connection: ConnectionInterface; | ||
|
||
/// Initialize a new delivery acknowledgment aggregator. | ||
async fn init(config: Self::Config) -> anyhow::Result<Self>; | ||
} | ||
|
||
pub trait ConnectionInterface: Send + Sync { | ||
/// The writer half of this connection. | ||
type Writer: AsyncWrite + Unpin + Send + Sync; | ||
|
||
/// The reader half of this connection. | ||
type Reader: AsyncRead + Unpin + Send + Sync; | ||
|
||
/// Split the connection to the `writer` and `reader` half and returns a mutable reference to | ||
/// both sides. | ||
fn split(&mut self) -> (&mut Self::Writer, &mut Self::Reader); | ||
|
||
/// Returns a mutable reference to the writer half of this connection. | ||
fn writer(&mut self) -> &mut Self::Writer; | ||
|
||
/// Returns a mutable reference to the reader half of this connection. | ||
fn reader(&mut self) -> &mut Self::Reader; | ||
|
||
/// Returns the lane number associated with this connection. | ||
fn get_lane(&self) -> u8; | ||
|
||
/// Returns the ID of the client that has established this connection. | ||
fn get_client(&self) -> &ClientPublicKey; | ||
|
||
fn get_compression_set(&self) -> CompressionAlgoSet; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::{types::ServiceId, ConfigConsumer, ConnectionInterface, WithStartAndShutdown}; | ||
|
||
pub trait ServiceExecutorInterface: WithStartAndShutdown + ConfigConsumer + Send + Sync { | ||
/// The connector object that this service executor provides. | ||
type Connector: ServiceConnectorInterface; | ||
|
||
/// Return the connector for this service executor. | ||
fn get_connector(&self) -> Self::Connector; | ||
|
||
/// Register a core service, a core service is any service that we ship with this binary. | ||
fn register_core_service(&self, service_id: ServiceId); | ||
} | ||
|
||
pub trait ServiceConnectorInterface: Clone { | ||
/// The connection specified. | ||
type Connection: ConnectionInterface; | ||
|
||
/// Handle the connection to the service specified by the name. | ||
fn handle(&self, service: ServiceId, connection: Self::Connection); | ||
} |