Class: Google::Cloud::Bigtable::SingleClusterRouting

Inherits:
RoutingPolicy
  • Object
show all
Defined in:
lib/google/cloud/bigtable/routing_policy.rb

Overview

A single-cluster routing policy for all read/write requests that use the associated app profile.

Unconditionally routes all read/write requests to a specific cluster. This option preserves read-your-writes consistency, but does not improve availability.

Examples:

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
  "my-cluster",
  allow_transactional_writes: true
)

app_profile = instance.create_app_profile(
  "my-app-profile",
  routing_policy,
  description: "App profile for user data instance"
)
puts app_profile.routing_policy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster_id, allow_transactional_writes) ⇒ SingleClusterRouting

Creates a new single-cluster routing policy.

Parameters:

  • cluster_id (String)

    The cluster to which read/write requests should be routed.

  • allow_transactional_writes (Boolean)

    If true, CheckAndMutateRow and ReadModifyWriteRow requests are allowed by this app profile. It is unsafe to send these requests to the same table/row/column in multiple clusters. Default value is false.



158
159
160
161
162
# File 'lib/google/cloud/bigtable/routing_policy.rb', line 158

def initialize cluster_id, allow_transactional_writes
  super()
  @cluster_id = cluster_id
  @allow_transactional_writes = allow_transactional_writes
end

Instance Attribute Details

#allow_transactional_writestrue, false

Returns If true, CheckAndMutateRow and ReadModifyWriteRow requests are allowed by this app profile. It is unsafe to send these requests to the same table/row/column in multiple clusters. Default value is false.

Returns:

  • (true, false)

    If true, CheckAndMutateRow and ReadModifyWriteRow requests are allowed by this app profile. It is unsafe to send these requests to the same table/row/column in multiple clusters. Default value is false.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/google/cloud/bigtable/routing_policy.rb', line 143

class SingleClusterRouting < RoutingPolicy
  attr_reader :cluster_id
  attr_reader :allow_transactional_writes

  ##
  # Creates a new single-cluster routing policy.
  #
  # @param cluster_id [String] The cluster to which read/write requests
  #   should be routed.
  # @param allow_transactional_writes [Boolean]
  #   If true, `CheckAndMutateRow` and `ReadModifyWriteRow` requests are
  #   allowed by this app profile. It is unsafe to send these requests to
  #   the same table/row/column in multiple clusters.
  #   Default value is false.
  #
  def initialize cluster_id, allow_transactional_writes
    super()
    @cluster_id = cluster_id
    @allow_transactional_writes = allow_transactional_writes
  end

  # @private
  def to_grpc
    Google::Cloud::Bigtable::Admin::V2::AppProfile::SingleClusterRouting.new(
      cluster_id:                 cluster_id,
      allow_transactional_writes: allow_transactional_writes
    )
  end
end

#cluster_idString

Returns The cluster to which read/write requests should be routed.

Returns:

  • (String)

    The cluster to which read/write requests should be routed.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/google/cloud/bigtable/routing_policy.rb', line 143

class SingleClusterRouting < RoutingPolicy
  attr_reader :cluster_id
  attr_reader :allow_transactional_writes

  ##
  # Creates a new single-cluster routing policy.
  #
  # @param cluster_id [String] The cluster to which read/write requests
  #   should be routed.
  # @param allow_transactional_writes [Boolean]
  #   If true, `CheckAndMutateRow` and `ReadModifyWriteRow` requests are
  #   allowed by this app profile. It is unsafe to send these requests to
  #   the same table/row/column in multiple clusters.
  #   Default value is false.
  #
  def initialize cluster_id, allow_transactional_writes
    super()
    @cluster_id = cluster_id
    @allow_transactional_writes = allow_transactional_writes
  end

  # @private
  def to_grpc
    Google::Cloud::Bigtable::Admin::V2::AppProfile::SingleClusterRouting.new(
      cluster_id:                 cluster_id,
      allow_transactional_writes: allow_transactional_writes
    )
  end
end