Module resty.cassandra.policies.lb.req_dc_rr

Request and datacenter-aware round robin load balancing policy for OpenResty.

This policy will try to reuse the same node for the lifecycle of a given request if possible. It is mostly designed for use in OpenResty environments.

This ensures that the underlying connection pool to the node is reused as much as possible. If a new node is chosen for every query, there is no guarantee that each selected node will already have a pre-established connection. Since this policy reuses the same node for the lifecycle of a request, the chances of having to open a new connection are much reduced.

Since this policy is also datacenter-aware, it will prioritize nodes in the local datacenter as well (when no node has been elected for a given request yet).

Info:

  • Author: kikito

Functions

new (local_dc) Create a request and DC-aware round robin policy.


Functions

new (local_dc)
Create a request and DC-aware round robin policy. Instanciates a request and DC-aware round robin policy for resty.cassandra.cluster.

Parameters:

  • local_dc string Name of the local/closest datacenter.

Returns:

    table policy: A DC-aware round robin policy.

Usage:

    local Cluster = require "resty.cassandra.cluster"
    local req_dc_rr = require "resty.cassandra.policies.lb.req_dc_rr"
    
    local policy = req_dc_rr.new("my_local_cluster_name")
    local cluster = assert(Cluster.new {
      lb_policy = policy
    })
generated by LDoc 1.4.6 Last updated 2022-05-20 11:10:11