Skip to content

Commit 4b154d0

Browse files
author
Swapnil Nagar
committed
Adding support for input binding
1 parent 4e6848d commit 4b154d0

File tree

5 files changed

+14
-42
lines changed

5 files changed

+14
-42
lines changed

src/converters/toCoreFunctionMetadata.ts

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import {
5-
ExponentialBackoffRetryOptions,
6-
FixedDelayRetryOptions,
7-
GenericFunctionOptions,
8-
SupportedDeferredBindingTypes,
9-
} from '@azure/functions';
4+
import { ExponentialBackoffRetryOptions, FixedDelayRetryOptions, GenericFunctionOptions } from '@azure/functions';
105
import * as coreTypes from '@azure/functions-core';
116
import { returnBindingKey } from '../constants';
127
import { AzFuncSystemError } from '../errors';
@@ -24,7 +19,7 @@ export function toCoreFunctionMetadata(name: string, options: GenericFunctionOpt
2419
...trigger,
2520
direction: 'in',
2621
type: isTrigger(trigger.type) ? trigger.type : trigger.type + 'Trigger',
27-
properties: addDeferredBindingsFlag(options.trigger.type, options.trigger.deferredBindingType),
22+
properties: addDeferredBindingsFlag(options.trigger?.deferredBinding),
2823
};
2924
bindingNames.push(trigger.name);
3025

@@ -33,7 +28,7 @@ export function toCoreFunctionMetadata(name: string, options: GenericFunctionOpt
3328
bindings[input.name] = {
3429
...input,
3530
direction: 'in',
36-
//properties: addDeferredBindingsFlag(input.type),
31+
properties: addDeferredBindingsFlag(input?.deferredBinding),
3732
};
3833
bindingNames.push(input.name);
3934
}
@@ -84,25 +79,11 @@ export function toCoreFunctionMetadata(name: string, options: GenericFunctionOpt
8479
return { name, bindings, retryOptions };
8580
}
8681

87-
function addDeferredBindingsFlag(
88-
triggerType: string,
89-
deferredBindingType?: SupportedDeferredBindingTypes | unknown
90-
): { [key: string]: string } {
82+
function addDeferredBindingsFlag(deferredBindingType?: boolean | unknown): { [key: string]: string } {
9183
//Ensure that trigger type that is passed is valid and supported, to avoid customer misconfiguration.
92-
console.log('Adding deferred binding flag: ', deferredBindingType);
93-
//TODO there is inherent issue with converting the enum to string, look for fix in the when other SDK biniding will be supported.
94-
const deferredBindingTypesSet = new Set<string>([
95-
'blobTrigger',
96-
//TODO: enum memeber conversion is running into error, issue is with the typescript.
97-
//SupportedDeferredBindingTypes.BLOBTRIGGER,
98-
]);
99-
100-
if (
101-
deferredBindingType !== undefined &&
102-
deferredBindingType === triggerType &&
103-
deferredBindingTypesSet.has(triggerType)
104-
) {
105-
console.log('Adding deferred binding flag to trigger type:', triggerType);
84+
console.log('Deferred binding flag value is: ', deferredBindingType);
85+
if (deferredBindingType !== undefined && deferredBindingType === true) {
86+
console.log('Adding deferred binding propertyu to trigger type:', deferredBindingType);
10687
return { supportsDeferredBinding: 'true' };
10788
}
10889

src/deferred-binding/supportedDeferredBindingTypes.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

types/index.d.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { SupportedDeferredBindingTypes } from '../src/deferred-binding/supportedDeferredBindingTypes';
54
import { InvocationContext } from './InvocationContext';
65

7-
export * from '../src/deferred-binding/supportedDeferredBindingTypes';
86
export * as app from './app';
97
export * from './cosmosDB';
108
export * from './cosmosDB.v3';
@@ -72,12 +70,6 @@ export interface FunctionOptions {
7270
* During invocation, set these values with `context.extraOutputs.set()`
7371
*/
7472
extraOutputs?: FunctionOutput[];
75-
76-
/**
77-
* Configuration for the optional deferredBindingTypey for this function
78-
* This is the retry policy that will be used if the function fails during
79-
*/
80-
deferredBindingType?: SupportedDeferredBindingTypes;
8173
}
8274

8375
/**

types/storage.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export interface StorageBlobOptions {
2929
* An app setting (or environment variable) with the storage connection string to be used by this blob input or output
3030
*/
3131
connection: string;
32+
33+
/**
34+
* Whether to use deferred binding for this blob operation.
35+
* */
36+
deferredBinding?: boolean;
3237
}
3338

3439
export interface StorageQueueOptions {

types/storageBlobClient.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ export type StorageBlobClient = StorageBlobClientOptions;
1111

1212
export interface StorageBlobClientOptions {
1313
/**
14-
* Blob client to be used by this queue input or output. This is the client that will be used to perform operations on the blob storage.
14+
* Blob client to be used by this blob input or output. This is the client that will be used to perform operations on the blob storage.
1515
*/
1616
blobClient: BlobClient;
1717

1818
/**
19-
* Container client to be used by this queue input or output. This is the client that will be used to perform operations on the container storage.
19+
* Container client to be used by this blob input or output. This is the client that will be used to perform operations on the container storage.
2020
*/
2121
conatinerClient: ContainerClient;
2222
}

0 commit comments

Comments
 (0)