mobc_nebula/
graph.rs

1use core::marker::PhantomData;
2
3use fbthrift_transport::{
4    fbthrift_transport_response_handler::ResponseHandler, AsyncTransportConfiguration,
5};
6use nebula_client::Version;
7
8//
9#[derive(Debug, Clone)]
10pub struct GraphClientConfiguration {
11    pub host: String,
12    pub port: u16,
13    pub username: String,
14    pub password: String,
15    pub space: Option<String>,
16}
17
18impl GraphClientConfiguration {
19    pub fn new(
20        host: String,
21        port: u16,
22        username: String,
23        password: String,
24        space: Option<String>,
25    ) -> Self {
26        Self {
27            host,
28            port,
29            username,
30            password,
31            space,
32        }
33    }
34}
35
36impl GraphClientConfiguration {
37    pub fn tcp_connect_addr(&self) -> String {
38        format!("{}:{}", self.host, self.port)
39    }
40}
41
42//
43#[derive(Clone)]
44pub struct GraphConnectionManager<S, SLEEP, H, V>
45where
46    H: ResponseHandler,
47    V: Version,
48{
49    pub client_configuration: GraphClientConfiguration,
50    pub transport_configuration: AsyncTransportConfiguration<H>,
51    phantom: PhantomData<(S, SLEEP, V)>,
52}
53
54impl<S, SLEEP, H, V> GraphConnectionManager<S, SLEEP, H, V>
55where
56    H: ResponseHandler + Send + Sync + 'static + Unpin,
57    V: Version,
58{
59    pub fn new(
60        client_configuration: GraphClientConfiguration,
61        transport_configuration: AsyncTransportConfiguration<H>,
62    ) -> Self {
63        Self {
64            client_configuration,
65            transport_configuration,
66            phantom: PhantomData,
67        }
68    }
69}