util

package
v0.0.0-...-c641a3c Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2019 License: Apache-2.0 Imports: 17 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClientDialOpts

func CreateClientDialOpts() ([]grpc.DialOption, error)

CreateClientDialOpts creates the TLC/non-TLS and other common dial options for establishing a grpc server connection to other microservices.

func HandleOSSignals

func HandleOSSignals(cleanup func())

HandleOSSignals handles OS signals interrups and SIGTERM and calls cleanup()

func Retry

func Retry(attempts int, interval time.Duration, description string, logr *logger.LocLoggingEntry, callback func() error) (err error)

Helper retry function

func Round

func Round(f float64) float64

Round a float64

func RoundPlus

func RoundPlus(f float64, places int) float64

RoundPlus rounds a float64 to places

func StdCopy2

func StdCopy2(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)

StdCopy2 is a modified version of io.Copy.

StdCopy2 will demultiplex `src`, assuming that it contains two streams, previously multiplexed together using a StdWriter instance. As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.

StdCopy2 will read until it hits EOF on `src`. It will then return a nil error. In other words: if `err` is non nil, it indicates a real underlying error.

`written` will hold the total number of bytes written to `dstout` and `dsterr`.

func Unzip

func Unzip(src, dest string) error

func UnzipFromBytes

func UnzipFromBytes(archive []byte, target string) error

func Zip

func Zip(source, target string) error

func ZipToBytes

func ZipToBytes(source string) ([]byte, error)

Types

type StdType

type StdType byte

StdType is the type of standard stream a writer can multiplex to.

const (
	// Stdin represents standard input stream type.
	Stdin StdType = iota
	// Stdout represents standard output stream type.
	Stdout
	// Stderr represents standard error steam type.
	Stderr
)

Jump to

Keyboard shortcuts

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