slacker.client.cluster

*grouping*

dynamic

cluster grouping function

*grouping-exceptions*

dynamic

clustered exception option

*grouping-results*

dynamic

clustered call result merge function

->ClusterEnabledSlackerClient

(->ClusterEnabledSlackerClient discover slacker-clients options)

Positional factory function for class slacker.client.cluster.ClusterEnabledSlackerClient.

clustered-slackerc

(clustered-slackerc cluster-name zk-server & {:keys [zk-root grouping grouping-results grouping-exceptions ping-interval factory server-data-change-handler interceptors], :or {zk-root "/slacker/cluster", grouping :random, grouping-results :single, grouping-exceptions :all, ping-interval 0}, :as options})

create a cluster enalbed slacker client options:

  • zk-root: specify the root path in zookeeper
  • factory: a client factory, default to non-ssl implementation
  • grouping: specify how the client select servers to call, this allows one or more servers to be called. Possible values:
    • :first always choose the first server available
    • :random choose a server by random (default)
    • :leader use current leader server
    • :least-in-flight use server with least pending requests
    • :weighted randomly select a server using :weight from server data as weight
    • :all call function on all servers
    • (fn [ns fname params slacker-client servers]) specify a function to choose. You can also return :random or :all in this function
  • grouping-results: when you call functions on multiple server, you can specify how many results return for the call. Note that if you use :vector or :map, you will break default behavior of the function. Possible values:
    • :nil always returns nil
    • :single returns only one value
    • :vector returns values from all servers as a vector
    • :map returns values from all servers as a map, server host:port as key
    • (fn [ns fname params]) a function that returns keywords above
  • grouping-exceptions: how to deal with the exceptions when calling functions on multiple instance.
    • :all the API throws exception when exception is thrown on every instance
    • :any the API throws exception when any instance throws exception
    • (fn [valid-result error-results]) a function to decide what exception to throw or never
  • server-data-change-handler: a function accepts the client object, server address and server data. Note that this function runs on event thread so never do blocking things within it.

CoordinatorAwareClient

protocol

members

delete-ns-mapping

(delete-ns-mapping this fname)

get-connected-servers

(get-connected-servers this)

get-ns-mappings

(get-ns-mappings this)

refresh-all-servers

(refresh-all-servers this)

refresh-associated-servers

(refresh-associated-servers this ns)

server-data

(server-data this server-id)

defn-remote

macro

(defn-remote sc fname & options)

cluster enabled defn-remote, with cluster options supported.

try-update-server-data!

use-remote

(use-remote & options)

cluster enabled use-remote