keygen-sh / keygen-api

Keygen is a fair source software licensing and distribution API built with Ruby on Rails. For developers, by developers.
https://keygen.sh
Other
701 stars 40 forks source link

Add support for providing socket path for Redis connections #752

Open crankedguy opened 10 months ago

crankedguy commented 10 months ago

Hi,

I tried I think every known possible uri combination to connect my redis instances via UDS and not the slower TCP. It seems this is not implemented at all, or at least the uri scheme to use is not known to me then. If it is possible can you please provide the correct scheme, if not possible can this be implemented please? A connection via UDS should really be considered standard today, and is possible in nearly every application known. And as you already connect to redis this should be a few lines at max to parse/extend/connect.

Please consider.

Many thanks!

ezekg commented 10 months ago

We use redis-rb under the hood, and that library does accept a socket path in the initializer:

redis = Redis.new(path: "/tmp/redis.sock")

But I'm unsure of if Sidekiq and the Redis cache store accept a socket, which both use Redis. Right now, both of these pull their Redis config from the environment. We're using the REDIS_PROVIDER environment variable for Sidekiq's Redis, and REDIS_URL for the cache store. I'm not sure if either of these accept a path instead of a URL (I'd assume no), so it would require a custom Redis instance be provided to each of these if an environment variable resembles a socket path.

But since this isn't following our self-hosting best practices (i.e. using Docker), we're not going to add this functionality ourselves. But please feel free to open a pull request if you figure it out and want to contribute.

crankedguy commented 10 months ago

Your are not using the linked library under the hood, you are using this one https://github.com/redis-rb/redis-client according to the Gemfile. What does this have to do with docker? You can configure the docker container to serve on a socket, like any other standard redis install. Listening on a socket is not non-standard but in fact promoted by redis because they have a much higher throughput. I hope someday people come back to reason with their non-optimized-everything-standard dockerized approach :)) Your arguments at least are not viable in this case. Thanks anyways, I am no Ruby developer. Maybe I find someone who does it for me,

ezekg commented 10 months ago

Incorrect. We depend on the redis gem aka redis-rb: https://github.com/keygen-sh/keygen-api/blob/master/Gemfile#L17

Sidekiq depends on redis-client as of v7, so it's included in the lockfile because of that.

Like I said, open to PRs but we won't be implementing this ourselves.

crankedguy commented 10 months ago

We fixed that on our side with a patch now. Thanks.