Documentation
¶
Overview ¶
Package sitecalc computes the live site quantities (spec 5.5) from the live cache: on a change of a meter value, debounced, and on a refresh tick so missing inputs remove the quantity. Results go back into the live cache; they are never stored.
Index ¶
Constants ¶
const ( Debounce = 250 * time.Millisecond Refresh = time.Second )
Timing (spec 5 step 7).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface {
Subscribe(size int, policy eventbus.Overflow) *eventbus.Subscription
Unsubscribe(s *eventbus.Subscription)
}
Bus is the part of the event bus the calculator subscribes to.
type Cache ¶
type Cache interface {
Get(key string) (livecache.Value, bool)
Set(key string, v livecache.Value, interval time.Duration)
Delete(keys ...string)
}
Cache is the part of the live cache the calculator reads and writes.
type Calculator ¶
type Calculator struct {
// contains filtered or unexported fields
}
Calculator is a restartable component (spec 8.2).
func (*Calculator) LastBeat ¶
func (c *Calculator) LastBeat() time.Time
LastBeat returns the time of the last loop iteration.
func (*Calculator) Start ¶
func (c *Calculator) Start(ctx context.Context) error
Start runs the loop until ctx ends or Stop.
func (*Calculator) State ¶
func (c *Calculator) State() health.State
State is always Healthy: missing inputs are data, not a failure.
func (*Calculator) Stop ¶
func (c *Calculator) Stop() error
Stop ends the loop and waits for it; idempotent.