util

package
v0.0.0-...-5db00e0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgListToMap

func ArgListToMap(args ...interface{}) map[string]interface{}

ArgListToMap converts an argument list to a map, e.g. ("key", value, "key2", value2) => {"key": value, "key2", value2}

func CheckHTTPResponse

func CheckHTTPResponse(resp *http.Response, err error) ([]byte, error)

CheckHTTPResponse does some basic error handling and reads the response body into a byte array

func EnsureDir

func EnsureDir(p string) error

EnsureDir ensures a directory exists.

func EnsurePath

func EnsurePath(p string) error

EnsurePath ensures a directory exists, given a file path. This calls path.Dir(p) TODO probably just remove this

func NewDockerClient

func NewDockerClient() (*client.Client, error)

NewDockerClient returns a new docker client. This util handles working around some client/server API version mismatch issues.

func PerRPCPassword

func PerRPCPassword(password string) grpc.DialOption

PerRPCPassword returns a new gRPC DialOption which includes a basic auth. password header in each RPC request.

func SignalContext

func SignalContext(ctx context.Context, sigs ...os.Signal) context.Context

SignalContext will cancel the context when any of the given signals is received.

Types

type IdleTimeout

type IdleTimeout interface {
	Done() <-chan time.Time
	Start()
	Stop()
}

IdleTimeout provides a helper for managing the Pool's idle timeout. Start() and Stop() are used to control the timer, and Done() is used to detect when the timeout has been reached.

 in := make(chan int)
 requestInput(in)
 t := IdleTimeoutAfter(time.Second * 10)
 for {
   select {
   case <-t.Done():
     // ... code to respond to timeout
   case <-in:
     // Reset the timeout.
     t.Start()
   }
}

func NewIdleTimeout

func NewIdleTimeout(d time.Duration) IdleTimeout

NewIdleTimeout returns an IdleTimeout instance for the given duration.

func NoIdleTimeout

func NoIdleTimeout() IdleTimeout

NoIdleTimeout creates an IdleTimeout that never times out.

type MultiError

type MultiError []error

MultiError helps collect multiple errors and implements Go's "error" interface.

func (MultiError) Error

func (m MultiError) Error() string

Error returns all the error strings joined by a newline.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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