Documentation ¶
Index ¶
- func Diff(a, b []string) []string
- func InterfaceToObject(data, result interface{}) error
- func RandHexString(n int) string
- func RandInt(n int) int
- func RandIntRange(min, max int) int
- func RandString(n int) string
- func ToMap(a []string) map[string]struct{}
- func ToPtr(v interface{}) interface{}
- func Tomapstr(m map[string]*string) map[string]string
- func Tomapstrptr(m map[string]string) map[string]*string
- type Checkable
- type Runnable
- type SignalListener
- type WriterWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff returns the elements in `a` that aren't in `b` Good algorithm as it's O(n) instead of a naive O(n2)
func InterfaceToObject ¶
func InterfaceToObject(data, result interface{}) error
func RandHexString ¶
func RandIntRange ¶
func RandString ¶
Types ¶
type Checkable ¶
type Checkable interface { ID() string // CheckLiveness MUST return an error if the long living task is not running otherwise nil CheckLiveness(context.Context) error // CheckReadiness MUST return an error if the long living task is not running otherwise nil CheckReadiness(context.Context) error }
Checkable allows to
type Runnable ¶
type Runnable interface { // Start long living task in a parallel goroutine // // It MUST return an error if and only if it failed at starting the long living task Start(context.Context) error // Stop gracefully interrupts long living task // // Stop SHOULD make sure underlying long living task has gracefully interrupted execution before returning // // In case context timeouts or is canceled Stop MUST // 1. [optional] Try to kill long living task (MUST not block on doing this) // 2. Return immediately with an error // // In any other case Stop MUST not return before the long live task // has gracefully interrupted execution Stop(context.Context) error // Close clean the runnable // // Init, Start, Stop, MUST NOT be called after Close Close() error // Error returns any possible error met by the runnable // // It MAY be // - an error that raised Init, Start, Stop or Close // - an error that raised on the long living task which force prematured Stop Error() error }
Runnable manages running long living task
type SignalListener ¶
type SignalListener struct {
// contains filtered or unexported fields
}
SignalListener listen to signals and trigger callbacks
func NewSignalListener ¶
func NewSignalListener(cb func(os.Signal)) *SignalListener
NewSignalListener creates a new SignalListener
type WriterWrapper ¶
Click to show internal directories.
Click to hide internal directories.