(add-sentinel-groups! conf)
Add sentinel groups,it will be merged into current conf: {:group-name {:specs [{ :host host :port port :password password :timeout-ms timeout-ms }, ...other sentinel instances...] :pool {<opts>}}} The conf is a map of sentinel group to connection spec.
Add sentinel groups,it will be merged into current conf: {:group-name {:specs [{ :host host :port port :password password :timeout-ms timeout-ms }, ...other sentinel instances...] :pool {<opts>}}} The conf is a map of sentinel group to connection spec.
(get-sentinel-redis-spec sentinel-group
master-name
{:keys [prefer-slave? slaves-balancer]
:or {prefer-slave? false slaves-balancer first}
:as server-conn})
Get redis spec by sentinel-group and master name. If it is not resolved, it will query from sentinel and cache the result in memory. Recommend to call this function at your app startup to reduce resolving cost.
Get redis spec by sentinel-group and master name. If it is not resolved, it will query from sentinel and cache the result in memory. Recommend to call this function at your app startup to reduce resolving cost.
(register-listener! listener)
Register listener for switching master. The listener will be called with an event: {:event "+switch-master" :old {:host old-master-ip :port old-master-port :new {:host new-master-ip :port new-master-port}}}
Register listener for switching master. The listener will be called with an event: {:event "+switch-master" :old {:host old-master-ip :port old-master-port :new {:host new-master-ip :port new-master-port}}}
(remove-invalid-resolved-master-specs!)
Iterate all the resolved master specs and remove any invalid master spec found by checking role on redis. Please call this periodically to keep safe.
Iterate all the resolved master specs and remove any invalid master spec found by checking role on redis. Please call this periodically to keep safe.
(remove-last-resolved-spec! sg master-name)
Remove last resolved master spec by sentinel group and master name.
Remove last resolved master spec by sentinel group and master name.
(remove-sentinel-group! group-name)
Remove a sentinel group configuration by name.
Remove a sentinel group configuration by name.
(sentinel-get-master-addr-by-name name)
get master address by master name. complexity O(1)
get master address by master name. complexity O(1)
(sentinel-group-status)
Get the status of all the registered sentinel groups and resolved redis cluster specs.
For example, firstly we set sentinel groups:
(set-sentinel-groups! {:group1 {:specs [{:host "127.0.0.1" :port 5000} {:host "127.0.0.1" :port 5001} {:host "127.0.0.1" :port 5002}]}})
Then do something to trigger the resolving of the redis cluster specs.
(let [server1-conn {:pool {} :spec {} :sentinel-group :group1 :master-name "mymaster"}] (wcar server1-conn (car/set "a" 100)))
At last we execute (sentinel-group-status), then got things like:
{:group1 {:redis-clusters [{:master-name "mymaster", :master-spec {:host "127.0.0.1", :port 6379}, :slave-specs ({:host "127.0.0.1", :port 6380})}], :sentinels [{:host "127.0.0.1", :port 5000, :with-active-sentinel-listener? true} {:host "127.0.0.1", :port 5001, :with-active-sentinel-listener? true} {:host "127.0.0.1", :port 5002, :with-active-sentinel-listener? true}]}}
Get the status of all the registered sentinel groups and resolved redis cluster specs. For example, firstly we set sentinel groups: (set-sentinel-groups! {:group1 {:specs [{:host "127.0.0.1" :port 5000} {:host "127.0.0.1" :port 5001} {:host "127.0.0.1" :port 5002}]}}) Then do something to trigger the resolving of the redis cluster specs. (let [server1-conn {:pool {} :spec {} :sentinel-group :group1 :master-name "mymaster"}] (wcar server1-conn (car/set "a" 100))) At last we execute (sentinel-group-status), then got things like: {:group1 {:redis-clusters [{:master-name "mymaster", :master-spec {:host "127.0.0.1", :port 6379}, :slave-specs ({:host "127.0.0.1", :port 6380})}], :sentinels [{:host "127.0.0.1", :port 5000, :with-active-sentinel-listener? true} {:host "127.0.0.1", :port 5001, :with-active-sentinel-listener? true} {:host "127.0.0.1", :port 5002, :with-active-sentinel-listener? true}]}}
(sentinel-sentinels name)
get sentinel instances by mater name. complexity O(1)
get sentinel instances by mater name. complexity O(1)
(sentinel-slaves name)
get slaves address by master name. complexity O(1)
get slaves address by master name. complexity O(1)
(set-sentinel-groups! conf)
Configure sentinel groups, it will replace current conf: {:group-name {:specs [{ :host host :port port :password password :timeout-ms timeout-ms }, ...other sentinel instances...] :pool {<opts>}}} The conf is a map of sentinel group to connection spec.
Configure sentinel groups, it will replace current conf: {:group-name {:specs [{ :host host :port port :password password :timeout-ms timeout-ms }, ...other sentinel instances...] :pool {<opts>}}} The conf is a map of sentinel group to connection spec.
(unregister-listener! listener)
Remove the listener for switching master.
Remove the listener for switching master.
(update-conn-spec server-conn)
Cast a carmine-sentinel conn to carmine raw conn spec. It will resolve master from sentinel first time,then cache the result in memory for reusing.
Cast a carmine-sentinel conn to carmine raw conn spec. It will resolve master from sentinel first time,then cache the result in memory for reusing.
(wcar conn & body)
(wcar conn :as-pipeline & body)
It's the same as taoensso.carmine/wcar, but supports :master-name "mymaster" :sentinel-group :default in conn for redis sentinel cluster.
It's the same as taoensso.carmine/wcar, but supports :master-name "mymaster" :sentinel-group :default in conn for redis sentinel cluster.
(with-new-pubsub-listener conn-spec & others)
It's the same as taoensso.carmine/with-new-pubsub-listener, but supports :master-name "mymaster" :sentinel-group :default in conn for redis sentinel cluster.
Please note that you can only pass connection spec like hostname and port to taoensso.carmine/with-new-pubsub-listener like:
(taoensso.carmine/with-new-pubsub-listener {:host "127.0.0.1" :port 6379} {... channel and handler stuff ... } ... publish and subscribe stuff ... )
but for with-new-pubsub-listener in carmine-sentinel, you need to wrap connection spec with another layer along with master-name and sentinel-group to take advantage of sentinel cluster like:
(carmine-sentinel/with-new-pubsub-listener {:spec {:host "127.0.0.1" :port 6379} :master-name "mymaster" :sentinel-group :default} {... channel and handler stuff ... } ... publish and subscribe stuff ... )
It's the same as taoensso.carmine/with-new-pubsub-listener, but supports :master-name "mymaster" :sentinel-group :default in conn for redis sentinel cluster. Please note that you can only pass connection spec like hostname and port to taoensso.carmine/with-new-pubsub-listener like: (taoensso.carmine/with-new-pubsub-listener {:host "127.0.0.1" :port 6379} {... channel and handler stuff ... } ... publish and subscribe stuff ... ) but for with-new-pubsub-listener in carmine-sentinel, you need to wrap connection spec with another layer along with master-name and sentinel-group to take advantage of sentinel cluster like: (carmine-sentinel/with-new-pubsub-listener {:spec {:host "127.0.0.1" :port 6379} :master-name "mymaster" :sentinel-group :default} {... channel and handler stuff ... } ... publish and subscribe stuff ... )
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close