helpers

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CharsetCharUpperCase = []rune("ABCDEFGHIJKLMNOPARSTUVWXYZ")
	CharsetCharLowerCase = []rune("abcdefghijklmnopqrstuvwxyz")
	CharsetChars         = append(CharsetCharUpperCase, CharsetCharLowerCase...)
	CharsetDigit         = []rune("0123456789")
	CharsetCharDigit     = append(CharsetChars, CharsetDigit...)
	CharsetHex           = []rune("0123456789abcdef")
)

Functions

func DistinctStrings

func DistinctStrings(elems ...string) []string

func GetPathOfSelf

func GetPathOfSelf() (dir string, err error)

func GzipCompress

func GzipCompress(in []byte) (out []byte, err error)

func GzipDecompress

func GzipDecompress(in []byte) (out []byte, err error)

func RandomString

func RandomString(size int, charset []rune) string

func ToStruct

func ToStruct(v map[string]interface{}) *st.Struct

ToStruct converts a map[string]interface{} to a ptypes.Struct

func ToValue

func ToValue(v interface{}) *st.Value

ToValue converts an interface{} to a ptypes.Value

Types

type BashScriptStage

type BashScriptStage struct {
	Name    string
	Scripts []string
}

func NewBashScriptStage

func NewBashScriptStage(name string, scripts ...string) *BashScriptStage

func (*BashScriptStage) AddScripts

func (e *BashScriptStage) AddScripts(scripts ...string) *BashScriptStage

func (*BashScriptStage) EncodedScripts

func (e *BashScriptStage) EncodedScripts(job string) []string

func (*BashScriptStage) SetScripts

func (e *BashScriptStage) SetScripts(scripts ...string) *BashScriptStage

type BashScriptsExecutor

type BashScriptsExecutor struct {
	Id     string
	Env    []string
	Stages []BashScriptStage
}

func NewBashScriptsExecutor

func NewBashScriptsExecutor(id string, env ...string) *BashScriptsExecutor

func (*BashScriptsExecutor) AddEnv

func (e *BashScriptsExecutor) AddEnv(env ...string) *BashScriptsExecutor

func (*BashScriptsExecutor) AddScriptsInStage

func (e *BashScriptsExecutor) AddScriptsInStage(name string, scripts ...string) *BashScriptsExecutor

func (*BashScriptsExecutor) AddStage

func (*BashScriptsExecutor) EncodedScript

func (e *BashScriptsExecutor) EncodedScript() string

func (*BashScriptsExecutor) Perform

func (e *BashScriptsExecutor) Perform() ([]byte, error)

func (*BashScriptsExecutor) SetEnv

func (e *BashScriptsExecutor) SetEnv(env ...string) *BashScriptsExecutor

type FairQueue

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

*

  • Fair Queue:
  • a fifo queue, which is used to help us schedule the
  • sequence of execution *
  • It could also treated as some kind of Lock

func NewFairQueue

func NewFairQueue() *FairQueue

func (*FairQueue) Close

func (q *FairQueue) Close()

It's OK to leave a Go channel open forever and never close it. When the channel is no longer used, it will be garbage collected. -- <https://stackoverflow.com/questions/8593645> However we could provide a close + wait interface, which is used to indicate its finishing

func (*FairQueue) Enqueue

func (q *FairQueue) Enqueue(f func())

func (*FairQueue) Perform

func (q *FairQueue) Perform()

func (*FairQueue) Wait

func (q *FairQueue) Wait()

type SingletonDesc

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

*

  • SingletonDesc provides a simple way to **SKIP** one function
  • If another function is in executing

func NewSingleton

func NewSingleton() *SingletonDesc

func (*SingletonDesc) Acquire

func (s *SingletonDesc) Acquire(f func())

type WaitGroupWithState

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

func NewWaitGroupWithState

func NewWaitGroupWithState() *WaitGroupWithState

func (*WaitGroupWithState) Add

func (wg *WaitGroupWithState) Add(delta int64) int64

func (*WaitGroupWithState) Done

func (wg *WaitGroupWithState) Done() int64

func (*WaitGroupWithState) State

func (wg *WaitGroupWithState) State() int64

func (*WaitGroupWithState) Wait

func (wg *WaitGroupWithState) Wait()

Jump to

Keyboard shortcuts

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