net-component 0.1.0

This crate defines core traits and types for the components in net-timescale. The component in the context is a separate microservice which handles each own type of requests from net-gateway - rest server. Because of the amount of such services we decided to create a trait which defines the skeleton of each one to reduce the code duplicate.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::error::Error;
use std::sync::Arc;

use sqlx::Pool;
use sqlx::Postgres;

use net_core_api::api::envelope::envelope::Envelope;

#[async_trait::async_trait]
pub trait NetworkServiceHandler: Send + Sync {
    async fn handle(
        &self,
        connection_pool: Arc<Pool<Postgres>>,
        enveloped_request: Envelope
    ) -> Result<Envelope, Box<dyn Error + Send + Sync>>;

    fn get_handler_type(&self) -> String;
}