Blame vendor/github.com/Azure/azure-storage-blob-go/azblob/zc_pipeline.go

Packit Service 4d2de5
package azblob
Packit Service 4d2de5
Packit Service 4d2de5
import (
Packit Service 4d2de5
	"github.com/Azure/azure-pipeline-go/pipeline"
Packit Service 4d2de5
)
Packit Service 4d2de5
Packit Service 4d2de5
// PipelineOptions is used to configure a request policy pipeline's retry policy and logging.
Packit Service 4d2de5
type PipelineOptions struct {
Packit Service 4d2de5
	// Log configures the pipeline's logging infrastructure indicating what information is logged and where.
Packit Service 4d2de5
	Log pipeline.LogOptions
Packit Service 4d2de5
Packit Service 4d2de5
	// Retry configures the built-in retry policy behavior.
Packit Service 4d2de5
	Retry RetryOptions
Packit Service 4d2de5
Packit Service 4d2de5
	// RequestLog configures the built-in request logging policy.
Packit Service 4d2de5
	RequestLog RequestLogOptions
Packit Service 4d2de5
Packit Service 4d2de5
	// Telemetry configures the built-in telemetry policy behavior.
Packit Service 4d2de5
	Telemetry TelemetryOptions
Packit Service 4d2de5
Packit Service 4d2de5
	// HTTPSender configures the sender of HTTP requests
Packit Service 4d2de5
	HTTPSender pipeline.Factory
Packit Service 4d2de5
}
Packit Service 4d2de5
Packit Service 4d2de5
// NewPipeline creates a Pipeline using the specified credentials and options.
Packit Service 4d2de5
func NewPipeline(c Credential, o PipelineOptions) pipeline.Pipeline {
Packit Service 4d2de5
	// Closest to API goes first; closest to the wire goes last
Packit Service 4d2de5
	f := []pipeline.Factory{
Packit Service 4d2de5
		NewTelemetryPolicyFactory(o.Telemetry),
Packit Service 4d2de5
		NewUniqueRequestIDPolicyFactory(),
Packit Service 4d2de5
		NewRetryPolicyFactory(o.Retry),
Packit Service 4d2de5
	}
Packit Service 4d2de5
Packit Service 4d2de5
	if _, ok := c.(*anonymousCredentialPolicyFactory); !ok {
Packit Service 4d2de5
		// For AnonymousCredential, we optimize out the policy factory since it doesn't do anything
Packit Service 4d2de5
		// NOTE: The credential's policy factory must appear close to the wire so it can sign any
Packit Service 4d2de5
		// changes made by other factories (like UniqueRequestIDPolicyFactory)
Packit Service 4d2de5
		f = append(f, c)
Packit Service 4d2de5
	}
Packit Service 4d2de5
	f = append(f,
Packit Service 4d2de5
		NewRequestLogPolicyFactory(o.RequestLog),
Packit Service 4d2de5
		pipeline.MethodFactoryMarker()) // indicates at what stage in the pipeline the method factory is invoked
Packit Service 4d2de5
Packit Service 4d2de5
Packit Service 4d2de5
	return pipeline.NewPipeline(f, pipeline.Options{HTTPSender: o.HTTPSender, Log: o.Log})
Packit Service 4d2de5
}