common

package
v0.0.0-...-3735483 Latest Latest
Warning

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

Go to latest
Published: May 11, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackgroundContext

func BackgroundContext(ctx context.Context) context.Context

BackgroundContext returns a context that is specifically not a child of the provided parent context wrt any cancellation or deadline of the parent, so that it contains all values only.

func IsTemporary

func IsTemporary(err error) bool

func Logger

func Logger(ctx context.Context) logrus.FieldLogger

Logger returns the structured logger.

func LoggerWithFields

func LoggerWithFields(ctx context.Context, fields logrus.Fields) (context.Context, logrus.FieldLogger)

LoggerWithFields returns a child context of the provided parent that contains a logger with additional fields from the parent's logger, it returns the new child logger, as well.

func MinDuration

func MinDuration(f, s time.Duration) time.Duration

func NewClampWriter

func NewClampWriter(buf io.Writer, maxResponseSize uint64, overflowErr error) io.Writer

func NewRNG

func NewRNG(seed int64) *rand.Rand

func NewSyslogHook

func NewSyslogHook(url *url.URL, prefix string) error

func SetLogDest

func SetLogDest(to, prefix string)

func SetLogLevel

func SetLogLevel(ll string)

func WithLogger

func WithLogger(ctx context.Context, l logrus.FieldLogger) context.Context

WithLogger stores the logger.

Types

type Backoff

type Backoff int

func (*Backoff) Sleep

func (b *Backoff) Sleep(ctx context.Context)

type BoxTime

type BoxTime struct{}

func (BoxTime) After

func (BoxTime) After(d time.Duration) <-chan time.Time

func (BoxTime) Now

func (BoxTime) Now() time.Time

func (BoxTime) Sleep

func (BoxTime) Sleep(d time.Duration)

type Clock

type Clock interface {
	Now() time.Time
	Sleep(time.Duration)
	After(time.Duration) <-chan time.Time
}

type GhostReader

type GhostReader interface {
	io.Reader
	io.Closer
	Swap(r io.Reader) io.Reader
}

func NewGhostReader

func NewGhostReader() GhostReader

type GhostWriter

type GhostWriter interface {
	io.Writer
	io.Closer
	Swap(r io.Writer) io.Writer
}

func NewGhostWriter

func NewGhostWriter() GhostWriter

type Temporary

type Temporary interface {
	Temporary() bool
}

type WaitGroup

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

func NewWaitGroup

func NewWaitGroup() *WaitGroup

func (*WaitGroup) AddSession

func (r *WaitGroup) AddSession(delta uint64) bool

AddSession manipulates the session counter by adding the delta value. Incrementing the session counter is not possible and will set return value to false if a close was initiated.

func (*WaitGroup) CloseGroup

func (r *WaitGroup) CloseGroup()

CloseGroup initiates a close and blocks until session counter becomes zero.

func (*WaitGroup) CloseGroupNB

func (r *WaitGroup) CloseGroupNB() chan struct{}

CloseGroupNB is non-blocking version of CloseGroup which returns a channel that can be waited on.

func (*WaitGroup) Closer

func (r *WaitGroup) Closer() chan struct{}

Closer returns a channel that is closed if WaitGroup is in closing state

func (*WaitGroup) DoneSession

func (r *WaitGroup) DoneSession()

DoneSession decrements 1 from accumulated sessions and wakes up listeners when this reaches zero.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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