Documentation ¶
Overview ¶
Package utils provides miscellaneous utilities for ProxyFS.
Index ¶
- func ByteSliceToString(byteSlice []byte) (str string)
- func ByteSliceToUint32(byteSlice []byte) (u32 uint32, ok bool)
- func ByteSliceToUint64(byteSlice []byte) (u64 uint64, ok bool)
- func ByteToHexDigit(u8 byte) (digit byte)
- func FetchRandomBool() (randBool bool)
- func FetchRandomByteSlice(len int) (randByteSlice []byte)
- func FetchRandomUint64() (randUint64 uint64)
- func GetAFnName(level int) string
- func GetCallerFnName() string
- func GetFnName() string
- func GetFuncPackage(level int) (fn string, pkg string, gid uint64)
- func GetGID() uint64
- func GetGoId() uint64
- func HexStrToUint64(value string) (uint64, error)
- func JSONify(input interface{}, indentify bool) (output string)
- func MyStackTrace() (stackTrace string)
- func PathToAcctContObj(path string) (accountName string, containerName string, objectName string, err error)
- func RandomizeList(theList *list.List)
- func StackTraceToGoId(buf []byte) uint64
- func StackTracesToMap(buf []byte) (traceMap map[uint64]string, stateMap map[uint64]string)
- func StringToByteSlice(str string) (byteSlice []byte)
- func Uint32ToByteSlice(u32 uint32) (byteSlice []byte)
- func Uint64ToByteSlice(u64 uint64) (byteSlice []byte)
- func Uint64ToHexStr(value uint64) string
- type EventDuration
- type EventStats
- type EventTime
- type MultiWaiterWaitGroup
- type Profiler
- type Stopwatch
- func (sw *Stopwatch) Elapsed() time.Duration
- func (sw *Stopwatch) ElapsedMs() int64
- func (sw *Stopwatch) ElapsedMsString() string
- func (sw *Stopwatch) ElapsedNs() int64
- func (sw *Stopwatch) ElapsedNsString() string
- func (sw *Stopwatch) ElapsedSec() int64
- func (sw *Stopwatch) ElapsedSecString() string
- func (sw *Stopwatch) ElapsedString() string
- func (sw *Stopwatch) ElapsedUs() int64
- func (sw *Stopwatch) ElapsedUsString() string
- func (sw *Stopwatch) Restart()
- func (sw *Stopwatch) Stop() time.Duration
- type TryLockMutex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteSliceToString ¶
func ByteSliceToUint32 ¶
func ByteSliceToUint64 ¶
func ByteToHexDigit ¶
ByteToHexDigit returns the (uppercase) hex character representation of the low order nibble of the byte supplied.
func FetchRandomBool ¶
func FetchRandomBool() (randBool bool)
func FetchRandomByteSlice ¶
func FetchRandomUint64 ¶
func FetchRandomUint64() (randUint64 uint64)
func GetAFnName ¶
Return a string containing calling function and package
func GetCallerFnName ¶
func GetCallerFnName() string
GetCallerFnName returns a string containing the name of the calling function. This can be useful for debug prints.
func GetFnName ¶
func GetFnName() string
GetFnName returns a string containing the name of the running function and its package. This can be useful for debug prints.
func GetFuncPackage ¶
Return separage strings containing calling function and package
XXX TODO TEMPORARY: also return goroutine id
func GetGID ¶
func GetGID() uint64
XXX TODO TEMPORARY:
I know our go-overlords would prefer that we knew nothing about goroutines, but logging the goroutine context can be useful when trying to debug things like locking.
Intent is to have this now and hopefully remove it once we've gotten debugged.
func HexStrToUint64 ¶
func MyStackTrace ¶
func MyStackTrace() (stackTrace string)
Return the stack track of the caller, including this function.
func PathToAcctContObj ¶
func RandomizeList ¶
func StackTraceToGoId ¶
Given the first line of a stack trace parse out and return the goroutine ID. The first line of a stack trace starts with: "goroutine 7 [runnable]:\n"
This function really should have some error checking to insure it matched "goroutine" though there's no way to log a failure.
func StackTracesToMap ¶
Convert a slice filled in by runtime.Stack(buf, true), which contains the stack traceback of one or more go routines, into a map goid -> stack.
buffer looks like:
goroutine 1 [running]: main.main() /vagrant/guest_workspaces/swift-runway-001/ProxyFS/src/github.com/swiftstack/ProxyFS/stacktrace.go:27 +0x21e
goroutine 5 [runnable]: main.killTime() /vagrant/guest_workspaces/swift-runway-001/ProxyFS/src/github.com/swiftstack/ProxyFS/stacktrace.go:9 created by main.main /vagrant/guest_workspaces/swift-runway-001/ProxyFS/src/github.com/swiftstack/ProxyFS/stacktrace.go:14 +0x47
goroutine 7 [runnable]: main.killTime() /vagrant/guest_workspaces/swift-runway-001/ProxyFS/src/github.com/swiftstack/ProxyFS/stacktrace.go:9 created by main.main /vagrant/guest_workspaces/swift-runway-001/ProxyFS/src/github.com/swiftstack/ProxyFS/stacktrace.go:16 +0x77
func StringToByteSlice ¶
func Uint32ToByteSlice ¶
func Uint64ToByteSlice ¶
func Uint64ToHexStr ¶
Types ¶
type EventDuration ¶
type EventDuration struct {
// contains filtered or unexported fields
}
type EventStats ¶
type EventStats struct {
// contains filtered or unexported fields
}
func GetStats ¶
func GetStats(profiles map[int]*Profiler) *EventStats
func (*EventStats) DumpToStdout ¶
func (s *EventStats) DumpToStdout()
func (*EventStats) DumpToString ¶
func (s *EventStats) DumpToString(condensed bool) (out string)
type MultiWaiterWaitGroup ¶
MultiWaiterWaitGroup emulates the behavior of sync.WaitGroup while enabling multiple waiters.
Unline sync.WaitGroup, however, you must allocate a MultiWaiterWaitGroup with a call to FetchMultiWaiterWaitGroup().
func FetchMultiWaiterWaitGroup ¶
func FetchMultiWaiterWaitGroup() (mwwg *MultiWaiterWaitGroup)
func (*MultiWaiterWaitGroup) Add ¶
func (mwwg *MultiWaiterWaitGroup) Add(delta int)
func (*MultiWaiterWaitGroup) Done ¶
func (mwwg *MultiWaiterWaitGroup) Done()
func (*MultiWaiterWaitGroup) Wait ¶
func (mwwg *MultiWaiterWaitGroup) Wait()
type Profiler ¶
type Profiler struct { Timer *Stopwatch // contains filtered or unexported fields }
func NewProfiler ¶
func NewProfilerIf ¶
NewProfilerIf allocates and returns a new Profiler, if condition is true.
func (*Profiler) AddEventNow ¶
type Stopwatch ¶
type Stopwatch struct { StartTime time.Time StopTime time.Time ElapsedTime time.Duration IsRunning bool }
func NewStopwatch ¶
func NewStopwatch() *Stopwatch
func (*Stopwatch) ElapsedMsString ¶
func (*Stopwatch) ElapsedNsString ¶
func (*Stopwatch) ElapsedSec ¶
func (*Stopwatch) ElapsedSecString ¶
func (*Stopwatch) ElapsedString ¶
func (*Stopwatch) ElapsedUsString ¶
type TryLockMutex ¶
type TryLockMutex struct {
// contains filtered or unexported fields
}
TryLockMutex is used to support a timeout a the lock request
func NewTryLockMutex ¶
func NewTryLockMutex() (tryLockMutex *TryLockMutex)
func (*TryLockMutex) Lock ¶
func (tryLockMutex *TryLockMutex) Lock()
func (*TryLockMutex) TryLock ¶
func (tryLockMutex *TryLockMutex) TryLock(timeout time.Duration) (gotIt bool)
func (*TryLockMutex) Unlock ¶
func (tryLockMutex *TryLockMutex) Unlock()