import type { Event, EventPayload } from "./event.js"; import type { FunctionBundleProps, FunctionRuntimeProps } from "./function-props.js"; import { SourceLocation } from "./internal/service-spec.js"; import { ServiceContext } from "./service.js"; export interface SubscriptionContext { /** *Information about the containing service. */ service: ServiceContext; } /** * A Function that processes an {@link event} of type {@link E}. */ export type SubscriptionHandler = (event: E, context: SubscriptionContext) => Promise | void; /** * Runtime Props for an Event Handler. */ export interface SubscriptionRuntimeProps extends FunctionRuntimeProps, FunctionBundleProps { /** * Number of times an event can be re-driven to the Event Handler before considering * the Event as failed to process and sending it to the Service Dead Letter Queue. * * Minimum value of `0`. * Maximum value of `185`. * * @default 185 */ retryAttempts?: number; } export interface SubscriptionProps extends SubscriptionRuntimeProps { /** * Events to subscribe to. */ events: Event[]; } export interface Subscription { kind: "Subscription"; /** * Unique name of this Subscription. */ name: Name; /** * The Handler Function for processing the Events. */ handler: SubscriptionHandler; /** * Subscriptions this Event Handler is subscribed to. Any event flowing * through the Service's Event Bus that match these criteria will be * sent to this Lambda Function. */ filters: SubscriptionFilter[]; /** * Runtime configuration for this Event Handler. */ props?: SubscriptionProps; /** * Only available during eventual-infer. */ sourceLocation?: SourceLocation; } /** * A {@link Subscription} is an object that describes how to select events from * within a service boundary to route to a {@link EventHandlerFunction}. * * For now, we only support matching on a single name, but this object can be * extended with other properties such as selection predicates. */ export interface SubscriptionFilter { /** * Name of the event to subscribe to. */ name: string; } /** * Subscribe to this event. The {@link handler} will be invoked every * time an event with this name is emitted within the service boundary. * * @param handler the handler function that will process the event. */ export declare function subscription(name: Name, props: SubscriptionProps, handlers: SubscriptionHandler): Subscription; //# sourceMappingURL=subscription.d.ts.map