Cloud Bigtable API - Class Google::Cloud::Bigtable::AppProfile (v2.10.1)

Reference documentation and code samples for the Cloud Bigtable API class Google::Cloud::Bigtable::AppProfile.

AppProfile

A configuration object describing how Cloud Bigtable should treat traffic from a particular end user application.

Inherits

  • Object

Example

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

app_profile = instance.app_profile "my-app-profile"

# Update
app_profile.description = "User data instance app profile"
app_profile.routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
job = app_profile.save
job.wait_until_done!

# Delete
app_profile.delete

Methods

.multi_cluster_routing

def self.multi_cluster_routing() -> Google::Cloud::Bigtable::MultiClusterRoutingUseAny

Creates an instance of the multi cluster routing policy.

Read/write requests may be routed to any cluster in the instance and will fail over to another cluster in the event of transient errors or delays. Choosing this option sacrifices read-your-writes consistency to improve availability.

Example
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing

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

.single_cluster_routing

def self.single_cluster_routing(cluster_id, allow_transactional_writes: false) -> Google::Cloud::Bigtable::SingleClusterRouting

Creates an instance of the single cluster routing policy.

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

Parameters
  • cluster_id (String) — The cluster to which read/write requests should be routed.
  • allow_transactional_writes (Boolean) (defaults to: 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.
Example
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

#delete

def delete(ignore_warnings: false) -> Boolean

Deletes the app profile.

Parameter
  • ignore_warnings (Boolean) (defaults to: false) — Default value is false. If true, ignore safety checks when deleting the app profile.
Returns
  • (Boolean) — Returns true if the app profile was deleted.
Example
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

app_profile = instance.app_profile "my-app-profile"

app_profile.delete ignore_warnings: true # Ignore warnings.

# OR : Not ignoring warnings
app_profile.delete

#description

def description() -> String

Description of the app profile.

Returns
  • (String)

#description=

def description=(text)

Sets the description of the app profile.

Parameter
  • text (String) — Description text

#etag

def etag() -> String

Etag for optimistic concurrency control.

Returns
  • (String)

#instance_id

def instance_id() -> String

The unique identifier for the instance to which the app profile belongs.

Returns
  • (String)

#multi_cluster_routing

def multi_cluster_routing() -> Google::Cloud::Bigtable::MultiClusterRoutingUseAny, nil

Gets the multi-cluster routing policy, if present.

#name

def name() -> String

The unique identifier for the app profile.

Returns
  • (String)

#path

def path() -> String

The full path for the app profile resource. Values are of the form: projects/<project_id>/instances/<instance_id>/appProfiles/<app_profile_name>.

Returns
  • (String)

#project_id

def project_id() -> String

The unique identifier for the project to which the app profile belongs.

Returns
  • (String)

#reload!

def reload!() -> Google::Cloud::Bigtable::AppProfile

Reloads the app profile data.

#routing_policy

def routing_policy() -> Google::Cloud::Bigtable::RoutingPolicy

Gets the routing policy for all read/write requests that use the app profile.

Routing Policies:

  • MultiClusterRoutingUseAny - Read/write requests may be routed to any cluster in the instance and will fail over to another cluster in the event of transient errors or delays. Choosing this option sacrifices read-your-writes consistency to improve availability.
  • SingleClusterRouting - Unconditionally routes all read/write requests to a specific cluster. This option preserves read-your-writes consistency but does not improve availability. Value contains cluster_id and optional field allow_transactional_writes.
Example
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing

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

#routing_policy=

def routing_policy=(policy)

Sets the routing policy for the app profile.

Parameter
  • policy (Google::Cloud::Bigtable::RoutingPolicy) —

    The routing policy for all read/write requests that use this app profile. A value must be explicitly set.

    Routing Policies:

    • MultiClusterRoutingUseAny - Read/write requests may be routed to any cluster in the instance and will fail over to another cluster in the event of transient errors or delays. Choosing this option sacrifices read-your-writes consistency to improve availability.
    • SingleClusterRouting - Unconditionally routes all read/write requests to a specific cluster. This option preserves read-your-writes consistency but does not improve availability. Value contains cluster_id and optional field allow_transactional_writes.
Examples

Set multi cluster routing policy.

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new
instance = bigtable.instance "my-instance"
app_profile = instance.app_profile "my-app-profile"

routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing
app_profile.routing_policy = routing_policy

Set single cluster routing policy.

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new
instance = bigtable.instance "my-instance"
app_profile = instance.app_profile "my-app-profile"

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

#save

def save(ignore_warnings: false) -> Google::Cloud::Bigtable::AppProfile::Job
Aliases

Updates the app profile.

Parameter
  • ignore_warnings (Boolean) (defaults to: false) — Default value is false. If true, ignore safety checks when updating the app profile.
Examples
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

app_profile = instance.app_profile "my-app-profile"

app_profile.description = "User data instance app profile"
app_profile.routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing

job = app_profile.save
job.wait_until_done!
if job.error?
  puts job.error
else
  puts "App profile successfully updated."
  app_profile = job.app_profile
end

Update with single cluster routing.

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"
app_profile = instance.app_profile "my-app-profile"

app_profile.description = "User data instance app profile"
routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
  "my-cluster",
  allow_transactional_writes: true
)
app_profile.routing_policy = routing_policy

job = app_profile.save

job.done? #=> false
job.reload!
job.done? #=> true

if job.error?
  puts job.error
else
  app_profile = job.app_profile
  puts app_profile.name
end

#single_cluster_routing

def single_cluster_routing() -> Google::Cloud::Bigtable::SingleClusterRouting, nil

Gets the single cluster routing policy, if present.

#update

def update(ignore_warnings: false) -> Google::Cloud::Bigtable::AppProfile::Job
Alias Of: #save

Updates the app profile.

Parameter
  • ignore_warnings (Boolean) (defaults to: false) — Default value is false. If true, ignore safety checks when updating the app profile.
Examples
require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"

app_profile = instance.app_profile "my-app-profile"

app_profile.description = "User data instance app profile"
app_profile.routing_policy = Google::Cloud::Bigtable::AppProfile.multi_cluster_routing

job = app_profile.save
job.wait_until_done!
if job.error?
  puts job.error
else
  puts "App profile successfully updated."
  app_profile = job.app_profile
end

Update with single cluster routing.

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance "my-instance"
app_profile = instance.app_profile "my-app-profile"

app_profile.description = "User data instance app profile"
routing_policy = Google::Cloud::Bigtable::AppProfile.single_cluster_routing(
  "my-cluster",
  allow_transactional_writes: true
)
app_profile.routing_policy = routing_policy

job = app_profile.save

job.done? #=> false
job.reload!
job.done? #=> true

if job.error?
  puts job.error
else
  app_profile = job.app_profile
  puts app_profile.name
end