taoensso / carmine

Redis client + message queue for Clojure
https://www.taoensso.com/carmine
Eclipse Public License 1.0
1.15k stars 130 forks source link

Extending for Redis modules #246

Closed bandoos closed 11 months ago

bandoos commented 3 years ago

Hi!

(Great job awesome library! I can't describe the joy of finding libraries like this one)

In a hobby project i'm trying to build a system dashboard on top of redis with clj and cljs, and I'm now discovering about techniques in redis to store time-series data for cpu/memory/disk monitoring. Among the alternatives I found RedisTimeSeries which adds a new data structure and several commands to the redis instance.

The real question is: Do you have any pointers to give me for extending carmine generating additional commands from a redis extension module (e.g. RedisTimeSeries)?

I don't know if this is in the scope of carmine itself, and in fact my project can go on by wrapping the java library dedicated to the module; but i'd much rather maintain (and contribute) a carmine extension rather than a java wrapper.

Thanks in advance!

keep up the good work

ptaoussanis commented 3 years ago

@bandoos Hi Luca,

First thing I'd suggest would be to check if redis-call might be sufficient for your needs. This basically sends any arbitrary commands to Redis.

Does that cover your use case?

bandoos commented 3 years ago

Thanks for the fast response!

Yes it does cover the use case.

I will close the issue but i'm still curious if i could potentially 'recompile' carmine against a custom commands.json spec?

ptaoussanis commented 3 years ago

I will close the issue but i'm still curious if i could potentially 'recompile' carmine against a custom commands.json spec?

Sure, you've got two options:

  1. Append entries to https://github.com/ptaoussanis/carmine/blob/master/src/taoensso/carmine/commands.edn as your code starts up, before Carmine loads and consumes that file.

  2. Just define your own fn/s that use redis-call as a partial fn.

Number 2 is probably simpler and would do the job.

Cheers!

ptaoussanis commented 3 years ago

I just realised that as module use grows, it might be nice for Carmine to actually expose a hook for easily loading custom commands.edn or .json.

Would be easy to do this through an environment variable, etc.

Going to re-open this as a reminder for me to take a look at adding something like this next time I'm working on Carmine.

ptaoussanis commented 11 months ago

Just to update re: possibility of adding support for custom commands.json and/or commands.edn -

In hindsight, I don't think that Carmine is the right place for custom commands to be defined.

Users wishing to add 1st-class commands for modules, etc. - would do better to define these in a custom namespace:

tl;dr - folks using modules have two good options:

  1. Use redis-call, or
  2. Write custom wrapper/s for redis-call, etc. (this could be done on an application or library basis).