Liking cljdoc? Tell your friends :D

carmine-sentinel.core


add-sentinel-groups!clj

(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.
sourceraw docstring

get-sentinel-redis-specclj

(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.
sourceraw docstring

notify-event-listenersclj

(notify-event-listeners event)
source

register-listener!clj

(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}}}
sourceraw docstring

remove-invalid-resolved-master-specs!clj

(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.
sourceraw docstring

remove-last-resolved-spec!clj

(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.
sourceraw docstring

remove-sentinel-group!clj

(remove-sentinel-group! group-name)

Remove a sentinel group configuration by name.

Remove a sentinel group configuration by name.
sourceraw docstring

sentinel-get-master-addr-by-nameclj

(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)
sourceraw docstring

sentinel-group-statusclj

(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}]}}
sourceraw docstring

sentinel-sentinelsclj

(sentinel-sentinels name)

get sentinel instances by mater name. complexity O(1)

get sentinel instances by mater name. complexity O(1)
sourceraw docstring

sentinel-slavesclj

(sentinel-slaves name)

get slaves address by master name. complexity O(1)

get slaves address by master name. complexity O(1)
sourceraw docstring

SentinelListenerclj

source

set-sentinel-groups!clj

(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.
sourceraw docstring

silentlycljmacro

(silently & body)
source

sync-oncljmacro

(sync-on sg mn & body)
source

unregister-listener!clj

(unregister-listener! listener)

Remove the listener for switching master.

Remove the listener for switching master.
sourceraw docstring

update-conn-specclj

(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.
sourceraw docstring

wcarcljmacro

(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.
sourceraw docstring

with-new-pubsub-listenercljmacro

(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 ... )
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close