Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication in connection string #29

Open
FireMasterK opened this issue Nov 3, 2024 · 3 comments
Open

Authentication in connection string #29

FireMasterK opened this issue Nov 3, 2024 · 3 comments

Comments

@FireMasterK
Copy link
Collaborator

FireMasterK commented Nov 3, 2024

It would be nice to be able to provide authentication in the connection string like the Rust client, so you do not need to manually log in or connect. This would be really helpful for me for use in Docker (because of networking changes) if the client can automatically reconnect and login without me having to.

Relevent: #24 (comment)

@lsabi
Copy link
Contributor

lsabi commented Nov 3, 2024

The rust client on which this library is based on, does not have the credentials in the connect method, as shown in the example https://github.com/iggy-rs/iggy/blob/master/examples/src/getting-started/consumer/main.rs

Rather, the IggyClient only has it, but it is not used in this library.

I don't understand why the client "can automatically reconnect and login without you having to"....it's code, you write it once and if works you can run it multiple times. I don't understand the problem, do you mind elaborating the request?

@FireMasterK
Copy link
Collaborator Author

The rust client on which this library is based on, does not have the credentials in the connect method, as shown in the example https://github.com/iggy-rs/iggy/blob/master/examples/src/getting-started/consumer/main.rs

Rather, the IggyClient only has it, but it is not used in this library.

Yes, but what prevents us from using it directly? It also uses the Tcp client behind the scenes. The IggyClientBuilder gives us an IggyClient instance upon building anyway. There's also IggyClientBuilder::from_connection_string which does the same thing as far as I can tell. I have been using this in my Rust application without any issues.

I don't understand why the client "can automatically reconnect and login without you having to"....it's code, you write it once and if works you can run it multiple times. I don't understand the problem, do you mind elaborating the request?

Let's say you have a hostname you want iggy to connect, and you initialize a client and connect like so:
You can initialize it like so:

    let iggy_client = IggyClient::from_connection_string(&iggy_address).unwrap();

    iggy_client.connect().await.unwrap();

vs

    let iggy_client = IggyClientBuilder::new()
        .with_tcp()
        .with_server_address(iggy_address)
        .build()
        .unwrap();

    iggy_client.connect().await.unwrap();

    iggy_client.login_user("iggy", "iggy").await.unwrap();

When you connect this way, the client seems more fault tolerant from my observation in my Rust app. Previously, I used to get a Pipe broken error, in case my iggy server's IP changes (hostname remains the same).

This error caused me to need to restart my application every time this happened. I'm not sure but maybe this could be fixed at runtime by calling connect and login_user again, but would be really inconvenient since I would need to handle this error everywhere I use iggy.

@lsabi
Copy link
Contributor

lsabi commented Nov 3, 2024

If the server IP changes continuously, this is an edge case and also a problem for many other libraries in general. I think you need to first check your configuration/topology

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants