hud-sdk
Version:
Hud's Node SDK
53 lines (50 loc) • 2 kB
TypeScript
// Generated by dts-bundle-generator v9.5.1
declare enum FlowType {
Queue = "queue",
WebSocket = "websocket",
Custom = "custom"
}
declare enum FlowFramework {
BullMQ = "bullmq",
SocketIO = "socket.io",
Pubsub = "pubsub",
Amqplib = "amqplib",
EventHubs = "eventhubs",
Kafka = "kafka",
Sqs = "sqs",
ServiceBus = "servicebus",
Custom = "custom"
}
export type UserContext = any;
/**
* Options for the manual flow APIs. The shape is intentionally generic (not
* Kafka/queue specific): a flow has a {@link FlowType}, an arbitrary framework
* identifier, and optional queue attributes that are only used for queue flows.
*/
export interface FlowOptions {
/** Defaults to {@link FlowType.Custom}. */
type?: FlowType | "queue" | "websocket" | "custom";
/** Free-form framework identifier (e.g. "kafka"). Defaults to "custom". */
framework?: FlowFramework | string;
/**
* Number of messages handled by this flow (queue flows only). Must be a
* positive integer; a non-integer, zero, or negative value is ignored.
*/
messageCount?: number;
/**
* `Date` the message(s) were enqueued/produced (queue flows only). Used to
* derive the end-to-end (enqueue -> processing finished) duration. A
* non-`Date` value, one that is more than a year in the past, or one that is
* in the future is ignored.
*/
enqueueTime?: Date;
}
export type FlowHandler<Args extends unknown[], T> = (...args: Args) => T;
export declare function setHttpFlow(route: string, method: string): void;
export declare function startFlow(flowName: string, options?: FlowOptions): void;
export declare function endFlow(failureReason?: string): void;
export declare function wrapFlow<Args extends unknown[], T>(flowName: string, handler: FlowHandler<Args, T>, options?: FlowOptions): FlowHandler<Args, T>;
export declare function flush(): Promise<void>;
export declare function setContext(context: UserContext): void;
export declare function setFailure(error: string, context?: UserContext): void;
export {};