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

org.xmtp.proto.message.api.v1.MessageApiOuterClassGrpcKt.kt Maven / Gradle / Ivy

There is a newer version: 3.70.1
Show newest version
package org.xmtp.proto.message.api.v1

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.bidiStreamingRpc
import io.grpc.kotlin.ClientCalls.serverStreamingRpc
import io.grpc.kotlin.ClientCalls.unaryRpc
import io.grpc.kotlin.ServerCalls
import io.grpc.kotlin.ServerCalls.bidiStreamingServerMethodDefinition
import io.grpc.kotlin.ServerCalls.serverStreamingServerMethodDefinition
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
import kotlinx.coroutines.flow.Flow
import org.xmtp.proto.message.api.v1.MessageApiGrpc.getServiceDescriptor

/**
 * Holder for Kotlin coroutine-based client and server APIs for xmtp.message_api.v1.MessageApi.
 */
public object MessageApiGrpcKt {
  public const val SERVICE_NAME: String = MessageApiGrpc.SERVICE_NAME

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

  public val publishMethod:
      MethodDescriptor
    @JvmStatic
    get() = MessageApiGrpc.getPublishMethod()

  public val subscribeMethod:
      MethodDescriptor
    @JvmStatic
    get() = MessageApiGrpc.getSubscribeMethod()

  public val subscribe2Method:
      MethodDescriptor
    @JvmStatic
    get() = MessageApiGrpc.getSubscribe2Method()

  public val subscribeAllMethod:
      MethodDescriptor
    @JvmStatic
    get() = MessageApiGrpc.getSubscribeAllMethod()

  public val queryMethod:
      MethodDescriptor
    @JvmStatic
    get() = MessageApiGrpc.getQueryMethod()

  public val batchQueryMethod:
      MethodDescriptor
    @JvmStatic
    get() = MessageApiGrpc.getBatchQueryMethod()

  /**
   * A stub for issuing RPCs to a(n) xmtp.message_api.v1.MessageApi service as suspending
   * coroutines.
   */
  @StubFor(MessageApiGrpc::class)
  public class MessageApiCoroutineStub @JvmOverloads constructor(
    channel: Channel,
    callOptions: CallOptions = DEFAULT,
  ) : AbstractCoroutineStub(channel, callOptions) {
    public override fun build(channel: Channel, callOptions: CallOptions): MessageApiCoroutineStub =
        MessageApiCoroutineStub(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.
     */
    public suspend fun publish(request: MessageApiOuterClass.PublishRequest, headers: Metadata =
        Metadata()): MessageApiOuterClass.PublishResponse = unaryRpc(
      channel,
      MessageApiGrpc.getPublishMethod(),
      request,
      callOptions,
      headers
    )

    /**
     * Returns a [Flow] that, when collected, executes this RPC and emits responses from the
     * server as they arrive.  That flow finishes normally if the server closes its response with
     * [`Status.OK`][Status], and fails by throwing a [StatusException] otherwise.  If
     * collecting the flow downstream fails exceptionally (including via cancellation), the RPC
     * is cancelled with that 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 A flow that, when collected, emits the responses from the server.
     */
    public fun subscribe(request: MessageApiOuterClass.SubscribeRequest, headers: Metadata =
        Metadata()): Flow = serverStreamingRpc(
      channel,
      MessageApiGrpc.getSubscribeMethod(),
      request,
      callOptions,
      headers
    )

    /**
     * Returns a [Flow] that, when collected, executes this RPC and emits responses from the
     * server as they arrive.  That flow finishes normally if the server closes its response with
     * [`Status.OK`][Status], and fails by throwing a [StatusException] otherwise.  If
     * collecting the flow downstream fails exceptionally (including via cancellation), the RPC
     * is cancelled with that exception as a cause.
     *
     * The [Flow] of requests is collected once each time the [Flow] of responses is
     * collected. If collection of the [Flow] of responses completes normally or
     * exceptionally before collection of `requests` completes, the collection of
     * `requests` is cancelled.  If the collection of `requests` completes
     * exceptionally for any other reason, then the collection of the [Flow] of responses
     * completes exceptionally for the same reason and the RPC is cancelled with that reason.
     *
     * @param requests A [Flow] of request messages.
     *
     * @param headers Metadata to attach to the request.  Most users will not need this.
     *
     * @return A flow that, when collected, emits the responses from the server.
     */
    public fun subscribe2(requests: Flow, headers: Metadata =
        Metadata()): Flow = bidiStreamingRpc(
      channel,
      MessageApiGrpc.getSubscribe2Method(),
      requests,
      callOptions,
      headers
    )

    /**
     * Returns a [Flow] that, when collected, executes this RPC and emits responses from the
     * server as they arrive.  That flow finishes normally if the server closes its response with
     * [`Status.OK`][Status], and fails by throwing a [StatusException] otherwise.  If
     * collecting the flow downstream fails exceptionally (including via cancellation), the RPC
     * is cancelled with that 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 A flow that, when collected, emits the responses from the server.
     */
    public fun subscribeAll(request: MessageApiOuterClass.SubscribeAllRequest, headers: Metadata =
        Metadata()): Flow = serverStreamingRpc(
      channel,
      MessageApiGrpc.getSubscribeAllMethod(),
      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.
     */
    public suspend fun query(request: MessageApiOuterClass.QueryRequest, headers: Metadata =
        Metadata()): MessageApiOuterClass.QueryResponse = unaryRpc(
      channel,
      MessageApiGrpc.getQueryMethod(),
      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.
     */
    public suspend fun batchQuery(request: MessageApiOuterClass.BatchQueryRequest, headers: Metadata
        = Metadata()): MessageApiOuterClass.BatchQueryResponse = unaryRpc(
      channel,
      MessageApiGrpc.getBatchQueryMethod(),
      request,
      callOptions,
      headers
    )
  }

  /**
   * Skeletal implementation of the xmtp.message_api.v1.MessageApi service based on Kotlin
   * coroutines.
   */
  public abstract class MessageApiCoroutineImplBase(
    coroutineContext: CoroutineContext = EmptyCoroutineContext,
  ) : AbstractCoroutineServerImpl(coroutineContext) {
    /**
     * Returns the response to an RPC for xmtp.message_api.v1.MessageApi.Publish.
     *
     * 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.
     */
    public open suspend fun publish(request: MessageApiOuterClass.PublishRequest):
        MessageApiOuterClass.PublishResponse = throw
        StatusException(UNIMPLEMENTED.withDescription("Method xmtp.message_api.v1.MessageApi.Publish is unimplemented"))

    /**
     * Returns a [Flow] of responses to an RPC for xmtp.message_api.v1.MessageApi.Subscribe.
     *
     * If creating or collecting the returned flow fails with a [StatusException], the RPC
     * will fail with the corresponding [Status].  If it fails with a
     * [java.util.concurrent.CancellationException], the RPC will fail with status
     * `Status.CANCELLED`.  If creating
     * or collecting the returned flow 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.
     */
    public open fun subscribe(request: MessageApiOuterClass.SubscribeRequest):
        Flow = throw
        StatusException(UNIMPLEMENTED.withDescription("Method xmtp.message_api.v1.MessageApi.Subscribe is unimplemented"))

    /**
     * Returns a [Flow] of responses to an RPC for xmtp.message_api.v1.MessageApi.Subscribe2.
     *
     * If creating or collecting the returned flow fails with a [StatusException], the RPC
     * will fail with the corresponding [Status].  If it fails with a
     * [java.util.concurrent.CancellationException], the RPC will fail with status
     * `Status.CANCELLED`.  If creating
     * or collecting the returned flow fails for any other reason, the RPC will fail with
     * `Status.UNKNOWN` with the exception as a cause.
     *
     * @param requests A [Flow] of requests from the client.  This flow can be
     *        collected only once and throws [java.lang.IllegalStateException] on attempts to
     * collect
     *        it more than once.
     */
    public open fun subscribe2(requests: Flow):
        Flow = throw
        StatusException(UNIMPLEMENTED.withDescription("Method xmtp.message_api.v1.MessageApi.Subscribe2 is unimplemented"))

    /**
     * Returns a [Flow] of responses to an RPC for xmtp.message_api.v1.MessageApi.SubscribeAll.
     *
     * If creating or collecting the returned flow fails with a [StatusException], the RPC
     * will fail with the corresponding [Status].  If it fails with a
     * [java.util.concurrent.CancellationException], the RPC will fail with status
     * `Status.CANCELLED`.  If creating
     * or collecting the returned flow 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.
     */
    public open fun subscribeAll(request: MessageApiOuterClass.SubscribeAllRequest):
        Flow = throw
        StatusException(UNIMPLEMENTED.withDescription("Method xmtp.message_api.v1.MessageApi.SubscribeAll is unimplemented"))

    /**
     * Returns the response to an RPC for xmtp.message_api.v1.MessageApi.Query.
     *
     * 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.
     */
    public open suspend fun query(request: MessageApiOuterClass.QueryRequest):
        MessageApiOuterClass.QueryResponse = throw
        StatusException(UNIMPLEMENTED.withDescription("Method xmtp.message_api.v1.MessageApi.Query is unimplemented"))

    /**
     * Returns the response to an RPC for xmtp.message_api.v1.MessageApi.BatchQuery.
     *
     * 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.
     */
    public open suspend fun batchQuery(request: MessageApiOuterClass.BatchQueryRequest):
        MessageApiOuterClass.BatchQueryResponse = throw
        StatusException(UNIMPLEMENTED.withDescription("Method xmtp.message_api.v1.MessageApi.BatchQuery is unimplemented"))

    public final override fun bindService(): ServerServiceDefinition =
        builder(getServiceDescriptor())
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = MessageApiGrpc.getPublishMethod(),
      implementation = ::publish
    ))
      .addMethod(serverStreamingServerMethodDefinition(
      context = this.context,
      descriptor = MessageApiGrpc.getSubscribeMethod(),
      implementation = ::subscribe
    ))
      .addMethod(bidiStreamingServerMethodDefinition(
      context = this.context,
      descriptor = MessageApiGrpc.getSubscribe2Method(),
      implementation = ::subscribe2
    ))
      .addMethod(serverStreamingServerMethodDefinition(
      context = this.context,
      descriptor = MessageApiGrpc.getSubscribeAllMethod(),
      implementation = ::subscribeAll
    ))
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = MessageApiGrpc.getQueryMethod(),
      implementation = ::query
    ))
      .addMethod(unaryServerMethodDefinition(
      context = this.context,
      descriptor = MessageApiGrpc.getBatchQueryMethod(),
      implementation = ::batchQuery
    )).build()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy