import * as grpc from "@grpc/grpc-js"; import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import { IAppCallbackServer } from "../../../proto/dapr/proto/runtime/v1/appcallback_grpc_pb"; import { InvokeRequest, InvokeResponse } from "../../../proto/dapr/proto/common/v1/common_pb"; import { BindingEventRequest, BindingEventResponse, ListInputBindingsResponse, ListTopicSubscriptionsResponse, TopicEventRequest, TopicEventResponse, TopicEventBulkRequest, TopicEventBulkResponse } from "../../../proto/dapr/proto/runtime/v1/appcallback_pb"; import { TypeDaprBindingCallback } from "../../../types/DaprBindingCallback.type"; import { TypeDaprPubSubCallback } from "../../../types/DaprPubSubCallback.type"; import { LoggerOptions } from "../../../types/logger/LoggerOptions"; import { PubSubSubscriptionOptionsType } from "../../../types/pubsub/PubSubSubscriptionOptions.type"; import { IServerType } from "./GRPCServer"; import { DaprInvokerCallbackFunction } from "../../../types/DaprInvokerCallback.type"; import { PubSubSubscriptionTopicRouteType } from "../../../types/pubsub/PubSubSubscriptionTopicRoute.type"; import DaprPubSubStatusEnum from "../../../enum/DaprPubSubStatus.enum"; import { PubSubSubscriptionsType } from "../../../types/pubsub/PubSubSubscriptions.type"; export default class GRPCServerImpl implements IAppCallbackServer { private readonly logger; private readonly subscriptionManager; handlersInvoke: { [key: string]: DaprInvokerCallbackFunction; }; handlersBindings: { [key: string]: TypeDaprBindingCallback; }; constructor(_server: IServerType, loggerOptions?: LoggerOptions); createInputBindingHandlerKey(bindingName: string): string; createOnInvokeHandlerKey(httpMethod: string, methodName: string): string; registerOnInvokeHandler(httpMethod: string, methodName: string, cb: DaprInvokerCallbackFunction): void; /** * When we subscribe, we subscribe to a topic * For this topic we can define "routes" which route to a certain callback depending on the event content * Each of these topics are handled by a EventHandler but there can be multiple handlers per pubsubname-topic-route combination * * We don't create the EventHandlers here but we ensure that the routes are registered and can receive POST events * -> we create POST / endpoints for each, but we create them uniquely! * -> to ensure uniqueness, we just check if this.pubsubRouteEventHandlers[route] is set * * @param pubSubName * @param topicName * @param cb * @param options */ registerPubsubSubscription(pubsubName: string, topic: string, options?: PubSubSubscriptionOptionsType): void; registerPubSubSubscriptionEventHandler(pubsubName: string, topic: string, route: string | undefined, cb: TypeDaprPubSubCallback): void; registerInputBindingHandler(bindingName: string, cb: DaprInvokerCallbackFunction): void; getSubscriptions(): PubSubSubscriptionsType; onInvoke(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise; onBindingEvent(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise; onTopicEvent(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise; onBulkTopicEventAlpha1(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise; processPubSubCallbacks(routeObj: PubSubSubscriptionTopicRouteType, data: any, headers: { [key: string]: string; }): Promise; listTopicSubscriptions(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise; listInputBindings(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData): Promise; }