Class: Cassandra::Execution::Profile

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra/execution/profile.rb

Overview

A profile is a collection of settings to use when executing and preparing statements. Register different profiles when creating the Cluster and execute/prepare statements with a particular profile by providing its name to the relevant method in Session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Profile

Returns a new instance of Profile.

Parameters:

  • options (Hash) (defaults to: {})

    hash of attributes. Unspecified attributes fall back to system defaults.

Options Hash (options):

  • :timeout (Numeric) — default: 12

    Request execution timeout in seconds. Setting value to nil will remove request timeout.

  • :load_balancing_policy (Cassandra::LoadBalancing::Policy) — default: LoadBalancing::Policies::TokenAware(LoadBalancing::Policies::DCAwareRoundRobin)

    Load-balancing policy that determines which node will run the next statement.

  • :retry_policy (Cassandra::Retry::Policy) — default: Retry::Policies::Default

    Retry policy that determines how request retries should be handled for different failure modes.

  • :consistency (Symbol) — default: :local_one

    Consistency level with which to run statements. Must be one of CONSISTENCIES.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cassandra/execution/profile.rb', line 58

def initialize(options = {})
  validate(options)
  options = DEFAULT_OPTIONS.merge(options)
  @load_balancing_policy = options[:load_balancing_policy] ||
      LoadBalancing::Policies::TokenAware.new(
          LoadBalancing::Policies::DCAwareRoundRobin.new,
          true)
  @retry_policy = options[:retry_policy] || Retry::Policies::Default.new
  @consistency = options[:consistency]
  @timeout = options[:timeout]
end

Instance Attribute Details

#consistencySymbol (readonly)

Returns consistency level with which to run statements.

Returns:

  • (Symbol)

    consistency level with which to run statements.



40
41
42
# File 'lib/cassandra/execution/profile.rb', line 40

def consistency
  @consistency
end

#load_balancing_policyCassandra::LoadBalancing::Policy (readonly)

Returns load-balancing policy that determines which node will run the next statement.

Returns:



33
34
35
# File 'lib/cassandra/execution/profile.rb', line 33

def load_balancing_policy
  @load_balancing_policy
end

#retry_policyCassandra::Retry::Policy (readonly)

Returns retry policy that determines how request retries should be handled for different failure modes.

Returns:

  • (Cassandra::Retry::Policy)

    retry policy that determines how request retries should be handled for different failure modes.



37
38
39
# File 'lib/cassandra/execution/profile.rb', line 37

def retry_policy
  @retry_policy
end

#timeoutNumeric (readonly)

Returns request execution timeout in seconds. nil means there is no timeout.

Returns:

  • (Numeric)

    request execution timeout in seconds. nil means there is no timeout.



43
44
45
# File 'lib/cassandra/execution/profile.rb', line 43

def timeout
  @timeout
end