ops

package
v7.6.86 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 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 Average added in v7.6.23

type Average [2]float64

Average holds the total plus a count in order to calculate the arithmatic mean

func (Average) Get added in v7.6.23

func (a Average) Get() interface{}

func (Average) MarshalJSON added in v7.6.23

func (a Average) MarshalJSON() ([]byte, error)

Average is marshalled to JSON as its final float64 value.

func (Average) Merge added in v7.6.23

func (a Average) Merge(_b Val) Val

type Float added in v7.6.23

type Float Sum

Float is an alias for Sum, it is deprecated, using Sum instead

func (Float) Get added in v7.6.23

func (a Float) Get() interface{}

func (Float) Merge added in v7.6.23

func (a Float) Merge(b Val) Val

type Max added in v7.6.23

type Max float64

Max is a float value that gets reduced by taking the highest value.

func (Max) Get added in v7.6.23

func (a Max) Get() interface{}

func (Max) Merge added in v7.6.23

func (a Max) Merge(b Val) Val

type Min added in v7.6.23

type Min float64

Min is a float value that gets reduced by taking the lowest value.

func (Min) Get added in v7.6.23

func (a Min) Get() interface{}

func (Min) Merge added in v7.6.23

func (a Min) Merge(b Val) Val

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 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")
)

type Ptile added in v7.6.23

type Ptile []float64

func (Ptile) Get added in v7.6.23

func (a Ptile) Get() interface{}

func (Ptile) Merge added in v7.6.23

func (a Ptile) Merge(b Val) Val

type Sum added in v7.6.23

type Sum float64

Sum is float value that gets reduced by plain addition.

func (Sum) Get added in v7.6.23

func (a Sum) Get() interface{}

func (Sum) Merge added in v7.6.23

func (a Sum) Merge(b Val) Val

type Val added in v7.6.23

type Val interface {
	// Get gets the final value (either a float64 or []float64)
	Get() interface{}

	// Merges merges another value with this one, using logic specific to the type
	// of value.
	Merge(b Val) Val
}

Val represents a value that can be reduced by a reducing submitter.

func Avg added in v7.6.23

func Avg(val float64) Val

Avg creates a value that gets reduced by taking the arithmetic mean of the values.

func Percentile added in v7.6.23

func Percentile(val float64) Val

Percentile stores individual values so that they can be used in a percentile in the DB

func WeightedAvg added in v7.6.23

func WeightedAvg(val float64, weight float64) Val

WeightedAvg is like Avg but the value is weighted by a given weight.

Jump to

Keyboard shortcuts

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