// NewForwarder allocates and initializes a new forwarder.
548412
func NewForwarder(s *stack.Stack, handler func(*ForwarderRequest)) *Forwarder {
	return &Forwarder{
		stack:   s,
		handler: handler,
	}
}
1324801
func (g *Cloud) CreateRegionForwardingRule(rule *compute.ForwardingRule, region string) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newForwardingRuleMetricContext("create", region)
	return mc.Observe(g.c.ForwardingRules().Insert(ctx, meta.RegionalKey(rule.Name, region), rule))
}
1120067
func NewRouter(f *Fibre) *Router {
	return &Router{
		fibre:  f,
		routes: make(map[string][]*Route),
	}
}
1296635
func NewProfiler() (prof *Profiler, err error) {
	p, err := o.NewProfiler()
	if err != nil {
		return nil, err
	}
	return &Profiler{Profiler: p}, nil
}
1116806
func NewBinaryPropagator(tracer *Tracer) *BinaryPropagator {
	return &BinaryPropagator{
		tracer:  tracer,
		buffers: sync.Pool{New: func() interface{} { return &bytes.Buffer{} }},
	}
}
1344128
func NewRouter() Router {
	return &router{
		gateways: make(map[string]*gateway.Gateway),
		brokers:  make(map[string]*broker),
	}
}
1105529
func NewForwarder(f *Forwarder) *Forwarder {
	f.rewriter = &headerRewriter{}
	if f.RoundTripper == nil {
		f.RoundTripper = http.DefaultTransport
	}

	return f
}
289736
func New(dialer httpstream.Dialer, ports []string, stopChan <-chan struct{}) (*PortForwarder, error) {
	if len(ports) == 0 {
		return nil, errors.New("You must specify at least 1 port")
	}
	parsedPorts, err := parsePorts(ports)
	if err != nil {
		return nil, err
	}
	return &PortForwarder{
		dialer:   dialer,
		ports:    parsedPorts,
		stopChan: stopChan,
		Ready:    make(chan struct{}),
	}, nil
}
1106143
func NewProtoHandler(b *ProtoBackend) *ProtoHandler {
	h := &ProtoHandler{
		Router:       NewRouter(),
		Logger:       b.Logger,
		ProtoService: b.ProtoService,
		LabelService: b.LabelService,
	}

	h.HandlerFunc("GET", protosPath, h.handleGetProtos)
	h.HandlerFunc("POST", protosDashboardsPath, h.handlePostProtosDashboards)

	return h
}
781155
func NewProfiler() (prof *Profiler, err error) {
	p, err := l.NewProfiler()
	if err != nil {
		return nil, err
	}
	return &Profiler{Profiler: p}, nil
}
829727
func NewForwardSigner(ctx context.Context) goaclient.Signer {
	return &JWTSigner{Token: goajwt.ContextJWT(ctx).Raw}
}
179961
func (c *Client) CreateIpForwardingRule(p *CreateIpForwardingRuleParameter) (*IpForwardingRule, error) {
	obj, err := c.Request("createIpForwardingRule", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*IpForwardingRule), err
}
531947
func newProber(
	runner kubecontainer.ContainerCommandRunner,
	refManager *kubecontainer.RefManager,
	recorder record.EventRecorder) *prober {

	const followNonLocalRedirects = false
	return &prober{
		exec:          execprobe.New(),
		readinessHttp: httprobe.New(followNonLocalRedirects),
		livenessHttp:  httprobe.New(followNonLocalRedirects),
		tcp:           tcprobe.New(),
		runner:        runner,
		refManager:    refManager,
		recorder:      recorder,
	}
}
638083
func (s *Server) PortForward(ctx context.Context, req *pb.PortForwardRequest) (resp *pb.PortForwardResponse, err error) {
	const operation = "port_forward"
	defer func() {
		recordOperation(operation, time.Now())
		recordError(operation, err)
	}()
	logrus.Debugf("PortForwardRequest %+v", req)

	resp, err = s.getPortForward(req)
	if err != nil {
		return nil, fmt.Errorf("unable to prepare portforward endpoint")
	}

	return resp, nil
}
905152
func NewForwarder(ctx context.Context, router, service string, next http.Handler) http.Handler {
	middlewares.GetLogger(ctx, "tracing", forwarderTypeName).
		Debugf("Added outgoing tracing middleware %s", service)

	return &forwarderMiddleware{
		router:  router,
		service: service,
		next:    next,
	}
}
1319699
func setBucketForwardingHandler(h http.Handler) http.Handler {
	fwd := handlers.NewForwarder(&handlers.Forwarder{
		PassHost:     true,
		RoundTripper: NewCustomHTTPTransport(),
	})
	return bucketForwardingHandler{fwd, h}
}
437221
func NewForwardRecorder(cfg ForwardRecorderConfig) (*ForwardRecorder, error) {
	if err := cfg.CheckAndSetDefaults(); err != nil {
		return nil, trace.Wrap(err)
	}

	// Always write sessions to local disk first, then forward them to the Auth
	// Server later.
	auditLog, err := NewForwarder(ForwarderConfig{
		SessionID:      cfg.SessionID,
		ServerID:       teleport.ComponentUpload,
		DataDir:        cfg.DataDir,
		RecordSessions: cfg.RecordSessions,
		Namespace:      cfg.Namespace,
		ForwardTo:      cfg.ForwardTo,
	})
	if err != nil {
		return nil, trace.Wrap(err)
	}

	sr := &ForwardRecorder{
		ForwardRecorderConfig: cfg,
		Entry: logrus.WithFields(logrus.Fields{
			trace.Component: cfg.Component,
		}),
		AuditLog: auditLog,
	}
	return sr, nil
}