1package azblob 2 3import ( 4 "github.com/Azure/azure-pipeline-go/pipeline" 5) 6 7// PipelineOptions is used to configure a request policy pipeline's retry policy and logging. 8type PipelineOptions struct { 9 // Log configures the pipeline's logging infrastructure indicating what information is logged and where. 10 Log pipeline.LogOptions 11 12 // Retry configures the built-in retry policy behavior. 13 Retry RetryOptions 14 15 // RequestLog configures the built-in request logging policy. 16 RequestLog RequestLogOptions 17 18 // Telemetry configures the built-in telemetry policy behavior. 19 Telemetry TelemetryOptions 20 21 // HTTPSender configures the sender of HTTP requests 22 HTTPSender pipeline.Factory 23} 24 25// NewPipeline creates a Pipeline using the specified credentials and options. 26func NewPipeline(c Credential, o PipelineOptions) pipeline.Pipeline { 27 // Closest to API goes first; closest to the wire goes last 28 f := []pipeline.Factory{ 29 NewTelemetryPolicyFactory(o.Telemetry), 30 NewUniqueRequestIDPolicyFactory(), 31 NewRetryPolicyFactory(o.Retry), 32 } 33 34 if _, ok := c.(*anonymousCredentialPolicyFactory); !ok { 35 // For AnonymousCredential, we optimize out the policy factory since it doesn't do anything 36 // NOTE: The credential's policy factory must appear close to the wire so it can sign any 37 // changes made by other factories (like UniqueRequestIDPolicyFactory) 38 f = append(f, c) 39 } 40 f = append(f, 41 NewRequestLogPolicyFactory(o.RequestLog), 42 pipeline.MethodFactoryMarker()) // indicates at what stage in the pipeline the method factory is invoked 43 44 45 return pipeline.NewPipeline(f, pipeline.Options{HTTPSender: o.HTTPSender, Log: o.Log}) 46} 47