Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.google.bytestream
import com.google.bytestream.ByteStreamGrpc.getServiceDescriptor
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.UNIMPLEMENTED
import io.grpc.StatusException
import io.grpc.kotlin.AbstractCoroutineServerImpl
import io.grpc.kotlin.AbstractCoroutineStub
import io.grpc.kotlin.ClientCalls.clientStreamingRpc
import io.grpc.kotlin.ClientCalls.serverStreamingRpc
import io.grpc.kotlin.ClientCalls.unaryRpc
import io.grpc.kotlin.ServerCalls.clientStreamingServerMethodDefinition
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
/**
* Holder for Kotlin coroutine-based client and server APIs for google.bytestream.ByteStream.
*/
public object ByteStreamGrpcKt {
public const val SERVICE_NAME: String = ByteStreamGrpc.SERVICE_NAME
@JvmStatic
public val serviceDescriptor: ServiceDescriptor
get() = getServiceDescriptor()
public val readMethod: MethodDescriptor
@JvmStatic
get() = ByteStreamGrpc.getReadMethod()
public val writeMethod:
MethodDescriptor
@JvmStatic
get() = ByteStreamGrpc.getWriteMethod()
public val queryWriteStatusMethod:
MethodDescriptor
@JvmStatic
get() = ByteStreamGrpc.getQueryWriteStatusMethod()
/**
* A stub for issuing RPCs to a(n) google.bytestream.ByteStream service as suspending coroutines.
*/
@StubFor(ByteStreamGrpc::class)
public class ByteStreamCoroutineStub @JvmOverloads constructor(
channel: Channel,
callOptions: CallOptions = DEFAULT,
) : AbstractCoroutineStub(channel, callOptions) {
override fun build(channel: Channel, callOptions: CallOptions): ByteStreamCoroutineStub =
ByteStreamCoroutineStub(channel, callOptions)
/**
* 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`][io.grpc.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 read(request: ByteStreamProto.ReadRequest, headers: Metadata = Metadata()):
Flow = serverStreamingRpc(
channel,
ByteStreamGrpc.getReadMethod(),
request,
callOptions,
headers
)
/**
* Executes this RPC and returns the response message, suspending until the RPC completes
* with [`Status.OK`][io.grpc.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.
*
* This function collects the [Flow] of requests. If the server terminates the RPC
* for any reason before collection of requests is complete, the collection of requests
* will be cancelled. If the collection of requests completes exceptionally for any other
* reason, the RPC will be cancelled for that reason and this method will throw that
* exception.
*
* @param requests A [Flow] of request messages.
*
* @param headers Metadata to attach to the request. Most users will not need this.
*
* @return The single response from the server.
*/
public suspend fun write(requests: Flow, headers: Metadata =
Metadata()): ByteStreamProto.WriteResponse = clientStreamingRpc(
channel,
ByteStreamGrpc.getWriteMethod(),
requests,
callOptions,
headers
)
/**
* Executes this RPC and returns the response message, suspending until the RPC completes
* with [`Status.OK`][io.grpc.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 queryWriteStatus(request: ByteStreamProto.QueryWriteStatusRequest,
headers: Metadata = Metadata()): ByteStreamProto.QueryWriteStatusResponse = unaryRpc(
channel,
ByteStreamGrpc.getQueryWriteStatusMethod(),
request,
callOptions,
headers
)
}
/**
* Skeletal implementation of the google.bytestream.ByteStream service based on Kotlin coroutines.
*/
public abstract class ByteStreamCoroutineImplBase(
coroutineContext: CoroutineContext = EmptyCoroutineContext,
) : AbstractCoroutineServerImpl(coroutineContext) {
/**
* Returns a [Flow] of responses to an RPC for google.bytestream.ByteStream.Read.
*
* If creating or collecting the returned flow fails with a [StatusException], the RPC
* will fail with the corresponding [io.grpc.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 read(request: ByteStreamProto.ReadRequest): Flow =
throw
StatusException(UNIMPLEMENTED.withDescription("Method google.bytestream.ByteStream.Read is unimplemented"))
/**
* Returns the response to an RPC for google.bytestream.ByteStream.Write.
*
* If this method fails with a [StatusException], the RPC will fail with the corresponding
* [io.grpc.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 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 suspend fun write(requests: Flow):
ByteStreamProto.WriteResponse = throw
StatusException(UNIMPLEMENTED.withDescription("Method google.bytestream.ByteStream.Write is unimplemented"))
/**
* Returns the response to an RPC for google.bytestream.ByteStream.QueryWriteStatus.
*
* If this method fails with a [StatusException], the RPC will fail with the corresponding
* [io.grpc.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 queryWriteStatus(request: ByteStreamProto.QueryWriteStatusRequest):
ByteStreamProto.QueryWriteStatusResponse = throw
StatusException(UNIMPLEMENTED.withDescription("Method google.bytestream.ByteStream.QueryWriteStatus is unimplemented"))
final override fun bindService(): ServerServiceDefinition = builder(getServiceDescriptor())
.addMethod(serverStreamingServerMethodDefinition(
context = this.context,
descriptor = ByteStreamGrpc.getReadMethod(),
implementation = ::read
))
.addMethod(clientStreamingServerMethodDefinition(
context = this.context,
descriptor = ByteStreamGrpc.getWriteMethod(),
implementation = ::write
))
.addMethod(unaryServerMethodDefinition(
context = this.context,
descriptor = ByteStreamGrpc.getQueryWriteStatusMethod(),
implementation = ::queryWriteStatus
)).build()
}
}