Documentation ¶
Index ¶
- Variables
- func EstimateRemainingTime(timeStart time.Time, current int64, total int64) (percentage float64, remaining time.Duration)
- func GetUint32Diff(newCount uint32, oldCount uint32) uint32
- func LoadEd25519PrivateKeysFromEnvironment(name string) ([]ed25519.PrivateKey, error)
- func LoadStringFromEnvironment(name string) (string, error)
- func ParseEd25519PrivateKeyFromString(key string) (ed25519.PrivateKey, error)
- func ParseEd25519PublicKeyFromString(key string) (ed25519.PublicKey, error)
- func ParseIPNet(entry string) (*net.IPNet, error)
- func RandomInsecure(min int, max int) int
- func ReadFromFile(filename string, data interface{}) error
- func ReadJSONFromFile(filename string, data interface{}) error
- func ReturnErrIfCtxDone(ctx context.Context, err error) error
- func WaitForChannelClosed(ctx context.Context, ch chan struct{}) error
- func WriteJSONToFile(filename string, data interface{}, perm os.FileMode) (err error)
- func WriteToFile(filename string, data interface{}, perm os.FileMode) (err error)
- type SyncEvent
- type TimeHeap
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidKeyLength = errors.New("invalid key length")
)
Functions ¶
func EstimateRemainingTime ¶ added in v0.5.0
func EstimateRemainingTime(timeStart time.Time, current int64, total int64) (percentage float64, remaining time.Duration)
EstimateRemainingTime estimates the remaining time for a running operation and returns the finished percentage.
func GetUint32Diff ¶
GetUint32Diff returns the difference between newCount and oldCount and catches overflows
func LoadEd25519PrivateKeysFromEnvironment ¶ added in v1.0.0
func LoadEd25519PrivateKeysFromEnvironment(name string) ([]ed25519.PrivateKey, error)
LoadEd25519PrivateKeysFromEnvironment loads ed25519 private keys from the given environment variable.
func LoadStringFromEnvironment ¶ added in v1.0.0
LoadStringFromEnvironment loads a string from the given environment variable.
func ParseEd25519PrivateKeyFromString ¶ added in v1.0.0
func ParseEd25519PrivateKeyFromString(key string) (ed25519.PrivateKey, error)
func ParseEd25519PublicKeyFromString ¶ added in v1.0.0
func RandomInsecure ¶
RandomInsecure returns a random int in the range of min to max. the result is not cryptographically secure. RandomInsecure is inclusive max value.
func ReadFromFile ¶ added in v1.0.0
ReadFromFile reads structured binary data from the file named by filename to data. A successful call returns err == nil, not err == EOF. ReadFromFile uses binary.Read to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func ReadJSONFromFile ¶ added in v1.0.0
ReadJSONFromFile reads JSON data from the file named by filename to data. ReadJSONFromFile uses json.Unmarshal to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func ReturnErrIfCtxDone ¶ added in v1.0.0
ReturnErrIfCtxDone returns the given error if the provided context is done.
func WaitForChannelClosed ¶ added in v1.0.0
WaitForChannelClosed waits until the channel is closed or the context is done. If the context was done, the event should be manually deregistered afterwards to clean up memory.
func WriteJSONToFile ¶ added in v1.0.0
WriteJSONToFile writes the JSON representation of data to a file named by filename. If the file does not exist, WriteJSONToFile creates it with permissions perm (before umask); otherwise WriteJSONToFile truncates it before writing, without changing permissions. WriteJSONToFile uses json.MarshalIndent to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
func WriteToFile ¶ added in v1.0.0
WriteToFile writes the binary representation of data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions. WriteToFile uses binary.Write to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.
Types ¶
type SyncEvent ¶ added in v1.0.0
func NewSyncEvent ¶ added in v1.0.0
func NewSyncEvent() *SyncEvent
func (*SyncEvent) DeregisterEvent ¶ added in v1.0.0
func (se *SyncEvent) DeregisterEvent(key interface{})
DeregisterEvent removes a registed event to free the memory if not used.
func (*SyncEvent) RegisterEvent ¶ added in v1.0.0
func (se *SyncEvent) RegisterEvent(key interface{}) chan struct{}
RegisterEvent creates a unique channel for the key which can be used to signal global events.
type TimeHeap ¶
type TimeHeap struct {
// contains filtered or unexported fields
}
TimeHeap implements a heap sorted by time, where older elements are popped during GetAveragePerSecond call.
func (*TimeHeap) GetAveragePerSecond ¶
GetAveragePerSecond calculates the average per second of all entries in the given duration. older elements are removed from the container.