Hi, I am new to crystal, trying to figure out the following compile issue:
In lib/redis/src/redis/pooled_client.cr:30:35
#19 1.369
#19 1.369 30 | @pool = ConnectionPool(Redis).new(capacity: pool_size, timeout: pool_timeout) do
#19 1.369 ^--
#19 1.369 Error: no overload matches 'ConnectionPool(Redis).new', capacity: Int32, timeout: Float64
#19 1.369
#19 1.369 Overloads are:
#19 1.369 - ConnectionPool(T).new(capacity : Int32 = 5, timeout : Time::Span = 5.seconds, &block : (-> T))
I believe the issue occurs when I try to initialize a redis connection:
@redis = RedisClient.new ci.redis_url
RedisClient class:
class RedisClient
include Helpers::LogHelper
....
getter! connection : Redis::PooledClient?
....
def connect
Retriable.retry do
Log.notice { "Connecting to Redis... " }
@connection = ::Redis::PooledClient.new url: @uri.to_s
connection.info
Log.notice { "Connected to Redis" }
nil
end
...
What am I missing?
Please note that the code was compiling fine in the past but I believe that change in this library (v0.3.0) broke it:
Thank you!
1 Like
The gist of it is if you look at the latest release:
- The timeout parameter for
Pool.new
is now a Time::Span
instead of a Float64
.
Upgrading from a 0.2.x
version to a 0.3.x
version can, and usually does, include breaking changes just like this. Which Redis shard/version of it are you using?
1 Like
Thanks @Blacksmoke16 for your reply.
Shard looks like:
redis:
github: stefanwille/crystal-redis
version: ~> 2.6.0
amqp-client:
github: cloudamqp/amqp-client.cr
cache:
github: mamantoha/cache
retriable:
github: Sija/retriable.cr
Does this help?
Thanks
What about your shard.lock
file?
NVM: The issue is by restricting the version of that redis shard to ~> 2.6.0
, it can only use that version, which was before the pool
shard was restricted to <= 0.2.4
in 2.9.1 · stefanwille/crystal-redis@15c22e0 · GitHub.
Solution seems to be just upgrade the redis shard to its latest version and should be good.
2 Likes
Bumping crystal-redis version to 2.9.1 did resolve this issue!
Thank you for this hint. I thought v2.8.0 is the latest version as it shows on GitHub so I did bump it to that one, with no luck.
I very much appreciate your help.
Cheers!
Glad to hear! Looks like it’s the latest release, but not the latest tag. Ideally the changelog, tag, and release are all in-sync, but that doesn’t seem to be the case. Could maybe be worth creating an issue on their GH about it.