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

games.mythical.saga.sdk.proto.api.offer.RpcGrpcKt.kt Maven / Gradle / Ivy

There is a newer version: 1.1.30
Show newest version
package games.mythical.saga.sdk.proto.api.offer

import games.mythical.saga.sdk.proto.api.offer.OfferServiceGrpc.getServiceDescriptor
import games.mythical.saga.sdk.proto.common.ReceivedResponse
import io.grpc.CallOptions
import io.grpc.CallOptions.DEFAULT
import io.grpc.Channel
import io.grpc.Metadata
import io.grpc.MethodDescriptor
import io.grpc.ServerServiceDefinition
import io.grpc.ServerServiceDefinition.builder
import io.grpc.ServiceDescriptor
import io.grpc.Status
import io.grpc.Status.UNIMPLEMENTED
import io.grpc.StatusException
import io.grpc.kotlin.AbstractCoroutineServerImpl
import io.grpc.kotlin.AbstractCoroutineStub
import io.grpc.kotlin.ClientCalls
import io.grpc.kotlin.ClientCalls.unaryRpc
import io.grpc.kotlin.ServerCalls
import io.grpc.kotlin.ServerCalls.unaryServerMethodDefinition
import io.grpc.kotlin.StubFor
import kotlin.String
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.jvm.JvmOverloads
import kotlin.jvm.JvmStatic

/**
 * Holder for Kotlin coroutine-based client and server APIs for saga.api.offer.OfferService.
 */
object OfferServiceGrpcKt {
  const val SERVICE_NAME: String = OfferServiceGrpc.SERVICE_NAME

  @JvmStatic
  val serviceDescriptor: ServiceDescriptor
    get() = OfferServiceGrpc.getServiceDescriptor()

  val createOfferQuoteMethod: MethodDescriptor
    @JvmStatic
    get() = OfferServiceGrpc.getCreateOfferQuoteMethod()

  val confirmOfferMethod: MethodDescriptor
    @JvmStatic
    get() = OfferServiceGrpc.getConfirmOfferMethod()

  val cancelOfferMethod: MethodDescriptor
    @JvmStatic
    get() = OfferServiceGrpc.getCancelOfferMethod()

  val getOffersMethod: MethodDescriptor
    @JvmStatic
    get() = OfferServiceGrpc.getGetOffersMethod()

  /**
   * A stub for issuing RPCs to a(n) saga.api.offer.OfferService service as suspending coroutines.
   */
  @StubFor(OfferServiceGrpc::class)
  class OfferServiceCoroutineStub @JvmOverloads constructor(
    channel: Channel,
    callOptions: CallOptions = DEFAULT
  ) : AbstractCoroutineStub(channel, callOptions) {
    override fun build(channel: Channel, callOptions: CallOptions): OfferServiceCoroutineStub =
        OfferServiceCoroutineStub(channel, callOptions)

    /**
     * Executes this RPC and returns the response message, suspending until the RPC completes
     * with [`Status.OK`][Status].  If the RPC completes with another status, a corresponding
     * [StatusException] is thrown.  If this coroutine is cancelled, the RPC is also cancelled
     * with the corresponding exception as a cause.
     *
     * @param request The request message to send to the server.
     *
     * @param headers Metadata to attach to the request.  Most users will not need this.
     *
     * @return The single response from the server.
     */
    suspend fun createOfferQuote(request: CreateOfferQuoteRequest, headers: Metadata = Metadata()):
        ReceivedResponse = unaryRpc(
      channel,
      OfferServiceGrpc.getCreateOfferQuoteMethod(),
      request,
      callOptions,
      headers
    )
    /**
     * Executes this RPC and returns the response message, suspending until the RPC completes
     * with [`Status.OK`][Status].  If the RPC completes with another status, a corresponding
     * [StatusException] is thrown.  If this coroutine is cancelled, the RPC is also cancelled
     * with the corresponding exception as a cause.
     *
     * @param request The request message to send to the server.
     *
     * @param headers Metadata to attach to the request.  Most users will not need this.
     *
     * @return The single response from the server.
     */
    suspend fun confirmOffer(request: ConfirmOfferRequest, headers: Metadata = Metadata()):
        ReceivedResponse = unaryRpc(
      channel,
      OfferServiceGrpc.getConfirmOfferMethod(),
      request,
      callOptions,
      headers
    )
    /**
     * Executes this RPC and returns the response message, suspending until the RPC completes
     * with [`Status.OK`][Status].  If the RPC completes with another status, a corresponding
     * [StatusException] is thrown.  If this coroutine is cancelled, the RPC is also cancelled
     * with the corresponding exception as a cause.
     *
     * @param request The request message to send to the server.
     *
     * @param headers Metadata to attach to the request.  Most users will not need this.
     *
     * @return The single response from the server.
     */
    suspend fun cancelOffer(request: CancelOfferRequest, headers: Metadata = Metadata()):
        ReceivedResponse = unaryRpc(
      channel,
      OfferServiceGrpc.getCancelOfferMethod(),
      request,
      callOptions,
      headers
    )
    /**
     * Executes this RPC and returns the response message, suspending until the RPC completes
     * with [`Status.OK`][Status].  If the RPC completes with another status, a corresponding
     * [StatusException] is thrown.  If this coroutine is cancelled, the RPC is also cancelled
     * with the corresponding exception as a cause.
     *
     * @param request The request message to send to the server.
     *
     * @param headers Metadata to attach to the request.  Most users will not need this.
     *
     * @return The single response from the server.
     */
    suspend fun getOffers(request: GetOffersRequest, headers: Metadata = Metadata()): OffersProto =
        unaryRpc(
      channel,
      OfferServiceGrpc.getGetOffersMethod(),
      request,
      callOptions,
      headers
    )}

  /**
   * Skeletal implementation of the saga.api.offer.OfferService service based on Kotlin coroutines.
   */
  abstract class OfferServiceCoroutineImplBase(
    coroutineContext: CoroutineContext = EmptyCoroutineContext
  ) : AbstractCoroutineServerImpl(coroutineContext) {
    /**
     * Returns the response to an RPC for saga.api.offer.OfferService.CreateOfferQuote.
     *
     * If this method fails with a [StatusException], the RPC will fail with the corresponding
     * [Status].  If this method fails with a [java.util.concurrent.CancellationException], the RPC
     * will fail
     * with status `Status.CANCELLED`.  If this method fails for any other reason, the RPC will
     * fail with `Status.UNKNOWN` with the exception as a cause.
     *
     * @param request The request from the client.
     */
    open suspend fun createOfferQuote(request: CreateOfferQuoteRequest): ReceivedResponse = throw
        StatusException(UNIMPLEMENTED.withDescription("Method saga.api.offer.OfferService.CreateOfferQuote is unimplemented"))

    /**
     * Returns the response to an RPC for saga.api.offer.OfferService.ConfirmOffer.
     *
     * If this method fails with a [StatusException], the RPC will fail with the corresponding
     * [Status].  If this method fails with a [java.util.concurrent.CancellationException], the RPC
     * will fail
     * with status `Status.CANCELLED`.  If this method fails for any other reason, the RPC will
     * fail with `Status.UNKNOWN` with the exception as a cause.
     *
     * @param request The request from the client.
     */
    open suspend fun confirmOffer(request: ConfirmOfferRequest): ReceivedResponse = throw
        StatusException(UNIMPLEMENTED.withDescription("Method saga.api.offer.OfferService.ConfirmOffer is unimplemented"))

    /**
     * Returns the response to an RPC for saga.api.offer.OfferService.CancelOffer.
     *
     * If this method fails with a [StatusException], the RPC will fail with the corresponding
     * [Status].  If this method fails with a [java.util.concurrent.CancellationException], the RPC
     * will fail
     * with status `Status.CANCELLED`.  If this method fails for any other reason, the RPC will
     * fail with `Status.UNKNOWN` with the exception as a cause.
     *
     * @param request The request from the client.
     */
    open suspend fun cancelOffer(request: CancelOfferRequest): ReceivedResponse = throw
        StatusException(UNIMPLEMENTED.withDescription("Method saga.api.offer.OfferService.CancelOffer is unimplemented"))

    /**
     * Returns the response to an RPC for saga.api.offer.OfferService.GetOffers.
     *
     * If this method fails with a [StatusException], the RPC will fail with the corresponding
     * [Status].  If this method fails with a [java.util.concurrent.CancellationException], the RPC
     * will fail
     * with status `Status.CANCELLED`.  If this method fails for any other reason, the RPC will
     * fail with `Status.UNKNOWN` with the exception as a cause.
     *
     * @param request The request from the client.
     */
    open suspend fun getOffers(request: GetOffersRequest): OffersProto = throw
        StatusException(UNIMPLEMENTED.withDescription("Method saga.api.offer.OfferService.GetOffers is unimplemented"))

    final override fun bindService(): ServerServiceDefinition = builder(getServiceDescriptor())
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = OfferServiceGrpc.getCreateOfferQuoteMethod(),
      implementation = ::createOfferQuote
    ))
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = OfferServiceGrpc.getConfirmOfferMethod(),
      implementation = ::confirmOffer
    ))
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = OfferServiceGrpc.getCancelOfferMethod(),
      implementation = ::cancelOffer
    ))
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = OfferServiceGrpc.getGetOffersMethod(),
      implementation = ::getOffers
    )).build()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy