pkg

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2014 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpBackoff

func ExpBackoff(last time.Duration, max time.Duration) (next time.Duration)

func NewThreadsafeSet

func NewThreadsafeSet(values ...string) *tsafeSet

func NewUnsafeSet

func NewUnsafeSet(values ...string) *unsafeSet

func ParseFilepath

func ParseFilepath(path string) string

ParseFilepath expands ~ and ~user constructions. If user or $HOME is unknown, do nothing.

func TrimToDashes

func TrimToDashes(args []string) []string

TrimToDashes takes a slice of strings (e.g. a command line) and returns everything after the first double dash (--), if any are present

Types

type Clock added in v0.14.0

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

Clock provides an interface that packages can use instead of directly using the time module, so that chronology-related behavior can be tested

func NewFakeClock added in v0.14.0

func NewFakeClock() Clock

NewFakeClock returns a Clock which can be manually ticked through time for testing.

func NewRealClock added in v0.14.0

func NewRealClock() Clock

NewRealClock returns a Clock which simply delegates calls to the actual time package; it should be used by packages in production.

type Event

type Event string

type EventStream

type EventStream interface {
	Next(stop chan struct{}) chan Event
}

EventStream generates a channel which will emit an event as soon as one of interest occurs. Any background operation associated with the channel should be terminated when stop is closed.

type FakeClock added in v0.14.0

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

func (*FakeClock) After added in v0.14.0

func (fc *FakeClock) After(d time.Duration) <-chan time.Time

After mimics time.After; it waits for the given duration to elapse on the FakeClock, then sends the current time on the returned channel.

func (*FakeClock) Sleep added in v0.14.0

func (fc *FakeClock) Sleep(d time.Duration)

Sleep blocks until the given duration has passed on the FakeClock

func (*FakeClock) Sleepers added in v0.14.0

func (fc *FakeClock) Sleepers() int

Sleepers returns the number of sleepers currently waiting for FakeClock to reach a certain time

func (*FakeClock) Tick added in v0.14.0

func (fc *FakeClock) Tick(d time.Duration)

Tick advances FakeClock to a new point in time, ensuring channels from any previous invocations of After are notified appropriately before returning

type LoggingHTTPTransport

type LoggingHTTPTransport struct {
	http.Transport
}

func (*LoggingHTTPTransport) RoundTrip

func (lt *LoggingHTTPTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

type PeriodicReconciler

type PeriodicReconciler interface {
	Run(stop chan bool)
}

func NewPeriodicReconciler

func NewPeriodicReconciler(interval time.Duration, recFunc func(), eStream EventStream) PeriodicReconciler

NewPeriodicReconciler creates a PeriodicReconciler that will run recFunc at least every ival, or in response to anything emitted from EventStream.Next()

type Set

type Set interface {
	Add(string)
	Remove(string)
	Contains(string) bool
	Equals(Set) bool
	Length() int
	Values() []string
	Copy() Set
	Sub(Set) Set
}

Jump to

Keyboard shortcuts

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