Open charles-dyfis-net opened 7 years ago
This ticket is largely filed as a request for comments -- if a patch implementing this functionality were forthcoming (which it may or may not be), would there be upstream interest in merging it?
If you want to use this library in single-master case without sentinel, you can just leave :master-name and :sentinel-group configs to nil and provide hostname and port for the target redis server in :spec
like:
(ns xxx
(:require [taoensso.carmine :as car]
[carmine-sentinel.core :as car-sentinel]))
(def server-spec
{:host "127.0.0.1"
:port 6379})
(defmacro wcar* [& body]
(car-sentinel/wcar {:pool pool
:spec server-spec}
~@body))
(wcar*
(car/set "x" 1))
So carmine-sentinel
will not ask any sentinel for the master redis address and just connect to the single redis on "127.0.0.1:6379".
Running the
role
command on establishing a connection will returnmaster
,slave
orsentinel
. Proceeding to current logic in the sentinel case, while redirecting to the master returned in the result of said query in theslave
case or using the connection one already has for data/queries in themaster
case, would serve to generalize this library for use in all single-master redis clusters, including those that don't actually use Sentinel; or those where access to the Sentinel nodes is not permitted from clients.