Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core-https] Port request policies to new pipeline model #9468

Merged
merged 26 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a998157
Port disableDisableResponseDecompressionPolicy
xirzec Jun 5, 2020
6e2d35f
Add exponentialRetryPolicy
xirzec Jun 5, 2020
0c98ffc
Port over clientid policy
xirzec Jun 5, 2020
8b218c8
port KeepAlivePolicy
xirzec Jun 5, 2020
55df818
Port log policy
xirzec Jun 6, 2020
0668ec5
Port proxy policy
xirzec Jun 6, 2020
1511abf
port redirect policy
xirzec Jun 6, 2020
d4d5d12
initial port of system error retry policy
xirzec Jun 9, 2020
8b8cac4
Tweak the way retry policies calculate jitter
xirzec Jun 9, 2020
1c795e9
Port throttling retry policy
xirzec Jun 9, 2020
f5b412e
Port tracing policy
xirzec Jun 9, 2020
68d97b9
Port user agent policy
xirzec Jun 9, 2020
d32d1e2
Add back factory for default pipeline
xirzec Jun 10, 2020
f86db5b
create form data policy
xirzec Jun 10, 2020
605c924
Add test for disable decompression
xirzec Jun 10, 2020
0d58584
Add tests for proxy policy
xirzec Jun 10, 2020
12f398f
Add tracing policy tests
xirzec Jun 11, 2020
5e43f2f
Add tests for throttling retry
xirzec Jun 11, 2020
017d6e8
Add system error ertry tests
xirzec Jun 11, 2020
66e5405
Add test for createPipelineFromOptions
xirzec Jun 11, 2020
e4a2ab6
Merge remote-tracking branch 'upstream/master' into requestPolicies
xirzec Jun 11, 2020
d997cca
Update user agent header per #6530
xirzec Jun 11, 2020
b4e709e
Address PR feedback
xirzec Jun 16, 2020
a856643
Preserve request id when cloning.
xirzec Jun 16, 2020
f2ab65d
nits found in review
xirzec Jun 17, 2020
a9cebf0
Update retry defaults
xirzec Jun 18, 2020
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
2 changes: 1 addition & 1 deletion sdk/core/core-https/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/latest/coreHttps.d.ts"
"publicTrimmedFilePath": "./types/latest/core-https.d.ts"
},
"messages": {
"tsdocMessageReporting": {
Expand Down
24 changes: 20 additions & 4 deletions sdk/core/core-https/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"name": "@azure/core-https",
"version": "1.0.0",
"version": "1.0.0-preview.1",
"private": true,
"description": "Isomorphic client library for making HTTPS requests in node.js and browser.",
"sdk-type": "client",
"main": "dist/index.js",
"module": "dist-esm/src/index.js",
"browser": {
"./dist-esm/src/defaultHttpsClient.js": "./dist-esm/src/defaultHttpsClient.browser.js",
"./dist-esm/src/policies/disableResponseDecompressionPolicy.js": "./dist-esm/src/policies/disableResponseDecompressionPolicy.browser.js",
"./dist-esm/src/policies/formDataPolicy.js": "./dist-esm/src/policies/formDataPolicy.browser.js",
"./dist-esm/src/policies/proxyPolicy.js": "./dist-esm/src/policies/proxyPolicy.browser.js",
"./dist-esm/src/util/inspect.js": "./dist-esm/src/util/inspect.browser.js",
"./dist-esm/src/util/url.js": "./dist-esm/src/util/url.browser.js"
"./dist-esm/src/util/url.js": "./dist-esm/src/util/url.browser.js",
"./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.browser.js"
},
"types": "types/latest/coreHttps.d.ts",
"types": "types/latest/core-https.d.ts",
"typesVersions": {
"<3.6": {
"types/latest/src/*": [
Expand Down Expand Up @@ -76,12 +80,23 @@
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-https/",
"sideEffects": false,
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
"//metadata": {
"constantPaths": [
{
"path": "src/constants.ts",
"prefix": "SDK_VERSION"
}
]
},
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.8",
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.6.1",
"form-data": "^3.0.0",
"tslib": "^2.0.0",
"https-proxy-agent": "^5.0.0"
"https-proxy-agent": "^5.0.0",
"uuid": "^8.1.0"
},
"devDependencies": {
"@microsoft/api-extractor": "7.7.11",
Expand All @@ -94,6 +109,7 @@
"@types/mocha": "^7.0.2",
"@types/node": "^8.0.0",
"@types/sinon": "^9.0.4",
"@types/uuid": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
Expand Down
147 changes: 147 additions & 0 deletions sdk/core/core-https/review/core-https.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
```ts

import { AbortSignalLike } from '@azure/abort-controller';
import { Debugger } from '@azure/logger';
import { SpanOptions } from '@azure/core-tracing';

// @public
export interface AddPipelineOptions {
Expand All @@ -20,6 +22,9 @@ export function createEmptyPipeline(): Pipeline;
// @public
export function createHttpHeaders(rawHeaders?: RawHttpHeaders): HttpHeaders;

// @public
export function createPipelineFromOptions(options: InternalPipelineOptions): Pipeline;

// @public
export function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest;

Expand All @@ -28,14 +33,42 @@ export class DefaultHttpsClient implements HttpsClient {
sendRequest(request: PipelineRequest): Promise<PipelineResponse>;
}

// @public
export function disableResponseDecompressionPolicy(): PipelinePolicy;
xirzec marked this conversation as resolved.
Show resolved Hide resolved

// @public
export const disableResponseDecompressionPolicyName = "disableResponseDecompressionPolicy";

// @public
export function exponentialRetryPolicy(options?: ExponentialRetryPolicyOptions): PipelinePolicy;

// @public
export interface ExponentialRetryPolicyOptions {
maxRetries?: number;
maxRetryDelayInMs?: number;
retryDelayInMs?: number;
}

// @public
export const expontentialRetryPolicyName = "exponentialRetryPolicy";

// @public
export type FormDataMap = {
[key: string]: FormDataValue | FormDataValue[];
};

// @public
export function formDataPolicy(): PipelinePolicy;

// @public
export const formDataPolicyName = "formDataPolicy";

// @public
export type FormDataValue = string | Blob;

// @public
export function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined;

// @public
export interface HttpHeaders extends Iterable<[string, string]> {
clone(): HttpHeaders;
Expand All @@ -54,6 +87,36 @@ export interface HttpsClient {
sendRequest: SendRequest;
}

// @public
export interface InternalPipelineOptions extends PipelineOptions {
decompressResponse?: boolean;
loggingOptions?: LogPolicyOptions;
}

// @public
export function keepAlivePolicy(options?: KeepAlivePolicyOptions): PipelinePolicy;
xirzec marked this conversation as resolved.
Show resolved Hide resolved

// @public
export const keepAlivePolicyName = "keepAlivePolicy";

// @public
export interface KeepAlivePolicyOptions {
enable?: boolean;
}

// @public
export function logPolicy(options?: LogPolicyOptions): PipelinePolicy;

// @public
export const logPolicyName = "logPolicy";

// @public
export interface LogPolicyOptions {
additionalAllowedHeaderNames?: string[];
additionalAllowedQueryParameters?: string[];
logger?: Debugger;
}

// @public
export interface Pipeline {
addPolicy(policy: PipelinePolicy, options?: AddPipelineOptions): void;
Expand All @@ -66,6 +129,16 @@ export interface Pipeline {
sendRequest(httpsClient: HttpsClient, request: PipelineRequest): Promise<PipelineResponse>;
}

// @public
export interface PipelineOptions {
httpsClient?: HttpsClient;
keepAliveOptions?: KeepAlivePolicyOptions;
proxyOptions?: ProxySettings;
redirectOptions?: PipelineRedirectOptions;
retryOptions?: ExponentialRetryPolicyOptions;
userAgentOptions?: UserAgentPolicyOptions;
}

// @public
export type PipelinePhase = "Serialize" | "Retry";

Expand All @@ -75,18 +148,26 @@ export interface PipelinePolicy {
sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse>;
}

// @public
export interface PipelineRedirectOptions extends RedirectPolicyOptions {
disable?: boolean;
}

// @public
export interface PipelineRequest {
abortSignal?: AbortSignalLike;
body?: RequestBodyType;
clone(): PipelineRequest;
formData?: FormDataMap;
headers: HttpHeaders;
keepAlive?: boolean;
method: HttpMethods;
onDownloadProgress?: (progress: TransferProgressEvent) => void;
onUploadProgress?: (progress: TransferProgressEvent) => void;
proxySettings?: ProxySettings;
requestId: string;
skipDecompressResponse?: boolean;
spanOptions?: SpanOptions;
streamResponseBody?: boolean;
timeout: number;
url: string;
Expand All @@ -104,7 +185,9 @@ export interface PipelineRequestOptions {
onDownloadProgress?: (progress: TransferProgressEvent) => void;
onUploadProgress?: (progress: TransferProgressEvent) => void;
proxySettings?: ProxySettings;
requestId?: string;
skipDecompressResponse?: boolean;
spanOptions?: SpanOptions;
streamResponseBody?: boolean;
timeout?: number;
url: string;
Expand All @@ -121,6 +204,12 @@ export interface PipelineResponse {
status: number;
}

// @public
export function proxyPolicy(proxySettings?: ProxySettings | undefined): PipelinePolicy;

// @public
export const proxyPolicyName = "proxyPolicy";

// @public
export interface ProxySettings {
host: string;
Expand All @@ -134,6 +223,17 @@ export type RawHttpHeaders = {
[headerName: string]: string;
};

// @public
export function redirectPolicy(options?: RedirectPolicyOptions): PipelinePolicy;

// @public
export const redirectPolicyName = "redirectPolicy";

// @public
export interface RedirectPolicyOptions {
maxRetries?: number;
}

// @public
export type RequestBodyType = NodeJS.ReadableStream | Blob | ArrayBuffer | ArrayBufferView | FormData | string | null;

Expand All @@ -160,11 +260,58 @@ export interface RestErrorOptions {
// @public
export type SendRequest = (request: PipelineRequest) => Promise<PipelineResponse>;

// @public
export function setClientRequestIdPolicy(requestIdHeaderName?: string): PipelinePolicy;

// @public
export const setClientRequestIdPolicyName = "setClientRequestIdPolicy";

// @public
export function systemErrorRetryPolicy(options?: SystemErrorRetryPolicyOptions): PipelinePolicy;

// @public
export const systemErrorRetryPolicyName = "systemErrorRetryPolicy";

// @public
export interface SystemErrorRetryPolicyOptions {
maxRetries?: number;
maxRetryDelayInMs?: number;
retryDelayInMs?: number;
}

// @public
export function throttlingRetryPolicy(): PipelinePolicy;

// @public
export const throttlingRetryPolicyName = "throttlingRetryPolicy";

// @public
export function tracingPolicy(options?: TracingPolicyOptions): PipelinePolicy;

// @public
export const tracingPolicyName = "tracingPolicy";

// @public
export interface TracingPolicyOptions {
userAgentPrefix?: string;
}

// @public
export type TransferProgressEvent = {
loadedBytes: number;
};

// @public
export function userAgentPolicy(options?: UserAgentPolicyOptions): PipelinePolicy;

// @public
export const userAgentPolicyName = "userAgentPolicy";

// @public
export interface UserAgentPolicyOptions {
userAgentPrefix?: string;
}


// (No @packageDocumentation comment for this package)

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-https/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const input = "dist-esm/src/index.js";
const production = process.env.NODE_ENV === "production";

export function nodeConfig(test = false) {
const externalNodeBuiltins = ["stream", "https", "zlib", "url", "util"];
const externalNodeBuiltins = ["os", "stream", "https", "zlib", "url", "util"];
const baseConfig = {
input: input,
external: depNames.concat(externalNodeBuiltins),
Expand Down
4 changes: 4 additions & 0 deletions sdk/core/core-https/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const SDK_VERSION: string = "1.0.0-preview.1";
44 changes: 43 additions & 1 deletion sdk/core/core-https/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,51 @@ export {
PipelinePhase,
PipelinePolicy,
Pipeline,
createEmptyPipeline
createEmptyPipeline,
InternalPipelineOptions,
PipelineOptions,
PipelineRedirectOptions,
createPipelineFromOptions
} from "./pipeline";
export { DefaultHttpsClient } from "./defaultHttpsClient";
export { createHttpHeaders } from "./httpHeaders";
export { createPipelineRequest, PipelineRequestOptions } from "./pipelineRequest";
export { RestError, RestErrorOptions } from "./restError";
export {
disableResponseDecompressionPolicy,
disableResponseDecompressionPolicyName
} from "./policies/disableResponseDecompressionPolicy";
export {
exponentialRetryPolicy,
ExponentialRetryPolicyOptions,
expontentialRetryPolicyName
} from "./policies/exponentialRetryPolicy";
export {
setClientRequestIdPolicy,
setClientRequestIdPolicyName
} from "./policies/setClientRequestIdPolicy";
export {
keepAlivePolicy,
keepAlivePolicyName,
KeepAlivePolicyOptions
} from "./policies/keepAlivePolicy";
export { logPolicy, logPolicyName, LogPolicyOptions } from "./policies/logPolicy";
export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./policies/proxyPolicy";
export {
redirectPolicy,
redirectPolicyName,
RedirectPolicyOptions
} from "./policies/redirectPolicy";
export {
systemErrorRetryPolicy,
SystemErrorRetryPolicyOptions,
systemErrorRetryPolicyName
} from "./policies/systemErrorRetryPolicy";
export { throttlingRetryPolicy, throttlingRetryPolicyName } from "./policies/throttlingRetryPolicy";
export { tracingPolicy, tracingPolicyName, TracingPolicyOptions } from "./policies/tracingPolicy";
export {
userAgentPolicy,
userAgentPolicyName,
UserAgentPolicyOptions
} from "./policies/userAgentPolicy";
export { formDataPolicy, formDataPolicyName } from "./policies/formDataPolicy";
Loading