Documentation ¶
Index ¶
- func Base64To256BitKey(ks string) (*[32]byte, error)
- func GUID() string
- func GetEnvironment() map[string]string
- func GetMonitoringLabels() map[string]string
- func GetPortNumber(address string) (int, error)
- func LogError(err error, msg string)
- func LogErrorf(err error, msg string, v ...interface{})
- func LogFatal(err error, msg string)
- func LogFatalf(err error, msg string, v ...interface{})
- func To256BitKey(key []byte) (*[32]byte, error)
- func UpdateBaseDirectory(cfg ConfigView, baseDir string)
- func UpdateServerDefaults(cfg ConfigView, grpcAddress string, httpAddress string)
- type Config
- func (c *Config) AllSettings() map[string]interface{}
- func (c *Config) GetBool(k string) bool
- func (c *Config) GetDuration(k string) time.Duration
- func (c *Config) GetFloat64(k string) float64
- func (c *Config) GetInt(k string) int
- func (c *Config) GetString(k string) string
- func (c *Config) Set(k string, v interface{})
- func (c *Config) SetDefault(k string, v interface{})
- type ConfigView
- type Counter
- type Crypter
- type ListenSpec
- type Pubsub
- type Stopwatch
- type Switch
- type ThrottledCall
- type UnitOfWork
- type WorkQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64To256BitKey ¶
Base64To256BitKey converts an encryption key []byte to *[32]byte. Used for importing encryption keys from configs.
func GetMonitoringLabels ¶
GetMonitoringLabels returns all static monitoring labels.
func GetPortNumber ¶
GetPortNumber from an address string. Example: localhost:123 returns 123, [::]:456 returns 456.
func To256BitKey ¶
To256BitKey converts an encryption key []byte to *[32]byte. Used for importing encryption keys from configs.
func UpdateBaseDirectory ¶
func UpdateBaseDirectory(cfg ConfigView, baseDir string)
UpdateBaseDirectory updates configuration defaults with the new base directory.
func UpdateServerDefaults ¶
func UpdateServerDefaults(cfg ConfigView, grpcAddress string, httpAddress string)
UpdateServerDefaults updates the address of each server's defaults.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a mutable configuration.
func (*Config) AllSettings ¶
AllSettings gets all configuration values.
func (*Config) GetDuration ¶
GetDuration returns a configuration entry as a time.Duration.
func (*Config) GetFloat64 ¶
GetFloat64 returns a configuration entry as a float64.
func (*Config) SetDefault ¶
SetDefault sets the default value of a configuration
type ConfigView ¶
type ConfigView interface { // GetString returns a configuration entry as a string. GetString(string) string // GetInt returns a configuration entry as a integer. GetInt(string) int // GetBool returns a configuration entry as a boolean. GetBool(string) bool // GetFloat64 returns a configuration entry as a float64. GetFloat64(string) float64 // GetDuration returns a configuration entry as a time.Duration. GetDuration(string) time.Duration }
ConfigView is a view of the configuration.
func DefaultConfig ¶
func DefaultConfig() ConfigView
DefaultConfig returns a configuration view with internal defaults set. This should only be used for internal testing.
func MustLoadConfig ¶
func MustLoadConfig() ConfigView
MustLoadConfig loads configuration for the application.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter can be incremented atomically.
type Crypter ¶
type Crypter interface { Encrypt(plainText []byte) ([]byte, error) Decrypt(cipherText []byte) ([]byte, error) }
Crypter can encrypt and decrypt data.
func MustCrypter ¶
MustCrypter returns a new crypter based on the input.
func NewAES256Crypter ¶
NewAES256Crypter creates a new AES-256-GCM crypter.
func NewCrypter ¶
NewCrypter returns a new crypter based on the input.
func NewNullEncrypter ¶
func NewNullEncrypter() Crypter
NewNullEncrypter creates a crypter that does nothing. Useful for testing but should not be used in production.
type ListenSpec ¶
type ListenSpec struct { Port int Address string Protocol string // contains filtered or unexported fields }
ListenSpec is a holder class for an opened port.
func OpenWithAddress ¶
func OpenWithAddress(protocol string, address string) (*ListenSpec, error)
OpenWithAddress opens a port via an address.
func (*ListenSpec) Acquire ¶
func (ls *ListenSpec) Acquire() net.Listener
Acquire returns the listener only once.
func (*ListenSpec) Close ¶
func (ls *ListenSpec) Close() error
Close the port that is being listened to.
func (*ListenSpec) IsOpen ¶
func (ls *ListenSpec) IsOpen() bool
IsOpen indicates that the TCP port is open.
type Pubsub ¶
type Pubsub struct {
// contains filtered or unexported fields
}
Pubsub relays messages to subscribers of a topic.
type Stopwatch ¶
type Stopwatch struct {
// contains filtered or unexported fields
}
Stopwatch is used to count difference in time.
func NewStopwatch ¶
func NewStopwatch() *Stopwatch
NewStopwatch creates a stop watch at the timestamp it was created.
func NewStopwatchAt ¶
NewStopwatchAt creates a stop watch at a specific timestamp.
func (*Stopwatch) TickMillis ¶
TickMillis returns the difference in time as milliseconds.
type Switch ¶
type Switch struct {
// contains filtered or unexported fields
}
Switch can be toggled on or off.
type ThrottledCall ¶
type ThrottledCall struct {
// contains filtered or unexported fields
}
ThrottledCall throttles method invocations.
func NewThrottledCall ¶
func NewThrottledCall(name string, delay time.Duration) *ThrottledCall
NewThrottledCall returns a throttler
type WorkQueue ¶
type WorkQueue interface { Enqueue(f UnitOfWork) error Drain() }
WorkQueue is a queue that performs work asynchronously.
func NewWorkQueue ¶
func NewWorkQueue() WorkQueue
NewWorkQueue returns a work queue with the default size.
func NewWorkQueueWithSize ¶
NewWorkQueueWithSize returns a work queue with the specified size.