Documentation
¶
Index ¶
- Constants
- Variables
- func Cached[T any](g func() (T, error), cache time.Duration) func() (T, error)
- func CaptureLogs(c chan<- Param)
- func DecodeOther(other, cc any) error
- func DefaultPort(conn string, port int) string
- func DefaultScheme(uri, scheme string) string
- func ErrorAsJson(err error) any
- func FormatValue(format string, val any) string
- func FormattedVersion() string
- func GetNextOccurrence(weekdays []int, timeStr string, tz string) (time.Time, error)
- func Getenv(key string, def ...string) string
- func LocalIPs() (ips []net.IPNet)
- func LogLevel(defaultLevel string, areaLevels map[string]string)
- func Loggers(cb func(string, *Logger))
- func Masked(s string) string
- func NewConfigError(err error) error
- func ParseDuration(s string) (time.Duration, error)
- func RedactDefaultHook(s string) []string
- func ReplaceFormatted(s string, kv map[string]any) (string, error)
- func ResetCached()
- func ResettableCached[T any](g func() (T, error), cache time.Duration) *cached[T]
- func SignFromPower(current, power float64) float64
- func System() string
- func TemplateName(typ string, other map[string]any) string
- func TokenWithExpiry(token *oauth2.Token) *oauth2.Token
- func TypeWithTemplateName(typ string, other map[string]any) string
- func WithLogger(ctx context.Context, log *Logger) context.Context
- type Cacheable
- type ConfigError
- type Logger
- type Monitor
- func (m *Monitor[T]) Done() <-chan struct{}
- func (m *Monitor[T]) Get() (T, error)
- func (m *Monitor[T]) GetContext(ctx context.Context) (T, error)
- func (m *Monitor[T]) GetFunc(get func(T)) error
- func (m *Monitor[T]) GetFuncContext(ctx context.Context, get func(T)) error
- func (m *Monitor[T]) Set(val T)
- func (m *Monitor[T]) SetFunc(set func(T) T)
- func (m *Monitor[T]) WithClock(clock clock.Clock) *Monitor[T]
- type Param
- type ParamCache
- type Queue
- type Redactor
- type Shard
- type Sharder
- type Snapshot
- type Tee
- type Value
Constants ¶
const DevVersion = "0.0.0"
Variables ¶
var ( // RedactReplacement is the default replacement string RedactReplacement = "***" // RedactHook is the hook for expanding different representations of // redaction items. Setting to nil will disable redaction. RedactHook = RedactDefaultHook )
var ( // Version of executable Version = DevVersion // Commit of executable Commit = "" )
var CtxLogger = struct{}{}
var LogAreaPadding = 6
LogAreaPadding of log areas
var ( // OutThreshold is the default console log level OutThreshold = jww.LevelInfo )
Functions ¶
func CaptureLogs ¶
func CaptureLogs(c chan<- Param)
CaptureLogs appends uiWriter to relevant log levels for loggers created before uiChan is initialized
func DecodeOther ¶
DecodeOther uses mapstructure to decode into target structure. Unused keys cause errors.
func DefaultPort ¶
DefaultPort appends given port to connection if not specified
func DefaultScheme ¶
DefaultScheme prepends given scheme to uri if not specified
func ErrorAsJson ¶
ErrorAsJson returns an error as json-formattable struct
func FormatValue ¶
FormatValue will apply specific formatting in addition to standard sprintf
func FormattedVersion ¶
func FormattedVersion() string
FormattedVersion returns the version, untagged builds carry a build timestamp
func GetNextOccurrence ¶
GetNextOccurrence returns the next occurrence of the given time on the specified weekdays.
func NewConfigError ¶
func RedactDefaultHook ¶
RedactDefaultHook expands a redaction item to include URL encoding
func ReplaceFormatted ¶
ReplaceFormatted replaces all occurrences of ${key} with formatted val from the kv map
func ResetCached ¶
func ResetCached()
func ResettableCached ¶
ResettableCached wraps a getter with a cache. It returns a `Cacheable`. Instead of the cached getter, the `Get()` and `Reset()` methods are exposed.
func SignFromPower ¶
SignFromPower is a helper function to create signed current from signed power bypassing already signed current
func TokenWithExpiry ¶
TokenWithExpiry decorates an oauth2.Token with the expiry from the ExpiresIn property
Types ¶
type ConfigError ¶
type ConfigError struct {
// contains filtered or unexported fields
}
ConfigError wraps yaml configuration errors from mapstructure
func (ConfigError) Error ¶
func (e ConfigError) Error() string
func (ConfigError) Unwrap ¶
func (e ConfigError) Unwrap() error
type Logger ¶
Logger wraps a jww notepad to avoid leaking implementation detail
func NewLoggerWithLoadpoint ¶
NewLoggerWithLoadpoint creates a logger with reference to at loadpoint
type Monitor ¶
type Monitor[T any] struct { // contains filtered or unexported fields }
Monitor monitors values for regular updates
func NewMonitor ¶
NewMonitor created a new monitor with given timeout
func (*Monitor[T]) Done ¶
func (m *Monitor[T]) Done() <-chan struct{}
Done signals if monitor has been updated at least once
func (*Monitor[T]) GetContext ¶
GetContext returns the current value or ErrOutdated if timeout exceeded. The context can cancel the blocking first-call wait.
func (*Monitor[T]) GetFunc ¶
GetFunc returns the current value or ErrOutdated if timeout exceeded while holding the lock
func (*Monitor[T]) GetFuncContext ¶
GetFuncContext returns the current value or ErrOutdated if timeout exceeded while holding the lock. The context can cancel the blocking first-call wait.
func (*Monitor[T]) Set ¶
func (m *Monitor[T]) Set(val T)
Set updates the current value and timestamp
type ParamCache ¶
type ParamCache struct {
// contains filtered or unexported fields
}
ParamCache is a data store
func (*ParamCache) All ¶
func (c *ParamCache) All() []Param
All provides a copy of the cached values
func (*ParamCache) Run ¶
func (c *ParamCache) Run(in <-chan Param)
Run adds input channel's values to cache
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue is based on https://github.com/golang-ds/queue
func (*Queue[T]) Dequeue ¶
Dequeue removes and returns the front element of the queue. It returns false if the queue was empty.
func (*Queue[T]) Enqueue ¶
func (q *Queue[T]) Enqueue(data T)
Enqueue adds an element to the end of the queue.
func (*Queue[T]) First ¶
First returns the front element of the queue. It returns false if the queue was empty.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor implements log redaction
func (*Redactor) RotatingSlot ¶
RotatingSlot reserves a redaction slot for periodically refreshed secrets like access and refresh tokens. Updating the slot replaces the previous values instead of appending, so the redaction list does not grow with every refresh.
type Sharder ¶
type Sharder interface {
ModifiedShards() iter.Seq2[string, any]
AllShards() iter.Seq2[string, any]
}
Sharder splits data into chunks, omitting unmodified chunks
func NewSharder ¶
NewSharder creates a Sharder that splits structs into sub-structs for space-efficient socket publishing Passing anything else than a struct will panic
type Snapshot ¶
type Snapshot func([]Param)
Snapshot requests a copy of the cache state at the parameter's position in the stream. It runs on the cache's goroutine and must not block for long.
type Tee ¶
type Tee struct {
// contains filtered or unexported fields
}
Tee distributes parameters to subscribers
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package discovery finds hosts in the local network using unprivileged methods
|
Package discovery finds hosts in the local network using unprivileged methods |
|
Package grid converts between phase currents and power for the configured grid.
|
Package grid converts between phase currents and power for the configured grid. |
|
Package shortrfc3339 implements helpers for working with shortened RFC-3339 compliant timestamps (those without seconds).
|
Package shortrfc3339 implements helpers for working with shortened RFC-3339 compliant timestamps (those without seconds). |
|
generate
command
|
|
|
Package urlvalues provides functions for working with url.Values
|
Package urlvalues provides functions for working with url.Values |