rabbitmq / rabbitmq-stream-go-client

A client library for RabbitMQ streams
MIT License
169 stars 20 forks source link

All uris must be reachable in case of environment creation #309

Closed Egyptmaster closed 4 months ago

Egyptmaster commented 5 months ago

Describe the bug

Not sure if that is an expected behavior but it makes the usage of the client very hard. In case you are using multiple uris by SetUris(uris ...string) method all the hosts must be available at the point in time you create the environment with NewEnvironment.

Reproduction steps

env, err = stream.NewEnvironment(
        stream.NewEnvironmentOptions().
            SetUris([]string{"rabbitmq-streams://localhost:5552", "rabbitmq-streams://localhost:5553"}))

will return an error in case one of the uris is not accessable at point in time

Expected behavior

From the documentation I would expect to silently accept one of the hosts/uris to be not available at any point in time and automatically use randomly another one. Otherwise it is really hard in context of kubernetes/docker when I can never guarantee that all nodes are available when my service tries to start.

Additional context

No response

Gsantomaggio commented 5 months ago

Thank you @Egyptmaster

yes, his part can be improved:

https://github.com/rabbitmq/rabbitmq-stream-go-client/blob/202c881a329b793d5999fe7dcebffd1cd90b1c97/pkg/stream/environment.go#L51-L76

The client should try to connect with each URI

Gsantomaggio commented 5 months ago

@Egyptmaster can you please try https://github.com/rabbitmq/rabbitmq-stream-go-client/pull/310 ? thank you

Egyptmaster commented 5 months ago

Sure, but can do on Monday earliest

Gsantomaggio commented 4 months ago

@Egyptmaster, please let me know if you have a chance to test it so I can release the new version. Thank you

Egyptmaster commented 4 months ago

@Gsantomaggio sorry for late response. I recently tried the feature brach and the issue seems to be fixed 👍 thanks for the quick fix

Gsantomaggio commented 4 months ago

FYI: https://github.com/rabbitmq/rabbitmq-stream-go-client/releases/tag/v1.4.5