|
4 | 4 | import { FunctionInput, FunctionOptions, FunctionOutput, FunctionResult, FunctionTrigger } from './index'; |
5 | 5 | import { InvocationContext } from './InvocationContext'; |
6 | 6 |
|
7 | | -export type CosmosDBHandler = (documents: unknown[], context: InvocationContext) => FunctionResult; |
| 7 | +export type CosmosDBv3Handler = (documents: unknown[], context: InvocationContext) => FunctionResult; |
8 | 8 |
|
9 | | -export interface CosmosDBFunctionOptions extends CosmosDBTriggerOptions, Partial<FunctionOptions> { |
10 | | - handler: CosmosDBHandler; |
| 9 | +export interface CosmosDBv3FunctionOptions extends CosmosDBv3TriggerOptions, Partial<FunctionOptions> { |
| 10 | + handler: CosmosDBv3Handler; |
11 | 11 |
|
12 | | - trigger?: CosmosDBTrigger; |
| 12 | + trigger?: CosmosDBv3Trigger; |
13 | 13 | } |
14 | 14 |
|
15 | | -export interface CosmosDBInputOptions { |
| 15 | +export interface CosmosDBv3InputOptions { |
16 | 16 | /** |
17 | 17 | * An app setting (or environment variable) with the Cosmos DB connection string |
18 | 18 | */ |
@@ -45,10 +45,16 @@ export interface CosmosDBInputOptions { |
45 | 45 | * Don't set both the id and sqlQuery properties. If you don't set either one, the entire collection is retrieved. |
46 | 46 | */ |
47 | 47 | sqlQuery?: string; |
| 48 | + |
| 49 | + /** |
| 50 | + * Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. |
| 51 | + * Values should be comma-separated. For example, East US,South Central US,North Europe |
| 52 | + */ |
| 53 | + preferredLocations?: string; |
48 | 54 | } |
49 | | -export type CosmosDBInput = FunctionInput & CosmosDBInputOptions; |
| 55 | +export type CosmosDBv3Input = FunctionInput & CosmosDBv3InputOptions; |
50 | 56 |
|
51 | | -export interface CosmosDBTriggerOptions extends CosmosDBInputOptions { |
| 57 | +export interface CosmosDBv3TriggerOptions extends CosmosDBv3InputOptions { |
52 | 58 | /** |
53 | 59 | * The name of an app setting that contains the connection string to the service which holds the lease collection. |
54 | 60 | * If not set it will connect to the service defined by `connectionStringSetting` |
@@ -80,10 +86,64 @@ export interface CosmosDBTriggerOptions extends CosmosDBInputOptions { |
80 | 86 | * Using a prefix allows two separate Azure Functions to share the same Lease collection by using different prefixes. |
81 | 87 | */ |
82 | 88 | leaseCollectionPrefix?: string; |
| 89 | + |
| 90 | + /** |
| 91 | + * The time (in milliseconds) for the delay between polling a partition for new changes on the feed, after all current changes are drained. |
| 92 | + * Default is 5,000 milliseconds, or 5 seconds. |
| 93 | + */ |
| 94 | + feedPollDelay?: number; |
| 95 | + |
| 96 | + /** |
| 97 | + * When set, it defines, in milliseconds, the interval to kick off a task to compute if partitions are distributed evenly among known host instances. |
| 98 | + * Default is 13000 (13 seconds). |
| 99 | + */ |
| 100 | + leaseAcquireInterval?: number; |
| 101 | + |
| 102 | + /** |
| 103 | + * When set, it defines, in milliseconds, the interval for which the lease is taken on a lease representing a partition. |
| 104 | + * If the lease is not renewed within this interval, it will cause it to expire and ownership of the partition will move to another instance. |
| 105 | + * Default is 60000 (60 seconds). |
| 106 | + */ |
| 107 | + leaseExpirationInterval?: number; |
| 108 | + |
| 109 | + /** |
| 110 | + * When set, it defines, in milliseconds, the renew interval for all leases for partitions currently held by an instance. |
| 111 | + * Default is 17000 (17 seconds). |
| 112 | + */ |
| 113 | + leaseRenewInterval?: number; |
| 114 | + |
| 115 | + /** |
| 116 | + * When set, it defines, in milliseconds, the interval between lease checkpoints. Default is always after each Function call. |
| 117 | + */ |
| 118 | + checkpointInterval?: number; |
| 119 | + |
| 120 | + /** |
| 121 | + * Customizes the amount of documents between lease checkpoints. Default is after every function call. |
| 122 | + */ |
| 123 | + checkpointDocumentCount?: number; |
| 124 | + |
| 125 | + /** |
| 126 | + * When set, this property sets the maximum number of items received per Function call. |
| 127 | + * If operations in the monitored container are performed through stored procedures, transaction scope is preserved when reading items from the change feed. |
| 128 | + * As a result, the number of items received could be higher than the specified value so that the items changed by the same transaction are returned as part of one atomic batch. |
| 129 | + */ |
| 130 | + maxItemsPerInvocation?: number; |
| 131 | + |
| 132 | + /** |
| 133 | + * This option tells the Trigger to read changes from the beginning of the container's change history instead of starting at the current time. |
| 134 | + * Reading from the beginning only works the first time the trigger starts, as in subsequent runs, the checkpoints are already stored. |
| 135 | + * Setting this option to true when there are leases already created has no effect. |
| 136 | + */ |
| 137 | + startFromBeginning?: boolean; |
| 138 | + |
| 139 | + /** |
| 140 | + * Enables multi-region accounts for writing to the leases collection. |
| 141 | + */ |
| 142 | + useMultipleWriteLocations?: boolean; |
83 | 143 | } |
84 | | -export type CosmosDBTrigger = FunctionTrigger & CosmosDBTriggerOptions; |
| 144 | +export type CosmosDBv3Trigger = FunctionTrigger & CosmosDBv3TriggerOptions; |
85 | 145 |
|
86 | | -export interface CosmosDBOutputOptions { |
| 146 | +export interface CosmosDBv3OutputOptions { |
87 | 147 | /** |
88 | 148 | * An app setting (or environment variable) with the Cosmos DB connection string |
89 | 149 | */ |
@@ -114,5 +174,16 @@ export interface CosmosDBOutputOptions { |
114 | 174 | * When createIfNotExists is true, it defines the [throughput](https://docs.microsoft.com/azure/cosmos-db/set-throughput) of the created collection |
115 | 175 | */ |
116 | 176 | collectionThroughput?: number; |
| 177 | + |
| 178 | + /** |
| 179 | + * Defines preferred locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. |
| 180 | + * Values should be comma-separated. For example, East US,South Central US,North Europe |
| 181 | + */ |
| 182 | + preferredLocations?: string; |
| 183 | + |
| 184 | + /** |
| 185 | + * When set to true along with preferredLocations, supports multi-region writes in the Azure Cosmos DB service. |
| 186 | + */ |
| 187 | + useMultipleWriteLocations?: boolean; |
117 | 188 | } |
118 | | -export type CosmosDBOutput = FunctionOutput & CosmosDBOutputOptions; |
| 189 | +export type CosmosDBv3Output = FunctionOutput & CosmosDBv3OutputOptions; |
0 commit comments