Documentation ¶
Index ¶
- Variables
- func ByteCountIEC(b int64) string
- func ByteCountSI(b int64) string
- func Copy(source interface{}) interface{}
- func CopyFiles(src, dst string, BUFFERSIZE int64) error
- func CopyStrPtr(s *string) *string
- func DirCompare(dirRoot1, dirRoot2 string) (bool, error)
- func DirReverseLookup(name, homePath string) string
- func ExtractMatches(buffer []byte, patterns map[string]*regexp.Regexp) map[string][][]string
- func FormatFullName(first, middle, family string) string
- func FormatMessage(indent, width int, indentFirst, capitalize bool, format string, ...) string
- func FormatMultilineString(input string, indent, width int, padFirstIndent bool, splitEven bool) (string, bool)
- func GetItemsWithMatchAtPath(keyPath, keyValueMatch string, valueMapArray []interface{}) ([]interface{}, error)
- func GetValueAtPath(keyPath string, valueMap interface{}) (interface{}, error)
- func HashString(s, prefix string) (string, error)
- func InvokeWithTimeout(fn func(), timeout time.Duration) bool
- func JoinListAsSentence(format string, list []string, quoteListItems bool) string
- func LinkPaths(linkSrc, linkDest string) error
- func LockTimeout(mx *sync.Mutex, timeout time.Duration) bool
- func MD5DirAll(dirRoot string) (map[string][md5.Size]byte, error)
- func MustGetValueAtPath(keyPath string, valueMap interface{}) interface{}
- func NewChunkReadSeeker(source io.ReaderAt, offset, chunkSize int64) io.ReadSeeker
- func NewChunkWriteSeeker(dest io.WriterAt, offset, chunkSize int64) io.WriteSeeker
- func PtrToStr(s string) *string
- func RandomString(n int) string
- func ReadJSONDelimiter(decoder *json.Decoder, delimiter json.Delim) (json.Token, error)
- func RepeatString(s string, n int, out io.Writer)
- func SetValueAtPath(keyPath string, value interface{}, valueMap interface{}) error
- func SortValueMap(keyPath string, valueMapArray interface{}) error
- func SplitString(input string, indent, width int) []string
- func Unzip(zippedData []byte, dest string) ([]string, error)
- func UnzipStream(reader io.ReaderAt, size int64, dest string) ([]string, error)
- func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool
- type ChunkReadSeeker
- type ChunkWriteSeeker
- type ExecTimer
- type SSHClient
- func SSHDial(network, address string, config *ssh.ClientConfig) (*SSHClient, error)
- func SSHDialWithKey(address, user string, key []byte) (*SSHClient, error)
- func SSHDialWithKeyWithPassphrase(address, user string, key []byte, passphrase string) (*SSHClient, error)
- func SSHDialWithPasswd(address, user, passwd string) (*SSHClient, error)
- func (c *SSHClient) Close() error
- func (c *SSHClient) Cmd(cmd string) *remoteScript
- func (c *SSHClient) Script(script string) *remoteScript
- func (c *SSHClient) ScriptFile(fname string) *remoteScript
- func (c *SSHClient) Shell() *remoteShell
- func (c *SSHClient) Terminal(config *SSHTerminalConfig) *remoteShell
- type SSHTerminalConfig
- type TaskDispatcher
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ByteCountIEC ¶
func ByteCountSI ¶
func Copy ¶
func Copy(source interface{}) interface{}
Creates an exact duplicae of struct behind the given interface
in: source - data structure to create a copy of out: a copy of the given source data structure
func CopyFiles ¶
Copies a source file to the given destination file path. The function uses a buffer that optimizes the copy operation.
func CopyStrPtr ¶
func DirCompare ¶
DirCompare compares the digests of all files in the given directories and returns whether the directory contents match or not
func DirReverseLookup ¶
Searches from the given path for a directory of the given name. If the directory is found in the user's home directory then it is returned. If not found the the search continues up the directory tree. If directory is not found then it will be created at the given path.
func ExtractMatches ¶
func FormatFullName ¶
Return a formated full name
func FormatMessage ¶
func FormatMultilineString ¶
func GetItemsWithMatchAtPath ¶
func GetItemsWithMatchAtPath(keyPath, keyValueMatch string, valueMapArray []interface{}) ([]interface{}, error)
Returns the map from an array of maps with the key matching the given regex.
in: keyPath - key path where path separator is '/' in: valueMapArray - nested map of maps to lookup key in
func GetValueAtPath ¶
func HashString ¶
func InvokeWithTimeout ¶
Invoke the given function and waits for it to complete within the specified timeout. Returns false if function call times out. If timeout is 0 then call will wait indefinitely until function call completes.
func JoinListAsSentence ¶
func LinkPaths ¶
Creates a symbolic link to the given src path. If windows then hard copy is done as some tools are unable to follow windows links
func LockTimeout ¶
Waits for the lock for the specified max timeout. Returns false if waiting timed out.
func MD5DirAll ¶
MD5All reads all the files in the file tree rooted at root and returns a map from file path to the MD5 sum of the file's contents. If the directory walk fails or any read operation fails, MD5All returns an error. In that case, MD5All does not wait for inflight read operations to complete.
func MustGetValueAtPath ¶
func MustGetValueAtPath(keyPath string, valueMap interface{}) interface{}
Returns the value at the given path within a nested map instance
in: keyPath - key path where path separator is '/' in: valueMap - nested map of maps to lookup key in out: the value at the given path
func NewChunkReadSeeker ¶
func NewChunkReadSeeker(source io.ReaderAt, offset, chunkSize int64) io.ReadSeeker
func NewChunkWriteSeeker ¶
func NewChunkWriteSeeker(dest io.WriterAt, offset, chunkSize int64) io.WriteSeeker
func RandomString ¶
func ReadJSONDelimiter ¶
Reads a specified JSON delimiter from a json stream decoder. If the expected delimiter is not read then an error is returned.
in: decoder - an instance of a json decoder stream reader in: delimiter - the delimiter expected to be read as the next token out: the json token read
func SetValueAtPath ¶
Sets a value at the given path within a nested map instance
in: keyPath - key path where path separator is '/' in: value - value to set in: valueMap - nested map of maps to lookup key in
func SortValueMap ¶
Sorts the given array of maps using the given key path as the sort key
in: keyPath - key path where path separator is '/' in: valueMapArray - an array of maps to be sorted
func SplitString ¶
Types ¶
type ChunkReadSeeker ¶
type ChunkReadSeeker struct {
// contains filtered or unexported fields
}
Chunk reader seeker
type ChunkWriteSeeker ¶
type ChunkWriteSeeker struct {
// contains filtered or unexported fields
}
Chunk write
type ExecTimer ¶
type ExecTimer struct {
// contains filtered or unexported fields
}
An execution timer will execute a call back after a specified period of time. The call back can inform the timer to resume to trigger at the same interval by returning 0 or update the interval by returning the next interval period in milliseconds. When the timer first starts it invokes the call back to determin the trigger interval.
func NewExecTimer ¶
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
func SSHDial ¶
func SSHDial( network, address string, config *ssh.ClientConfig, ) (*SSHClient, error)
dial starts a client connection to the given SSH server.
func SSHDialWithKey ¶
starts a client connection to the given SSH server with key authmethod.
func SSHDialWithKeyWithPassphrase ¶
func SSHDialWithKeyWithPassphrase( address, user string, key []byte, passphrase string, ) (*SSHClient, error)
same as DialWithKey but with a passphrase to decrypt the private key
func SSHDialWithPasswd ¶
starts a client connection to the given SSH server with passwd authmethod.
func (*SSHClient) ScriptFile ¶
run the given script file on a client
func (*SSHClient) Shell ¶
func (c *SSHClient) Shell() *remoteShell
create a noninteractive shell on client
func (*SSHClient) Terminal ¶
func (c *SSHClient) Terminal(config *SSHTerminalConfig) *remoteShell
create an interactive shell on client
type SSHTerminalConfig ¶
type SSHTerminalConfig struct { Term string Height int Weight int Modes ssh.TerminalModes }
type TaskDispatcher ¶
type TaskDispatcher struct {
// contains filtered or unexported fields
}
func NewTaskDispatcher ¶
func NewTaskDispatcher(bufferSize int, putTimeout time.Duration) *TaskDispatcher
func (*TaskDispatcher) RunTask ¶
func (td *TaskDispatcher) RunTask( name string, taskFn func(inData interface{}) (outData interface{}, err error), ) *task
func (*TaskDispatcher) Start ¶
func (td *TaskDispatcher) Start(numWorkers int)
func (*TaskDispatcher) Stop ¶
func (td *TaskDispatcher) Stop()