vapor / redis

Vapor provider for RediStack
MIT License
458 stars 57 forks source link

Impossible to configure redis, if redis host name is unknown on time of launch #212

Open Foboz opened 6 months ago

Foboz commented 6 months ago

Describe the issue

NIOCore.SocketAddressError.unknown from configuration

Vapor version

4.92.4

Operating system and version

Ubuntu Linux 22.04

Swift version

Swift 5.9

Steps to reproduce

We have a setup with docker-compose where redis is not mandatory or might start after vapor app, so network alias redis can't be resolved on time of vapor app starts, so that:

let configuration = try RedisConfiguration(url: "redis://redis:6379")

will fail with an error:

NIOCore.SocketAddressError.unknown(host: "redis", port: 6379)

which is happening here: https://github.com/vapor/redis/blob/44e57744b4dfbed596ef07466d36181105e475bc/Sources/Redis/RedisConfiguration.swift#L86

but actually here: https://github.com/apple/swift-nio/blob/1e2b3e34afee7d68d99d982b72f9a17a40624c66/Sources/NIOCore/SocketAddresses.swift#L490

so, no configuration can be set and due to internal logic around boot() it's not possible to configure Redis later on, once redis name can be resolved

Outcome

No response

Additional notes

No response