iggy icon indicating copy to clipboard operation
iggy copied to clipboard

Improve `IggyClient` interface

Open hubcio opened this issue 1 year ago • 1 comments

Currently, if someone wants to use IggyClient with custom server TCP address, following code is absolute minimum:

let tcp_client_config = TcpClientConfig {
    server_address: get_tcp_server_addr(),
    ..TcpClientConfig::default()
};
let tcp_client = Box::new(TcpClient::create(Arc::new(tcp_client_config)).unwrap());
let client = IggyClient::create(tcp_client, IggyClientConfig::default(), None, None, None);
client.connect().await?;
(...)

The aim of this task is to improve IggyClientBuilder and hide TcpClient, QuicClient and HttpClient.

IggyClientConfig should be renamed to something like IggyClientBackgroundConfig

After this task is done, IggyClientBuilder should look something like:

let config = TcpClientConfig {
            server_address: "127.0.0.1:8090".to_string(),
            reconnection_retries: 3,
            reconnection_interval: 1000,
            tls_enabled: false,
            tls_domain: "localhost".to_string(),
        } 
let client = IggyClientBuilder::new().with_config(config).build()?;
or
let client = IggyClientBuilder::new().with_tcp_config(config).build()?; // or http / quic if trait isn't possible
  • ClientProviderConfig can go away or at least be not preferred interface
  • we aim for simplicity
  • extra parameters should be set via IggyClientBuilder methods

hubcio avatar Jan 12 '24 20:01 hubcio

As discussed, I'll try to tackle this one. I'll ping you guys on Discord if/when I have some questions/proposal.

pradovic avatar Feb 13 '24 13:02 pradovic