Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/coreApi/converters/fromCoreFunctionMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function fromCoreFunctionMetadata(data: coreTypes.RpcFunctionMetadata): r
...data,
bindings: fromCoreBindings(data.bindings),
status: fromCoreStatusResult(data.status),
retryOptions: fromCoreRetryOptions(data.retryOptions),
};
return ensureKeysMatch(data, result);
}
Expand Down Expand Up @@ -74,3 +75,30 @@ function fromCoreBindingDirection(
return handleDefaultEnumCase(data, 'CoreRpcBindingDirection');
}
}

function fromCoreRetryOptions(
data: coreTypes.RpcRetryOptions | null | undefined
): rpc.IRpcRetryOptions | null | undefined {
if (data) {
const result = {
...data,
retryStrategy: fromCoreRetryStrategy(data.retryStrategy),
};
return ensureKeysMatch(data, result);
} else {
return data;
}
}

function fromCoreRetryStrategy(
data: coreTypes.RpcRetryStrategy | null | undefined
): rpc.RpcRetryOptions.RetryStrategy | null | undefined {
switch (data) {
case 'exponentialBackoff':
return rpc.RpcRetryOptions.RetryStrategy.exponential_backoff;
case 'fixedDelay':
return rpc.RpcRetryOptions.RetryStrategy.fixed_delay;
default:
return handleDefaultEnumCase(data, 'CoreRpcRetryStrategy');
}
}
28 changes: 28 additions & 0 deletions src/coreApi/converters/toCoreFunctionMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function toCoreFunctionMetadata(data: rpc.IRpcFunctionMetadata): coreType
...data,
bindings: toCoreBindings(data.bindings),
status: toCoreStatusResult(data.status),
retryOptions: toCoreRetryOptions(data.retryOptions),
};
return ensureKeysMatch(data, result);
}
Expand Down Expand Up @@ -74,3 +75,30 @@ function toCoreBindingDirection(
return handleDefaultEnumCase(data, 'RpcBindingDirection');
}
}

function toCoreRetryOptions(
data: rpc.IRpcRetryOptions | null | undefined
): coreTypes.RpcRetryOptions | null | undefined {
if (data) {
const result = {
...data,
retryStrategy: toCoreRetryStrategy(data.retryStrategy),
};
return ensureKeysMatch(data, result);
} else {
return data;
}
}

function toCoreRetryStrategy(
data: rpc.RpcRetryOptions.RetryStrategy | null | undefined
): coreTypes.RpcRetryStrategy | null | undefined {
switch (data) {
case rpc.RpcRetryOptions.RetryStrategy.exponential_backoff:
return 'exponentialBackoff';
case rpc.RpcRetryOptions.RetryStrategy.fixed_delay:
return 'fixedDelay';
default:
return handleDefaultEnumCase(data, 'RpcRetryStrategy');
}
}
29 changes: 28 additions & 1 deletion types-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare module '@azure/functions-core' {
function registerFunction(metadata: FunctionMetadata, callback: FunctionCallback): Disposable;

/**
* A slimmed down version of `RpcFunctionMetadata` that includes the minimum amount of information needed to register a function
* A slimmed down version of `RpcFunctionMetadata` that includes only the properties respected as a part of the `registerFunction` api
* NOTE: All properties on this object need to be deterministic to support the multiple worker scenario. More info here: https://github.com/Azure/azure-functions-nodejs-worker/issues/638
*/
interface FunctionMetadata {
Expand All @@ -43,6 +43,11 @@ declare module '@azure/functions-core' {
* A dictionary of binding name to binding info
*/
bindings: { [name: string]: RpcBindingInfo };

/**
* The retry policy options
*/
retryOptions?: RpcRetryOptions;
}

/**
Expand Down Expand Up @@ -298,6 +303,8 @@ declare module '@azure/functions-core' {
functionId?: string | null;

managedDependencyEnabled?: boolean | null;

retryOptions?: RpcRetryOptions | null;
}

interface RpcStatusResult {
Expand Down Expand Up @@ -352,6 +359,20 @@ declare module '@azure/functions-core' {

type RpcBindingDataType = 'undefined' | 'string' | 'binary' | 'stream';

interface RpcRetryOptions {
maxRetryCount?: number | null;

delayInterval?: RpcDuration | null;

minimumInterval?: RpcDuration | null;

maximumInterval?: RpcDuration | null;

retryStrategy?: RpcRetryStrategy | null;
}

type RpcRetryStrategy = 'exponentialBackoff' | 'fixedDelay';

interface RpcTypedData {
string?: string | null;

Expand Down Expand Up @@ -508,6 +529,12 @@ declare module '@azure/functions-core' {
nanos?: number | null;
}

interface RpcDuration {
seconds?: number | Long | null;

nanos?: number | null;
}

type RpcHttpCookieSameSite = 'none' | 'lax' | 'strict' | 'explicitNone';
// #endregion rpc types
}