<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: apache/rocketmq/v2/service.proto

namespace Apache\Rocketmq\V2;

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

/**
 * Generated from protobuf message <code>apache.rocketmq.v2.Subscription</code>
 */
class Subscription extends \Google\Protobuf\Internal\Message
{
    /**
     * Subscription settings below here is appointed by client, thus it is
     * unnecessary for server to push at present.
     * Consumer group.
     *
     * Generated from protobuf field <code>optional .apache.rocketmq.v2.Resource group = 1;</code>
     */
    protected $group = null;
    /**
     * Subscription for consumer.
     *
     * Generated from protobuf field <code>repeated .apache.rocketmq.v2.SubscriptionEntry subscriptions = 2;</code>
     */
    private $subscriptions;
    /**
     * Subscription settings below here are from server, it is essential for
     * server to push.
     * When FIFO flag is `true`, messages of the same message group are processed
     * in first-in-first-out manner.
     * Brokers will not deliver further messages of the same group until prior
     * ones are completely acknowledged.
     *
     * Generated from protobuf field <code>optional bool fifo = 3;</code>
     */
    protected $fifo = null;
    /**
     * Message receive batch size here is essential for push consumer.
     *
     * Generated from protobuf field <code>optional int32 receive_batch_size = 4;</code>
     */
    protected $receive_batch_size = null;
    /**
     * Long-polling timeout for `ReceiveMessageRequest`, which is essential for
     * push consumer.
     *
     * Generated from protobuf field <code>optional .google.protobuf.Duration long_polling_timeout = 5;</code>
     */
    protected $long_polling_timeout = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Apache\Rocketmq\V2\Resource $group
     *           Subscription settings below here is appointed by client, thus it is
     *           unnecessary for server to push at present.
     *           Consumer group.
     *     @type array<\Apache\Rocketmq\V2\SubscriptionEntry>|\Google\Protobuf\Internal\RepeatedField $subscriptions
     *           Subscription for consumer.
     *     @type bool $fifo
     *           Subscription settings below here are from server, it is essential for
     *           server to push.
     *           When FIFO flag is `true`, messages of the same message group are processed
     *           in first-in-first-out manner.
     *           Brokers will not deliver further messages of the same group until prior
     *           ones are completely acknowledged.
     *     @type int $receive_batch_size
     *           Message receive batch size here is essential for push consumer.
     *     @type \Google\Protobuf\Duration $long_polling_timeout
     *           Long-polling timeout for `ReceiveMessageRequest`, which is essential for
     *           push consumer.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Apache\Rocketmq\V2\Service::initOnce();
        parent::__construct($data);
    }

    /**
     * Subscription settings below here is appointed by client, thus it is
     * unnecessary for server to push at present.
     * Consumer group.
     *
     * Generated from protobuf field <code>optional .apache.rocketmq.v2.Resource group = 1;</code>
     * @return \Apache\Rocketmq\V2\Resource|null
     */
    public function getGroup()
    {
        return $this->group;
    }

    public function hasGroup()
    {
        return isset($this->group);
    }

    public function clearGroup()
    {
        unset($this->group);
    }

    /**
     * Subscription settings below here is appointed by client, thus it is
     * unnecessary for server to push at present.
     * Consumer group.
     *
     * Generated from protobuf field <code>optional .apache.rocketmq.v2.Resource group = 1;</code>
     * @param \Apache\Rocketmq\V2\Resource $var
     * @return $this
     */
    public function setGroup($var)
    {
        GPBUtil::checkMessage($var, \Apache\Rocketmq\V2\Resource::class);
        $this->group = $var;

        return $this;
    }

    /**
     * Subscription for consumer.
     *
     * Generated from protobuf field <code>repeated .apache.rocketmq.v2.SubscriptionEntry subscriptions = 2;</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getSubscriptions()
    {
        return $this->subscriptions;
    }

    /**
     * Subscription for consumer.
     *
     * Generated from protobuf field <code>repeated .apache.rocketmq.v2.SubscriptionEntry subscriptions = 2;</code>
     * @param array<\Apache\Rocketmq\V2\SubscriptionEntry>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setSubscriptions($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Apache\Rocketmq\V2\SubscriptionEntry::class);
        $this->subscriptions = $arr;

        return $this;
    }

    /**
     * Subscription settings below here are from server, it is essential for
     * server to push.
     * When FIFO flag is `true`, messages of the same message group are processed
     * in first-in-first-out manner.
     * Brokers will not deliver further messages of the same group until prior
     * ones are completely acknowledged.
     *
     * Generated from protobuf field <code>optional bool fifo = 3;</code>
     * @return bool
     */
    public function getFifo()
    {
        return isset($this->fifo) ? $this->fifo : false;
    }

    public function hasFifo()
    {
        return isset($this->fifo);
    }

    public function clearFifo()
    {
        unset($this->fifo);
    }

    /**
     * Subscription settings below here are from server, it is essential for
     * server to push.
     * When FIFO flag is `true`, messages of the same message group are processed
     * in first-in-first-out manner.
     * Brokers will not deliver further messages of the same group until prior
     * ones are completely acknowledged.
     *
     * Generated from protobuf field <code>optional bool fifo = 3;</code>
     * @param bool $var
     * @return $this
     */
    public function setFifo($var)
    {
        GPBUtil::checkBool($var);
        $this->fifo = $var;

        return $this;
    }

    /**
     * Message receive batch size here is essential for push consumer.
     *
     * Generated from protobuf field <code>optional int32 receive_batch_size = 4;</code>
     * @return int
     */
    public function getReceiveBatchSize()
    {
        return isset($this->receive_batch_size) ? $this->receive_batch_size : 0;
    }

    public function hasReceiveBatchSize()
    {
        return isset($this->receive_batch_size);
    }

    public function clearReceiveBatchSize()
    {
        unset($this->receive_batch_size);
    }

    /**
     * Message receive batch size here is essential for push consumer.
     *
     * Generated from protobuf field <code>optional int32 receive_batch_size = 4;</code>
     * @param int $var
     * @return $this
     */
    public function setReceiveBatchSize($var)
    {
        GPBUtil::checkInt32($var);
        $this->receive_batch_size = $var;

        return $this;
    }

    /**
     * Long-polling timeout for `ReceiveMessageRequest`, which is essential for
     * push consumer.
     *
     * Generated from protobuf field <code>optional .google.protobuf.Duration long_polling_timeout = 5;</code>
     * @return \Google\Protobuf\Duration|null
     */
    public function getLongPollingTimeout()
    {
        return $this->long_polling_timeout;
    }

    public function hasLongPollingTimeout()
    {
        return isset($this->long_polling_timeout);
    }

    public function clearLongPollingTimeout()
    {
        unset($this->long_polling_timeout);
    }

    /**
     * Long-polling timeout for `ReceiveMessageRequest`, which is essential for
     * push consumer.
     *
     * Generated from protobuf field <code>optional .google.protobuf.Duration long_polling_timeout = 5;</code>
     * @param \Google\Protobuf\Duration $var
     * @return $this
     */
    public function setLongPollingTimeout($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class);
        $this->long_polling_timeout = $var;

        return $this;
    }

}

