func (po *PolicyOptions) ShouldLog(level LogLevel) bool {
	if po.pipeline.options.Log.ShouldLog != nil {
		return po.pipeline.options.Log.ShouldLog(level)
	}
	return false
}
ShouldLog returns true if the specified log level should be logged.
package pipeline
import (
	"context"
	"github.com/mattn/go-ieproxy"
	"net"
	"net/http"
	"os"
	"time"
)
type Factory interface {
	New(next Policy, po *PolicyOptions) Policy
}
type FactoryFunc func(next Policy, po *PolicyOptions) PolicyFunc
func (f FactoryFunc) New(next Policy, po *PolicyOptions) Policy {
	return f(next, po)
}
type Policy interface {
	Do(ctx context.Context, request Request) (Response, error)
}
type PolicyFunc func(ctx context.Context, request Request) (Response, error)
func (f PolicyFunc) Do(ctx context.Context, request Request) (Response, error) {
	return f(ctx, request)
}
type Options struct {
	HTTPSender Factory  
	Log        LogOptions
}
type LogLevel uint32
const (
	LogNone LogLevel = iota
	LogFatal
	LogPanic
	LogError
	LogWarning
	LogInfo
	LogDebug
)
type LogOptions struct {
	Log func(level LogLevel, message string)
	ShouldLog func(level LogLevel) bool
}
type pipeline struct {
	factories []Factory
	options   Options
}
type Pipeline interface {
	Do(ctx context.Context, methodFactory Factory, request Request) (Response, error)
}
func NewPipeline(factories []Factory, o Options) Pipeline {
	if o.HTTPSender == nil {
		o.HTTPSender = newDefaultHTTPClientFactory()
	}
	if o.Log.Log == nil {
		o.Log.Log = func(LogLevel, string) {}  
	}
	return &pipeline{factories: factories, options: o}
}
func (p *pipeline) Do(ctx context.Context, methodFactory Factory, request Request) (Response, error) {
	response, err := p.newPolicies(methodFactory).Do(ctx, request)
	request.close()
	return response, err
}
func (p *pipeline) newPolicies(methodFactory Factory) Policy {
	po := &PolicyOptions{pipeline: p}  
	next := p.options.HTTPSender.New(nil, po)
	markers := 0
	for i := len(p.factories) - 1; i >= 0; i-- {
		factory := p.factories[i]
		if _, ok := factory.(methodFactoryMarker); ok {
			markers++
			if markers > 1 {
				panic("MethodFactoryMarker can only appear once in the pipeline")
			}
			if methodFactory != nil {
				next = methodFactory.New(next, po)
			}
		} else {
			next = factory.New(next, po)
		}
	}
	if markers == 0 && methodFactory != nil {
		panic("Non-nil methodFactory requires MethodFactoryMarker in the pipeline")
	}
	return next  
}
type PolicyOptions struct {
	pipeline *pipeline
}