Back to

Package dmetering

Latest Go to latest

The latest major version is .

Published: May 29, 2020 | License: Apache-2.0 | Module:


func EmitWithContext

func EmitWithContext(ev Event, ctx context.Context)

func EmitWithCredentials

func EmitWithCredentials(ev Event, creds authenticator.Credentials)

func GetStatusCounters

func GetStatusCounters() (total, errors uint64)

func NewMeteringMiddleware

func NewMeteringMiddleware(next http.Handler, metering Metering, source, kind string, trackRequestsAndResponses, trackIngressAndEgressBytes bool) http.Handler

func NewMeteringMiddlewareFunc

func NewMeteringMiddlewareFunc(metering Metering, source, kind string) func(http.Handler) http.Handler

func NewMeteringMiddlewareFuncWithOptions

func NewMeteringMiddlewareFuncWithOptions(metering Metering, source, kind string, trackRequestsAndResponses, trackIngressAndEgressBytes bool) func(http.Handler) http.Handler

func Register

func Register(name string, factory FactoryFunc)

func SetDefaultMeter

func SetDefaultMeter(m Metering)

func SetLogger

func SetLogger(logger *zap.Logger)

func WaitToFlush

func WaitToFlush()

type Event

type Event struct {
	Source            string
	Kind              string
	Method            string
	RequestsCount     int64
	ResponsesCount    int64
	IngressBytes      int64
	EgressBytes       int64
	IdleTime          int64
	RateLimitHitCount int64

type FactoryFunc

type FactoryFunc func(config string) (Metering, error)

type Metering

type Metering interface {
	EmitWithContext(ev Event, ctx context.Context)
	EmitWithCredentials(ev Event, creds authenticator.Credentials)
	GetStatusCounters() (total, errors uint64)

func New

func New(config string) (Metering, error)

type MeteringMiddleware

type MeteringMiddleware struct {
	// contains filtered or unexported fields

func (*MeteringMiddleware) ServeHTTP

func (m *MeteringMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MeteringResponseWriter

type MeteringResponseWriter struct {
	// contains filtered or unexported fields

func (*MeteringResponseWriter) Write

func (w *MeteringResponseWriter) Write(data []byte) (int, error)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier