<?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\GPBUtil;
use Google\Protobuf\RepeatedField;

/**
 * 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 string[] $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 RepeatedField<string>
     */
    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 string[] $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");
    }

}

