All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scalapb.fs2.pubsub.grpc.internal.ReceivedMessage.scala Maven / Gradle / Ivy

// Generated by the Scala Plugin for the Protocol Buffer Compiler.
// Do not edit!
//
// Protofile syntax: PROTO3

package fs2.pubsub.grpc.internal

/** A message and its corresponding acknowledgment ID.
  *
  * @param ackId
  *   Optional. This ID can be used to acknowledge the received message.
  * @param message
  *   Optional. The message.
  * @param deliveryAttempt
  *   Optional. The approximate number of times that Pub/Sub has attempted to
  *   deliver the associated message to a subscriber.
  *  
  *   More precisely, this is 1 + (number of NACKs) +
  *   (number of ack_deadline exceeds) for this message.
  *  
  *   A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
  *   exceeds event is whenever a message is not acknowledged within
  *   ack_deadline. Note that ack_deadline is initially
  *   Subscription.ackDeadlineSeconds, but may get extended automatically by
  *   the client library.
  *  
  *   Upon the first delivery of a given message, `delivery_attempt` will have a
  *   value of 1. The value is calculated at best effort and is approximate.
  *  
  *   If a DeadLetterPolicy is not set on the subscription, this will be 0.
  */
@SerialVersionUID(0L)
@scala.annotation.nowarn private[grpc]
final case class ReceivedMessage(
    ackId: _root_.scala.Predef.String = "",
    message: _root_.scala.Option[fs2.pubsub.grpc.internal.PubsubMessage] = _root_.scala.None,
    deliveryAttempt: _root_.scala.Int = 0,
    unknownFields: _root_.scalapb.UnknownFieldSet = _root_.scalapb.UnknownFieldSet.empty
    ) extends scalapb.GeneratedMessage with scalapb.lenses.Updatable[ReceivedMessage] {
    @transient
    private[this] var __serializedSizeMemoized: _root_.scala.Int = 0
    private[this] def __computeSerializedSize(): _root_.scala.Int = {
      var __size = 0
      
      {
        val __value = ackId
        if (!__value.isEmpty) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeStringSize(1, __value)
        }
      };
      if (message.isDefined) {
        val __value = message.get
        __size += 1 + _root_.com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__value.serializedSize) + __value.serializedSize
      };
      
      {
        val __value = deliveryAttempt
        if (__value != 0) {
          __size += _root_.com.google.protobuf.CodedOutputStream.computeInt32Size(3, __value)
        }
      };
      __size += unknownFields.serializedSize
      __size
    }
    override def serializedSize: _root_.scala.Int = {
      var __size = __serializedSizeMemoized
      if (__size == 0) {
        __size = __computeSerializedSize() + 1
        __serializedSizeMemoized = __size
      }
      __size - 1
      
    }
    def writeTo(`_output__`: _root_.com.google.protobuf.CodedOutputStream): _root_.scala.Unit = {
      {
        val __v = ackId
        if (!__v.isEmpty) {
          _output__.writeString(1, __v)
        }
      };
      message.foreach { __v =>
        val __m = __v
        _output__.writeTag(2, 2)
        _output__.writeUInt32NoTag(__m.serializedSize)
        __m.writeTo(_output__)
      };
      {
        val __v = deliveryAttempt
        if (__v != 0) {
          _output__.writeInt32(3, __v)
        }
      };
      unknownFields.writeTo(_output__)
    }
    def withAckId(__v: _root_.scala.Predef.String): ReceivedMessage = copy(ackId = __v)
    def getMessage: fs2.pubsub.grpc.internal.PubsubMessage = message.getOrElse(fs2.pubsub.grpc.internal.PubsubMessage.defaultInstance)
    def clearMessage: ReceivedMessage = copy(message = _root_.scala.None)
    def withMessage(__v: fs2.pubsub.grpc.internal.PubsubMessage): ReceivedMessage = copy(message = Option(__v))
    def withDeliveryAttempt(__v: _root_.scala.Int): ReceivedMessage = copy(deliveryAttempt = __v)
    def withUnknownFields(__v: _root_.scalapb.UnknownFieldSet) = copy(unknownFields = __v)
    def discardUnknownFields = copy(unknownFields = _root_.scalapb.UnknownFieldSet.empty)
    def getFieldByNumber(__fieldNumber: _root_.scala.Int): _root_.scala.Any = {
      (__fieldNumber: @_root_.scala.unchecked) match {
        case 1 => {
          val __t = ackId
          if (__t != "") __t else null
        }
        case 2 => message.orNull
        case 3 => {
          val __t = deliveryAttempt
          if (__t != 0) __t else null
        }
      }
    }
    def getField(__field: _root_.scalapb.descriptors.FieldDescriptor): _root_.scalapb.descriptors.PValue = {
      _root_.scala.Predef.require(__field.containingMessage eq companion.scalaDescriptor)
      (__field.number: @_root_.scala.unchecked) match {
        case 1 => _root_.scalapb.descriptors.PString(ackId)
        case 2 => message.map(_.toPMessage).getOrElse(_root_.scalapb.descriptors.PEmpty)
        case 3 => _root_.scalapb.descriptors.PInt(deliveryAttempt)
      }
    }
    def toProtoString: _root_.scala.Predef.String = _root_.scalapb.TextFormat.printToUnicodeString(this)
    def companion: fs2.pubsub.grpc.internal.ReceivedMessage.type = fs2.pubsub.grpc.internal.ReceivedMessage
    // @@protoc_insertion_point(GeneratedMessage[google.pubsub.v1.ReceivedMessage])
}

@scala.annotation.nowarn private[grpc]
object ReceivedMessage extends scalapb.GeneratedMessageCompanion[fs2.pubsub.grpc.internal.ReceivedMessage] {
  implicit def messageCompanion: scalapb.GeneratedMessageCompanion[fs2.pubsub.grpc.internal.ReceivedMessage] = this
  def parseFrom(`_input__`: _root_.com.google.protobuf.CodedInputStream): fs2.pubsub.grpc.internal.ReceivedMessage = {
    var __ackId: _root_.scala.Predef.String = ""
    var __message: _root_.scala.Option[fs2.pubsub.grpc.internal.PubsubMessage] = _root_.scala.None
    var __deliveryAttempt: _root_.scala.Int = 0
    var `_unknownFields__`: _root_.scalapb.UnknownFieldSet.Builder = null
    var _done__ = false
    while (!_done__) {
      val _tag__ = _input__.readTag()
      _tag__ match {
        case 0 => _done__ = true
        case 10 =>
          __ackId = _input__.readStringRequireUtf8()
        case 18 =>
          __message = Option(__message.fold(_root_.scalapb.LiteParser.readMessage[fs2.pubsub.grpc.internal.PubsubMessage](_input__))(_root_.scalapb.LiteParser.readMessage(_input__, _)))
        case 24 =>
          __deliveryAttempt = _input__.readInt32()
        case tag =>
          if (_unknownFields__ == null) {
            _unknownFields__ = new _root_.scalapb.UnknownFieldSet.Builder()
          }
          _unknownFields__.parseField(tag, _input__)
      }
    }
    fs2.pubsub.grpc.internal.ReceivedMessage(
        ackId = __ackId,
        message = __message,
        deliveryAttempt = __deliveryAttempt,
        unknownFields = if (_unknownFields__ == null) _root_.scalapb.UnknownFieldSet.empty else _unknownFields__.result()
    )
  }
  implicit def messageReads: _root_.scalapb.descriptors.Reads[fs2.pubsub.grpc.internal.ReceivedMessage] = _root_.scalapb.descriptors.Reads{
    case _root_.scalapb.descriptors.PMessage(__fieldsMap) =>
      _root_.scala.Predef.require(__fieldsMap.keys.forall(_.containingMessage eq scalaDescriptor), "FieldDescriptor does not match message type.")
      fs2.pubsub.grpc.internal.ReceivedMessage(
        ackId = __fieldsMap.get(scalaDescriptor.findFieldByNumber(1).get).map(_.as[_root_.scala.Predef.String]).getOrElse(""),
        message = __fieldsMap.get(scalaDescriptor.findFieldByNumber(2).get).flatMap(_.as[_root_.scala.Option[fs2.pubsub.grpc.internal.PubsubMessage]]),
        deliveryAttempt = __fieldsMap.get(scalaDescriptor.findFieldByNumber(3).get).map(_.as[_root_.scala.Int]).getOrElse(0)
      )
    case _ => throw new RuntimeException("Expected PMessage")
  }
  def javaDescriptor: _root_.com.google.protobuf.Descriptors.Descriptor = PubsubProto.javaDescriptor.getMessageTypes().get(25)
  def scalaDescriptor: _root_.scalapb.descriptors.Descriptor = PubsubProto.scalaDescriptor.messages(25)
  def messageCompanionForFieldNumber(__number: _root_.scala.Int): _root_.scalapb.GeneratedMessageCompanion[_] = {
    var __out: _root_.scalapb.GeneratedMessageCompanion[_] = null
    (__number: @_root_.scala.unchecked) match {
      case 2 => __out = fs2.pubsub.grpc.internal.PubsubMessage
    }
    __out
  }
  lazy val nestedMessagesCompanions: Seq[_root_.scalapb.GeneratedMessageCompanion[_ <: _root_.scalapb.GeneratedMessage]] = Seq.empty
  def enumCompanionForFieldNumber(__fieldNumber: _root_.scala.Int): _root_.scalapb.GeneratedEnumCompanion[_] = throw new MatchError(__fieldNumber)
  lazy val defaultInstance = fs2.pubsub.grpc.internal.ReceivedMessage(
    ackId = "",
    message = _root_.scala.None,
    deliveryAttempt = 0
  )
  implicit class ReceivedMessageLens[UpperPB](_l: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.ReceivedMessage]) extends _root_.scalapb.lenses.ObjectLens[UpperPB, fs2.pubsub.grpc.internal.ReceivedMessage](_l) {
    def ackId: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Predef.String] = field(_.ackId)((c_, f_) => c_.copy(ackId = f_))
    def message: _root_.scalapb.lenses.Lens[UpperPB, fs2.pubsub.grpc.internal.PubsubMessage] = field(_.getMessage)((c_, f_) => c_.copy(message = Option(f_)))
    def optionalMessage: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Option[fs2.pubsub.grpc.internal.PubsubMessage]] = field(_.message)((c_, f_) => c_.copy(message = f_))
    def deliveryAttempt: _root_.scalapb.lenses.Lens[UpperPB, _root_.scala.Int] = field(_.deliveryAttempt)((c_, f_) => c_.copy(deliveryAttempt = f_))
  }
  final val ACK_ID_FIELD_NUMBER = 1
  final val MESSAGE_FIELD_NUMBER = 2
  final val DELIVERY_ATTEMPT_FIELD_NUMBER = 3
  def of(
    ackId: _root_.scala.Predef.String,
    message: _root_.scala.Option[fs2.pubsub.grpc.internal.PubsubMessage],
    deliveryAttempt: _root_.scala.Int
  ): _root_.fs2.pubsub.grpc.internal.ReceivedMessage = _root_.fs2.pubsub.grpc.internal.ReceivedMessage(
    ackId,
    message,
    deliveryAttempt
  )
  // @@protoc_insertion_point(GeneratedMessageCompanion[google.pubsub.v1.ReceivedMessage])
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy