<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/bigtable/admin/v2/instance.proto

namespace Google\Cloud\Bigtable\Admin\V2\AppProfile;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Read/write requests are routed to the nearest cluster in the instance, and
 * will fail over to the nearest cluster that is available in the event of
 * transient errors or delays. Clusters in a region are considered
 * equidistant. Choosing this option sacrifices read-your-writes consistency
 * to improve availability.
 *
 * Generated from protobuf message <code>google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny</code>
 */
class MultiClusterRoutingUseAny extends \Google\Protobuf\Internal\Message
{
    /**
     * The set of clusters to route to. The order is ignored; clusters will be
     * tried in order of distance. If left empty, all clusters are eligible.
     *
     * Generated from protobuf field <code>repeated string cluster_ids = 1;</code>
     */
    private $cluster_ids;
    protected $affinity;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type array<string>|\Google\Protobuf\Internal\RepeatedField $cluster_ids
     *           The set of clusters to route to. The order is ignored; clusters will be
     *           tried in order of distance. If left empty, all clusters are eligible.
     *     @type \Google\Cloud\Bigtable\Admin\V2\AppProfile\MultiClusterRoutingUseAny\RowAffinity $row_affinity
     *           Row affinity sticky routing based on the row key of the request.
     *           Requests that span multiple rows are routed non-deterministically.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Bigtable\Admin\V2\Instance::initOnce();
        parent::__construct($data);
    }

    /**
     * The set of clusters to route to. The order is ignored; clusters will be
     * tried in order of distance. If left empty, all clusters are eligible.
     *
     * Generated from protobuf field <code>repeated string cluster_ids = 1;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getClusterIds()
    {
        return $this->cluster_ids;
    }

    /**
     * The set of clusters to route to. The order is ignored; clusters will be
     * tried in order of distance. If left empty, all clusters are eligible.
     *
     * Generated from protobuf field <code>repeated string cluster_ids = 1;</code>
     * @param array<string>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setClusterIds($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
        $this->cluster_ids = $arr;

        return $this;
    }

    /**
     * Row affinity sticky routing based on the row key of the request.
     * Requests that span multiple rows are routed non-deterministically.
     *
     * Generated from protobuf field <code>.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.RowAffinity row_affinity = 3;</code>
     * @return \Google\Cloud\Bigtable\Admin\V2\AppProfile\MultiClusterRoutingUseAny\RowAffinity|null
     */
    public function getRowAffinity()
    {
        return $this->readOneof(3);
    }

    public function hasRowAffinity()
    {
        return $this->hasOneof(3);
    }

    /**
     * Row affinity sticky routing based on the row key of the request.
     * Requests that span multiple rows are routed non-deterministically.
     *
     * Generated from protobuf field <code>.google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny.RowAffinity row_affinity = 3;</code>
     * @param \Google\Cloud\Bigtable\Admin\V2\AppProfile\MultiClusterRoutingUseAny\RowAffinity $var
     * @return $this
     */
    public function setRowAffinity($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\AppProfile\MultiClusterRoutingUseAny\RowAffinity::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * @return string
     */
    public function getAffinity()
    {
        return $this->whichOneof("affinity");
    }

}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(MultiClusterRoutingUseAny::class, \Google\Cloud\Bigtable\Admin\V2\AppProfile_MultiClusterRoutingUseAny::class);

