util

package
v0.0.0-...-dc1ddd1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakePanicTrace

func MakePanicTrace(err interface{}) string

func PanicToError

func PanicToError(fn func()) (err error)

Runs the given function and converts any panic encountered while doing so into an error. Useful for sending to channels that will close

func RandId

func RandId(idlen int) string

creates a random identifier of the specified length

func RandomSeed

func RandomSeed() (seed int64, err error)

func SecureRandId

func SecureRandId(idlen int) (id string, err error)

like RandId, but uses a crypto/rand for secure random identifiers

func SecureRandIdOrPanic

func SecureRandIdOrPanic(idlen int) string

Types

type Broadcast

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

func NewBroadcast

func NewBroadcast() *Broadcast

func (*Broadcast) In

func (b *Broadcast) In() chan interface{}

func (*Broadcast) Reg

func (b *Broadcast) Reg() chan interface{}

func (*Broadcast) UnReg

func (b *Broadcast) UnReg(listener chan interface{})

type Ring

type Ring struct {
	sync.Mutex
	*list.List
	// contains filtered or unexported fields
}

func NewRing

func NewRing(capacity int) *Ring

func (*Ring) Add

func (r *Ring) Add(item interface{}) interface{}

func (*Ring) Slice

func (r *Ring) Slice() []interface{}

type Shutdown

type Shutdown struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A small utility class for managing controlled shutdowns

func NewShutdown

func NewShutdown() *Shutdown

func (*Shutdown) Begin

func (s *Shutdown) Begin()

func (*Shutdown) Complete

func (s *Shutdown) Complete()

func (*Shutdown) WaitBegin

func (s *Shutdown) WaitBegin()

func (*Shutdown) WaitComplete

func (s *Shutdown) WaitComplete()

Jump to

Keyboard shortcuts

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