-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core-http] Establish standard PipelineOptions pattern in core-http (#…
…5669) * Extract NewPipelineOptions from keyvault-keys into core-http * Move keyvault-certificates to new PipelineOptions model * Move keyvault-secrets to new PipelineOptions model * Remove unused imports in ServiceClient * Remove userAgentHeaderName from UserAgentOptions * Remove the need for min retry interval * Add RetryMode to RetryOptions * Add InternalPipelineOptions for configuring internal options * Narrow KeyVault client constructor options to PipelineOptions type * Add LoggingOptions to propagate AzureLogger with LogPolicyOptions * Add requestPolicyFilter to PipelineOptions * Fix LoggerOptions logger propagation and KeyVault configuration * Simplify UserAgentOptions handling * Remove unused pipeline related artifacts in keyvault * Merge remote-tracking branch 'origin/master' into pr/daviwil/5669 * Revert "Merge remote-tracking branch 'origin/master' into pr/daviwil/5669" This reverts commit 126f6f5. * Remove unused pipeline related artifacts in keyvault certificates * Remove KeepAliveOptions.maxSockets (to be added back in the future) * Remove unused isPipelineOptions * Remove unused DefaultLogPolicyOptions * Rename userAgentPrefix local var * Alias ProxySettings as ProxyOptions * Rename PipelineOptions.requestPolicyFilter to updatePipelinePolicies
- Loading branch information
Showing
19 changed files
with
566 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { HttpClient } from "./httpClient"; | ||
import { RetryOptions } from './policies/exponentialRetryPolicy'; | ||
import { KeepAliveOptions } from './policies/keepAlivePolicy'; | ||
import { RedirectOptions } from './policies/redirectPolicy'; | ||
import { ProxyOptions } from './serviceClient'; | ||
import { UserAgentOptions } from './policies/userAgentPolicy'; | ||
import { DeserializationOptions } from './policies/deserializationPolicy'; | ||
import { LoggingOptions } from './policies/logPolicy'; | ||
import { RequestPolicyFactory } from './policies/requestPolicy'; | ||
|
||
/** | ||
* Defines options that are used to configure the HTTP pipeline for | ||
* an SDK client. | ||
*/ | ||
export interface PipelineOptions { | ||
/** | ||
* The HttpClient implementation to use for outgoing HTTP requests. Defaults | ||
* to DefaultHttpClient. | ||
*/ | ||
httpClient?: HttpClient; | ||
|
||
/** | ||
* Options that control how to retry failed requests. | ||
*/ | ||
retryOptions?: RetryOptions; | ||
|
||
/** | ||
* Options to configure a proxy for outgoing requests. | ||
*/ | ||
proxyOptions?: ProxyOptions; | ||
|
||
/* | ||
* Options for how HTTP connections should be maintained for future | ||
* requests. | ||
*/ | ||
keepAliveOptions?: KeepAliveOptions; | ||
|
||
/** | ||
* Options for how redirect responses are handled. | ||
*/ | ||
redirectOptions?: RedirectOptions; | ||
|
||
/** | ||
* Options for adding user agent details to outgoing requests. | ||
*/ | ||
userAgentOptions?: UserAgentOptions; | ||
|
||
/** | ||
* A function that accepts the array of RequestPolicyFactory created for | ||
* this PipelineOptions instance and can return modified list of policies. | ||
* This is useful for adding, inserting, or removing policies in special | ||
* case scenarios. If the function does not modify the array of | ||
* RequestPolicyFactory, it must return the original array it was given. | ||
*/ | ||
updatePipelinePolicies?: (requestPolicyFactories: RequestPolicyFactory[]) => RequestPolicyFactory[]; | ||
} | ||
|
||
/** | ||
* Defines options that are used to configure internal options of | ||
* the HTTP pipeline for an SDK client. | ||
*/ | ||
export interface InternalPipelineOptions extends PipelineOptions { | ||
/** | ||
* Options to configure API response deserialization. | ||
*/ | ||
deserializationOptions?: DeserializationOptions; | ||
|
||
/** | ||
* Options to configure request/response logging. | ||
*/ | ||
loggingOptions?: LoggingOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { BaseRequestPolicy, RequestPolicy, RequestPolicyOptions } from './requestPolicy'; | ||
import { WebResource } from '../webResource'; | ||
import { HttpOperationResponse } from '../httpOperationResponse'; | ||
|
||
/** | ||
* Options for how HTTP connections should be maintained for future | ||
* requests. | ||
*/ | ||
export interface KeepAliveOptions { | ||
/* | ||
* When true, connections will be kept alive for multiple requests. | ||
* Defaults to true. | ||
*/ | ||
enable: boolean; | ||
} | ||
|
||
export const DefaultKeepAliveOptions: KeepAliveOptions = { | ||
enable: true | ||
} | ||
|
||
export function keepAlivePolicy(keepAliveOptions?: KeepAliveOptions) { | ||
return { | ||
create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => { | ||
return new KeepAlivePolicy(nextPolicy, options, keepAliveOptions || DefaultKeepAliveOptions); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* KeepAlivePolicy is a policy used to control keep alive settings for every request. | ||
*/ | ||
export class KeepAlivePolicy extends BaseRequestPolicy { | ||
/** | ||
* Creates an instance of KeepAlivePolicy. | ||
* | ||
* @param {RequestPolicy} nextPolicy | ||
* @param {RequestPolicyOptions} options | ||
* @param {KeepAliveOptions} [keepAliveOptions] | ||
*/ | ||
constructor( | ||
nextPolicy: RequestPolicy, | ||
options: RequestPolicyOptions, | ||
private readonly keepAliveOptions: KeepAliveOptions | ||
) { | ||
super(nextPolicy, options); | ||
} | ||
|
||
/** | ||
* Sends out request. | ||
* | ||
* @param {WebResource} request | ||
* @returns {Promise<HttpOperationResponse>} | ||
* @memberof KeepAlivePolicy | ||
*/ | ||
public async sendRequest(request: WebResource): Promise<HttpOperationResponse> { | ||
request.keepAlive = this.keepAliveOptions.enable; | ||
return this._nextPolicy.sendRequest(request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.