Ctrl K
ComunidadGuías…

bldr/resource/resource_srpc.pb.ts

Rama master · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
// @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/s4wave/spacewave/bldr/resource/resource.proto (package resource, syntax proto3)
/* eslint-disable */

import {
  ResourceAttachRequest,
  ResourceAttachResponse,
  ResourceClientRequest,
  ResourceClientResponse,
  ResourceRpcPacket,
} from './resource.pb.js'
import { MethodKind } from '@aptre/protobuf-es-lite'
import {
  buildDecodeMessageTransform,
  buildEncodeMessageTransform,
  MessageStream,
  ProtoRpc,
  ServerContext,
} from 'starpc'

/**
 * ResourceService provides a set of stateful resources via an RPC service.
 *
 * @generated from service resource.ResourceService
 */
export const ResourceServiceDefinition = {
  typeName: 'resource.ResourceService',
  methods: {
    /**
     * ResourceClient starts an instance of a client for the ResourceService,
     * yielding a new client ID. The client can use that ID for future RPCs
     * accessing the Resource tree. When the streaming RPC ends, references to
     * resources opened by the client will be released.
     *
     * @generated from rpc resource.ResourceService.ResourceClient
     */
    ResourceClient: {
      name: 'ResourceClient',
      I: ResourceClientRequest,
      O: ResourceClientResponse,
      kind: MethodKind.BiDiStreaming,
    },
    /**
     * ResourceRpc is a rpc request for an open resource handle.
     * Exposes service(s) depending on the resource type.
     * The first request selects a resource; one typed acknowledgement precedes data.
     *
     * @generated from rpc resource.ResourceService.ResourceRpc
     */
    ResourceRpc: {
      name: 'ResourceRpc',
      I: ResourceRpcPacket,
      O: ResourceRpcPacket,
      kind: MethodKind.BiDiStreaming,
    },
    /**
     * ResourceAttach allows a client to provide resources that server-side
     * RPC handlers can invoke via getAttachedRef(id). Session-only Init/Ack,
     * then resources registered via Add/AddAck. After Init/Ack, mux_data
     * carries yamux frames for all attached resources.
     *
     * @generated from rpc resource.ResourceService.ResourceAttach
     */
    ResourceAttach: {
      name: 'ResourceAttach',
      I: ResourceAttachRequest,
      O: ResourceAttachResponse,
      kind: MethodKind.BiDiStreaming,
    },
  },
} as const

/**
 * ResourceService provides a set of stateful resources via an RPC service.
 *
 * @generated from service resource.ResourceService
 */
export interface ResourceService {
  /**
   * ResourceClient starts an instance of a client for the ResourceService,
   * yielding a new client ID. The client can use that ID for future RPCs
   * accessing the Resource tree. When the streaming RPC ends, references to
   * resources opened by the client will be released.
   *
   * @generated from rpc resource.ResourceService.ResourceClient
   */
  ResourceClient(
    request: MessageStream<ResourceClientRequest>,
    abortSignal?: AbortSignal,
  ): MessageStream<ResourceClientResponse>

  /**
   * ResourceRpc is a rpc request for an open resource handle.
   * Exposes service(s) depending on the resource type.
   * The first request selects a resource; one typed acknowledgement precedes data.
   *
   * @generated from rpc resource.ResourceService.ResourceRpc
   */
  ResourceRpc(
    request: MessageStream<ResourceRpcPacket>,
    abortSignal?: AbortSignal,
  ): MessageStream<ResourceRpcPacket>

  /**
   * ResourceAttach allows a client to provide resources that server-side
   * RPC handlers can invoke via getAttachedRef(id). Session-only Init/Ack,
   * then resources registered via Add/AddAck. After Init/Ack, mux_data
   * carries yamux frames for all attached resources.
   *
   * @generated from rpc resource.ResourceService.ResourceAttach
   */
  ResourceAttach(
    request: MessageStream<ResourceAttachRequest>,
    abortSignal?: AbortSignal,
  ): MessageStream<ResourceAttachResponse>
}

/**
 * ResourceService provides a set of stateful resources via an RPC service.
 *
 * @generated from service resource.ResourceService
 */
export interface ResourceServiceHandler {
  /**
   * ResourceClient starts an instance of a client for the ResourceService,
   * yielding a new client ID. The client can use that ID for future RPCs
   * accessing the Resource tree. When the streaming RPC ends, references to
   * resources opened by the client will be released.
   *
   * @generated from rpc resource.ResourceService.ResourceClient
   */
  ResourceClient(
    request: MessageStream<ResourceClientRequest>,
    abortSignal: AbortSignal,
    context: ServerContext,
  ): MessageStream<ResourceClientResponse>

  /**
   * ResourceRpc is a rpc request for an open resource handle.
   * Exposes service(s) depending on the resource type.
   * The first request selects a resource; one typed acknowledgement precedes data.
   *
   * @generated from rpc resource.ResourceService.ResourceRpc
   */
  ResourceRpc(
    request: MessageStream<ResourceRpcPacket>,
    abortSignal: AbortSignal,
    context: ServerContext,
  ): MessageStream<ResourceRpcPacket>

  /**
   * ResourceAttach allows a client to provide resources that server-side
   * RPC handlers can invoke via getAttachedRef(id). Session-only Init/Ack,
   * then resources registered via Add/AddAck. After Init/Ack, mux_data
   * carries yamux frames for all attached resources.
   *
   * @generated from rpc resource.ResourceService.ResourceAttach
   */
  ResourceAttach(
    request: MessageStream<ResourceAttachRequest>,
    abortSignal: AbortSignal,
    context: ServerContext,
  ): MessageStream<ResourceAttachResponse>
}

export const ResourceServiceServiceName = ResourceServiceDefinition.typeName

export class ResourceServiceClient implements ResourceService {
  private readonly rpc: ProtoRpc
  private readonly service: string
  constructor(rpc: ProtoRpc, opts?: { service?: string }) {
    this.service = opts?.service || ResourceServiceServiceName
    this.rpc = rpc
    this.ResourceClient = this.ResourceClient.bind(this)
    this.ResourceRpc = this.ResourceRpc.bind(this)
    this.ResourceAttach = this.ResourceAttach.bind(this)
  }
  /**
   * ResourceClient starts an instance of a client for the ResourceService,
   * yielding a new client ID. The client can use that ID for future RPCs
   * accessing the Resource tree. When the streaming RPC ends, references to
   * resources opened by the client will be released.
   *
   * @generated from rpc resource.ResourceService.ResourceClient
   */
  ResourceClient(
    request: MessageStream<ResourceClientRequest>,
    abortSignal?: AbortSignal,
  ): MessageStream<ResourceClientResponse> {
    const result = this.rpc.bidirectionalStreamingRequest(
      this.service,
      ResourceServiceDefinition.methods.ResourceClient.name,
      buildEncodeMessageTransform(ResourceClientRequest)(request),
      abortSignal || undefined,
    )
    return buildDecodeMessageTransform(ResourceClientResponse)(result)
  }

  /**
   * ResourceRpc is a rpc request for an open resource handle.
   * Exposes service(s) depending on the resource type.
   * The first request selects a resource; one typed acknowledgement precedes data.
   *
   * @generated from rpc resource.ResourceService.ResourceRpc
   */
  ResourceRpc(
    request: MessageStream<ResourceRpcPacket>,
    abortSignal?: AbortSignal,
  ): MessageStream<ResourceRpcPacket> {
    const result = this.rpc.bidirectionalStreamingRequest(
      this.service,
      ResourceServiceDefinition.methods.ResourceRpc.name,
      buildEncodeMessageTransform(ResourceRpcPacket)(request),
      abortSignal || undefined,
    )
    return buildDecodeMessageTransform(ResourceRpcPacket)(result)
  }

  /**
   * ResourceAttach allows a client to provide resources that server-side
   * RPC handlers can invoke via getAttachedRef(id). Session-only Init/Ack,
   * then resources registered via Add/AddAck. After Init/Ack, mux_data
   * carries yamux frames for all attached resources.
   *
   * @generated from rpc resource.ResourceService.ResourceAttach
   */
  ResourceAttach(
    request: MessageStream<ResourceAttachRequest>,
    abortSignal?: AbortSignal,
  ): MessageStream<ResourceAttachResponse> {
    const result = this.rpc.bidirectionalStreamingRequest(
      this.service,
      ResourceServiceDefinition.methods.ResourceAttach.name,
      buildEncodeMessageTransform(ResourceAttachRequest)(request),
      abortSignal || undefined,
    )
    return buildDecodeMessageTransform(ResourceAttachResponse)(result)
  }
}