1 | // Copyright (c) .NET Foundation. All rights reserved.
|
2 | // Licensed under the MIT License.
|
3 |
|
4 | import { FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger, RetryOptions } from './index';
|
5 | import { InvocationContext } from './InvocationContext';
|
6 |
|
7 | export type EventHubHandler = (messages: unknown, context: InvocationContext) => FunctionResult;
|
8 |
|
9 | export interface EventHubFunctionOptions extends EventHubTriggerOptions, Partial<FunctionOptions> {
|
10 | handler: EventHubHandler;
|
11 |
|
12 | trigger?: EventHubTrigger;
|
13 |
|
14 | /**
|
15 | * An optional retry policy to rerun a failed execution until either successful completion occurs or the maximum number of retries is reached.
|
16 | * Learn more [here](https://learn.microsoft.com/azure/azure-functions/functions-bindings-error-pages)
|
17 | */
|
18 | retry?: RetryOptions;
|
19 | }
|
20 |
|
21 | export interface EventHubTriggerOptions {
|
22 | /**
|
23 | * An app setting (or environment variable) with the event hub connection string
|
24 | */
|
25 | connection: string;
|
26 |
|
27 | /**
|
28 | * The name of the event hub. When the event hub name is also present in the connection string, that value overrides this property at runtime.
|
29 | */
|
30 | eventHubName: string;
|
31 |
|
32 | /**
|
33 | * Set to `many` in order to enable batching. If omitted or set to `one`, a single message is passed to the function.
|
34 | */
|
35 | cardinality?: 'many' | 'one';
|
36 |
|
37 | /**
|
38 | * An optional property that sets the [consumer group](https://docs.microsoft.com/azure/event-hubs/event-hubs-features#event-consumers) used to subscribe to events in the hub. If omitted, the `$Default` consumer group is used.
|
39 | */
|
40 | consumerGroup?: string;
|
41 | }
|
42 | export type EventHubTrigger = FunctionTrigger & EventHubTriggerOptions;
|
43 |
|
44 | export interface EventHubOutputOptions {
|
45 | /**
|
46 | * An app setting (or environment variable) with the event hub connection string
|
47 | */
|
48 | connection: string;
|
49 |
|
50 | /**
|
51 | * The name of the event hub. When the event hub name is also present in the connection string, that value overrides this property at runtime.
|
52 | */
|
53 | eventHubName: string;
|
54 | }
|
55 | export type EventHubOutput = FunctionOutput & EventHubOutputOptions;
|