ops

package
v7.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2023 License: GPL-3.0 Imports: 13 Imported by: 3

Documentation

Overview

Package ops wraps github.com/getlantern/ops with convenience methods for flashlight

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Go

func Go(fn func())

Go mimics the similar method from ops.

func InitGlobalContext

func InitGlobalContext(appName, applicationVersion, revisionDate, deviceID string, isPro func() bool, getCountry func() string)

InitGlobalContext configures global context info

func ProxyNameAndDC

func ProxyNameAndDC(name string) (proxyName string, dc string)

ProxyNameAndDC extracts the canonical proxy name and datacenter from a given full proxy name.

func RegisterReporter

func RegisterReporter(reporter ops.Reporter)

RegisterReporter mimics the similar method from ops

func SetGlobal

func SetGlobal(key string, value interface{})

SetGlobal mimics the similar method from ops

func SetGlobalDynamic

func SetGlobalDynamic(key string, valueFN func() interface{})

SetGlobalDynamic mimics the similar method from ops

func WithOp

func WithOp(ctx context.Context, op *Op) context.Context

WithOp adds an Op to the context to be retrieved later via FromContext

Types

type InstrumentedResponseWriter

type InstrumentedResponseWriter struct {
	http.ResponseWriter
	Op *Op
	// contains filtered or unexported fields
}

func InitInstrumentedResponseWriter

func InitInstrumentedResponseWriter(w http.ResponseWriter, label string) *InstrumentedResponseWriter

func (*InstrumentedResponseWriter) FailIf

func (w *InstrumentedResponseWriter) FailIf(err error)

func (*InstrumentedResponseWriter) Finish

func (w *InstrumentedResponseWriter) Finish()

func (*InstrumentedResponseWriter) Set

func (w *InstrumentedResponseWriter) Set(key string, value interface{})

func (*InstrumentedResponseWriter) Write

func (w *InstrumentedResponseWriter) Write(p []byte) (n int, err error)

func (*InstrumentedResponseWriter) WriteHeader

func (w *InstrumentedResponseWriter) WriteHeader(statusCode int)

type Op

type Op struct {
	// contains filtered or unexported fields
}

Op decorates an ops.Op with convenience methods.

func Begin

func Begin(name string) *Op

Begin mimics the similar method from ops

func FromContext

func FromContext(ctx context.Context) *Op

FromContext extracts an Op from the context, or nil if doesn't exist

func (*Op) BalancerDialTime

func (op *Op) BalancerDialTime(elapsed time.Duration, err error) *Op

BalancerDialTime records a balancer dial time relative to a given start time (in milliseconds) if and only if there is no error.

func (*Op) Begin

func (op *Op) Begin(name string) *Op

Begin mimics the similar method from ops.Op

func (*Op) Cancel

func (op *Op) Cancel()

Cancel mimics the similar method from ops.Op

func (*Op) ChainedProxy

func (op *Op) ChainedProxy(name string, addr string, protocol string, network string, multiplexed bool) *Op

ChainedProxy attaches chained proxy information to the Context

func (*Op) CoreDialTime

func (op *Op) CoreDialTime(elapsed time.Duration, err error) *Op

CoreDialTime records a core dial time relative to a given start time (in milliseconds) if and only if there is no error.

func (*Op) DialTime

func (op *Op) DialTime(elapsed time.Duration, err error) *Op

DialTime records a dial time relative to a given start time (in milliseconds) if and only if there is no error.

func (*Op) End

func (op *Op) End()

End mimics the similar method from ops.Op

func (*Op) FailIf

func (op *Op) FailIf(err error) error

FailIf mimics the similar method from ops.op

func (*Op) Go

func (op *Op) Go(fn func())

Go mimics the similar method from ops.Op

func (*Op) HTTPStatusCode

func (op *Op) HTTPStatusCode(code int) *Op

func (*Op) OriginFromRequest

func (op *Op) OriginFromRequest(req *http.Request) *Op

OriginFromRequest attaches the origin to the Context based on the request's Host property.

func (*Op) OriginPort

func (op *Op) OriginPort(origin string, defaultPort string) *Op

Origin attaches the origin to the Context

func (*Op) ProxyAddr

func (op *Op) ProxyAddr(v string) *Op

ProxyAddr attaches proxy server address to the Context

func (*Op) ProxyMultiplexed

func (op *Op) ProxyMultiplexed(v bool) *Op

func (*Op) ProxyName

func (op *Op) ProxyName(name string) *Op

ProxyName attaches the name of the proxy and the inferred datacenter to the Context

func (*Op) ProxyNetwork

func (op *Op) ProxyNetwork(v string) *Op

ProxyNetwork attaches proxy server's network (tcp or kcp) to the Context

func (*Op) ProxyProtocol

func (op *Op) ProxyProtocol(v string) *Op

ProxyProtocol attaches proxy server's protocol (http, https or obfs4) to the Context

func (*Op) ProxyType

func (op *Op) ProxyType(v ProxyType) *Op

ProxyType attaches proxy type to the Context

func (*Op) Request

func (op *Op) Request(req *http.Request) *Op

Request attaches key information of an `http.Request` to the Context.

func (*Op) Response

func (op *Op) Response(r *http.Response) *Op

Response attaches key information of an `http.Response` to the Context. If the response has corresponding Request it will call Request internally.

func (*Op) Set

func (op *Op) Set(key string, value interface{}) *Op

Set mimics the similar method from ops.Op

func (*Op) SetDynamic

func (op *Op) SetDynamic(key string, valueFN func() interface{}) *Op

SetDynamic mimics the similar method from ops.Op

func (*Op) SetMetric

func (op *Op) SetMetric(name string, value borda.Val) *Op

SetMetric sets a named metric. Metrics will be reported as borda values rather than dimensions.

func (*Op) SetMetricAvg

func (op *Op) SetMetricAvg(name string, value float64) *Op

func (*Op) SetMetricMax

func (op *Op) SetMetricMax(name string, value float64) *Op

func (*Op) SetMetricMin

func (op *Op) SetMetricMin(name string, value float64) *Op

func (*Op) SetMetricPercentile

func (op *Op) SetMetricPercentile(name string, value float64) *Op

func (*Op) SetMetricSum

func (op *Op) SetMetricSum(name string, value float64) *Op

func (*Op) UserAgent

func (op *Op) UserAgent(v string) *Op

UserAgent attaches a user agent to the Context.

func (*Op) Wrapped

func (op *Op) Wrapped() ops.Op

type ProxyType

type ProxyType string

ProxyType is the type of various proxy channel

const (
	// ProxyNone means direct access, not proxying at all
	ProxyNone ProxyType = "none"
	// ProxyChained means access through Lantern hosted chained server
	ProxyChained ProxyType = "chained"
	// ProxyFronted means access through domain fronting
	ProxyFronted ProxyType = "fronted"

	// NB - a beam is like a tracing ID and has nothing to do with the application named "beam"
	CtxKeyBeam = contextKey("beam")
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL