Documentation ¶
Index ¶
- Variables
- func BackInsertionSort[T any](slice []T, value T, less func(a, b T) bool) []T
- func BackLinearSearch[T any](slice []T, value T, less func(a, b T) bool) int
- func BuildNotificationPayload(updates []ZonedAlarmUpdate) ([]byte, error)
- func CacheControl(maxAge time.Duration) func(http.Handler) http.Handler
- func EnableCORS(origins []string) func(http.Handler) http.Handler
- func Execute() error
- func Golangify[T any](r *http.Request) (*T, error)
- func HTTPLogWrap(logger *logrus.Entry) func(h http.Handler) http.Handler
- func Insert[T any](slice []T, value T, index int) []T
- func InsertSlice[T any](a, b []T, begin, end int) []T
- func IsSubscribedTo(zone string, level api.AlarmLevel, settings api.NotificationSettings) bool
- func JSONify(w http.ResponseWriter, obj interface{})
- func LinearSearch[T any](slice []T, value T, less func(a, b T) bool) int
- func Max[T constraints.Ordered](a, b T) T
- func MayBeSubscribedTo(zone string, settings api.NotificationSettings) bool
- func NewNotificationLogger() *logNotification
- func NopCloser(w io.Writer) io.WriteCloser
- func RecoverWrap(logger *logrus.Entry) func(h http.Handler) http.Handler
- func ZoneIdentifier(hostname, zoneName string) string
- type AlarmLogger
- type AlreadyExistError
- type BatchingFilter
- type CSRFHandler
- type ClimateDataDownsampler
- type ClimateLogger
- type ClosedOlympusServerError
- type GenerateSecretsCommand
- type GenerateVAPIDKeysCommand
- type GracefulServer
- type GrpcSubscription
- type NoClimateRunningError
- type NoTrackingRunningError
- type NotificationFor
- type NotificationSender
- type NotificationSubscription
- type Notifier
- type Olympus
- func (o *Olympus) Close() (err error)
- func (o *Olympus) GetAlarmReports(host, zone string) ([]api.AlarmReport, error)
- func (o *Olympus) GetClimateTimeSerie(host, zone, window string) (api.ClimateTimeSeries, error)
- func (o *Olympus) GetServiceLogs() []api.ServiceLog
- func (o *Olympus) GetZoneReport(host, zone string) (*api.ZoneReport, error)
- func (o *Olympus) GetZones() []api.ZoneReportSummary
- func (o *Olympus) NotifyAlarm(ctx context.Context, zone string, update *api.AlarmUpdate)
- func (o *Olympus) RegisterClimate(ctx context.Context, declaration *api.ClimateDeclaration) (csub *GrpcSubscription[ClimateLogger], err error)
- func (o *Olympus) RegisterTracking(ctx context.Context, declaration *api.TrackingDeclaration) (tsub *GrpcSubscription[TrackingLogger], err error)
- func (o *Olympus) UnregisterClimate(ctx context.Context, host, name string, graceful bool) (err error)
- func (o *Olympus) UnregisterTracker(ctx context.Context, host string, graceful bool) (err error)
- func (o *Olympus) ZoneIsRegistered(host, zone string) bool
- type OlympusGRPCWrapper
- func (o *OlympusGRPCWrapper) Climate(stream api.Olympus_ClimateServer) (err error)
- func (o *OlympusGRPCWrapper) Log(ctx context.Context) *logrus.Entry
- func (o *OlympusGRPCWrapper) SendAlarm(ctx context.Context, update *api.AlarmUpdate) (*empty.Empty, error)
- func (o *OlympusGRPCWrapper) SubscriptionContext() context.Context
- func (o *OlympusGRPCWrapper) Tracking(stream api.Olympus_TrackingServer) (err error)
- type Options
- type PersistentMap
- type RunCommand
- type ServiceLogger
- type TimedValues
- func (d *TimedValues) DeepCopy() TimedValues
- func (d *TimedValues) Downsample(samples int, reference time.Time, unit time.Duration) [][]lttb.Point[float32]
- func (d *TimedValues) FrequencyCutoff(minimumPeriod time.Duration) TimedValues
- func (d *TimedValues) Push(other TimedValues, minimumPeriod time.Duration) bool
- func (d *TimedValues) RollOutOfWindow(window time.Duration)
- func (d *TimedValues) TimeVector(reference time.Time, unit time.Duration) []float32
- type TrackingLogger
- type UnexpectedStreamServerError
- type UpdateFilter
- type VersionCommand
- type WebPushAction
- type WebPushData
- type WebPushNotification
- type WebPushTargetAction
- type ZoneNotFoundError
- type ZonedAlarmUpdate
Constants ¶
This section is empty.
Variables ¶
var BackLogPageSize int = 4000
var CutOfFrequencyRatio float64 = 15.0
var OLYMPUS_VERSION = "v0.5.0-dev-55-gcf95c32"
Current package version
var UnknownEndpointError = errors.New("unknown PushSubscription endpoint")
Functions ¶
func BackInsertionSort ¶
func BackLinearSearch ¶
func BuildNotificationPayload ¶
func BuildNotificationPayload(updates []ZonedAlarmUpdate) ([]byte, error)
func InsertSlice ¶
func IsSubscribedTo ¶
func IsSubscribedTo(zone string, level api.AlarmLevel, settings api.NotificationSettings) bool
func JSONify ¶
func JSONify(w http.ResponseWriter, obj interface{})
func LinearSearch ¶
func Max ¶
func Max[T constraints.Ordered](a, b T) T
func MayBeSubscribedTo ¶
func MayBeSubscribedTo(zone string, settings api.NotificationSettings) bool
func NewNotificationLogger ¶
func NewNotificationLogger() *logNotification
func ZoneIdentifier ¶
Types ¶
type AlarmLogger ¶
type AlarmLogger interface { ActiveAlarmsCount() (warnings int, emergencies int) GetReports() []api.AlarmReport // PushAlarms adds a list of AlarmEvents to this logger. PushAlarms([]*api.AlarmUpdate) }
func NewAlarmLogger ¶
func NewAlarmLogger() AlarmLogger
type AlreadyExistError ¶
type AlreadyExistError string
func (AlreadyExistError) Error ¶
func (a AlreadyExistError) Error() string
type BatchingFilter ¶
type BatchingFilter func(outgoing chan<- []ZonedAlarmUpdate, incoming <-chan ZonedAlarmUpdate)
func BatchAlarmUpdate ¶
func BatchAlarmUpdate(batchPeriod time.Duration) BatchingFilter
Batches alarms updates so they are no more than a batch every silenceWindow
type CSRFHandler ¶
type CSRFHandler struct {
// contains filtered or unexported fields
}
func NewCSRFHandler ¶
func NewCSRFHandler(secret []byte) (*CSRFHandler, error)
func (*CSRFHandler) CheckCSRFCookie ¶
func (hh *CSRFHandler) CheckCSRFCookie(h http.Handler) http.Handler
func (*CSRFHandler) SetCSRFCookie ¶
func (hh *CSRFHandler) SetCSRFCookie(h http.Handler) http.Handler
type ClimateDataDownsampler ¶
type ClimateDataDownsampler interface { // Adds a new list of value to the sampler for a given time.Time // t. If mx is non nil, an asynchronous update will be performed. Add(values TimedValues) // Returns the resulting time series TimeSeries() api.ClimateTimeSeries }
A ClimateDataDownsample is used to keep trace of a set of time series over a certain time window. It optimize system performance by greatly reducing the amount of data.
func NewClimateDataDownsampler ¶
func NewClimateDataDownsampler(window, unit time.Duration, samples int) ClimateDataDownsampler
type ClimateLogger ¶
type ClimateLogger interface { Host() string ZoneName() string ZoneIdentifier() string // PushTarget update current target for this logger. PushTarget(*api.ClimateTarget) // PushReports updates a list of reports to this logger. PushReports([]*api.ClimateReport) GetClimateTimeSeries(window string) api.ClimateTimeSeries GetClimateReport() *api.ZoneClimateReport }
func NewClimateLogger ¶
func NewClimateLogger(declaration *api.ClimateDeclaration) ClimateLogger
type ClosedOlympusServerError ¶
type ClosedOlympusServerError struct{}
func (ClosedOlympusServerError) Error ¶
func (e ClosedOlympusServerError) Error() string
type GenerateSecretsCommand ¶
type GenerateSecretsCommand struct {
// contains filtered or unexported fields
}
func (*GenerateSecretsCommand) Execute ¶
func (c *GenerateSecretsCommand) Execute([]string) error
type GenerateVAPIDKeysCommand ¶
type GenerateVAPIDKeysCommand struct {
// contains filtered or unexported fields
}
func (*GenerateVAPIDKeysCommand) Execute ¶
func (c *GenerateVAPIDKeysCommand) Execute([]string) error
type GracefulServer ¶
func NewGracefulServer ¶
func NewGracefulServer(server *http.Server) GracefulServer
type GrpcSubscription ¶
type GrpcSubscription[T any] struct { // contains filtered or unexported fields }
func (GrpcSubscription[T]) NotifyAlarms ¶
func (s GrpcSubscription[T]) NotifyAlarms(updates []*api.AlarmUpdate)
type NoClimateRunningError ¶
type NoClimateRunningError string
func (NoClimateRunningError) Error ¶
func (z NoClimateRunningError) Error() string
type NoTrackingRunningError ¶
type NoTrackingRunningError string
func (NoTrackingRunningError) Error ¶
func (z NoTrackingRunningError) Error() string
type NotificationFor ¶
type NotificationFor struct { Subscription *webpush.Subscription Updates []ZonedAlarmUpdate }
type NotificationSender ¶
type NotificationSender interface {
Send(NotificationFor) error
}
func NewNotificationSender ¶
func NewNotificationSender() (NotificationSender, error)
type NotificationSubscription ¶
type NotificationSubscription struct { Push *webpush.Subscription Settings api.NotificationSettings }
type Notifier ¶
type Notifier interface { Incoming() chan<- ZonedAlarmUpdate Outgoing() <-chan NotificationFor RegisterPushSubscription(*webpush.Subscription) error UpdatePushSubscription(*api.NotificationSettingsUpdate) error Loop() }
func NewNotifier ¶
type Olympus ¶
type Olympus struct { api.UnimplementedOlympusServer // contains filtered or unexported fields }
func NewOlympus ¶
func (*Olympus) GetAlarmReports ¶
func (o *Olympus) GetAlarmReports(host, zone string) ([]api.AlarmReport, error)
func (*Olympus) GetClimateTimeSerie ¶
func (o *Olympus) GetClimateTimeSerie(host, zone, window string) (api.ClimateTimeSeries, error)
GetClimateTimeSeries returns the time series for a zone within a given window. window should be one of "10m","1h","1d", "1w". It may return a ZoneNotFoundError.
func (*Olympus) GetServiceLogs ¶
func (o *Olympus) GetServiceLogs() []api.ServiceLog
func (*Olympus) GetZoneReport ¶
func (o *Olympus) GetZoneReport(host, zone string) (*api.ZoneReport, error)
func (*Olympus) GetZones ¶
func (o *Olympus) GetZones() []api.ZoneReportSummary
func (*Olympus) NotifyAlarm ¶
func (*Olympus) RegisterClimate ¶
func (o *Olympus) RegisterClimate(ctx context.Context, declaration *api.ClimateDeclaration) (csub *GrpcSubscription[ClimateLogger], err error)
func (*Olympus) RegisterTracking ¶
func (o *Olympus) RegisterTracking(ctx context.Context, declaration *api.TrackingDeclaration) (tsub *GrpcSubscription[TrackingLogger], err error)
func (*Olympus) UnregisterClimate ¶
func (*Olympus) UnregisterTracker ¶
func (*Olympus) ZoneIsRegistered ¶
type OlympusGRPCWrapper ¶
type OlympusGRPCWrapper Olympus
func (*OlympusGRPCWrapper) Climate ¶
func (o *OlympusGRPCWrapper) Climate(stream api.Olympus_ClimateServer) (err error)
func (*OlympusGRPCWrapper) Log ¶
func (o *OlympusGRPCWrapper) Log(ctx context.Context) *logrus.Entry
func (*OlympusGRPCWrapper) SendAlarm ¶
func (o *OlympusGRPCWrapper) SendAlarm(ctx context.Context, update *api.AlarmUpdate) (*empty.Empty, error)
func (*OlympusGRPCWrapper) SubscriptionContext ¶
func (o *OlympusGRPCWrapper) SubscriptionContext() context.Context
func (*OlympusGRPCWrapper) Tracking ¶
func (o *OlympusGRPCWrapper) Tracking(stream api.Olympus_TrackingServer) (err error)
type PersistentMap ¶
func NewPersistentMap ¶
func NewPersistentMap[T any](name string) *PersistentMap[T]
func (*PersistentMap[T]) Save ¶
func (m *PersistentMap[T]) Save() error
func (*PersistentMap[T]) SaveKey ¶
func (m *PersistentMap[T]) SaveKey(key string) (err error)
type RunCommand ¶
type RunCommand struct { Verbose []bool `long:"verbose" short:"v" description:"enables verbose logging, set multiple time to increase the level"` Address string `long:"http-listen" short:"l" description:"Address for the HTTP server" default:":3000"` RPC int `long:"rpc-listen" short:"r" description:"Port for the RPC Service" default:"3001"` AllowCORS []string `long:"allow-cors" description:"allow cors from domain"` OtelEndpoint string `long:"otel-exporter" description:"Open Telemetry exporter endpoint" env:"OLYMPUS_OTEL_ENDPOINT"` }
func (*RunCommand) Execute ¶
func (c *RunCommand) Execute([]string) error
type ServiceLogger ¶
type ServiceLogger interface { Log(ctx context.Context, identifier string, on, graceful bool) Logs() []api.ServiceLog OnServices() []string OffServices() []string }
func NewServiceLogger ¶
func NewServiceLogger() ServiceLogger
type TimedValues ¶
type TimedValues struct {
// contains filtered or unexported fields
}
TimedValues holds a list of time series with a common time vector. Values should be added or removed from the time series only using this struct interface. It is designed and optimized for live data logging, where data is added in real-time as it becomes available, but is robust to out-of-order insertion.
func (*TimedValues) DeepCopy ¶
func (d *TimedValues) DeepCopy() TimedValues
DeepCopy performs a deep copy of the TimedValues.
func (*TimedValues) Downsample ¶
func (d *TimedValues) Downsample(samples int, reference time.Time, unit time.Duration) [][]lttb.Point[float32]
Downsample downsamples the TimedValues to not exceed a given number of samples. The list of resulting time series may contains empty values. After downsampling, the time vector of the series will most likely not correspong to each other, as the LTTB algorithm retains time reference to keep the most representative shape of the original serie.
func (*TimedValues) FrequencyCutoff ¶
func (d *TimedValues) FrequencyCutoff(minimumPeriod time.Duration) TimedValues
FrequencyCutOff creates a new TimedValues from the original one, which frequency does not exceed 1/minimumPeriod.
func (*TimedValues) Push ¶
func (d *TimedValues) Push(other TimedValues, minimumPeriod time.Duration) bool
Push adds another TimedValues to the TimedValues. values may be dropped if it would make the series instantaneous frequency exceed the frequency 1/minimumPeriod. This method is optimized for two scenarios:
- Adding a single value at the end of the TimedValues.
- Adding a large chunk of values to the TimedValues.
It will return true if a value was actually added to the timed value.
func (*TimedValues) RollOutOfWindow ¶
func (d *TimedValues) RollOutOfWindow(window time.Duration)
RollOutOfWindow prunes values which are older than window from the last time in the series.
func (*TimedValues) TimeVector ¶
TimeVector produces a time vector for a series, from a reference point. I.e from the first registered time or the last registered time.
type TrackingLogger ¶
type TrackingLogger interface { TrackingInfo() *api.TrackingInfo PushDiskStatus(*api.DiskStatus) }
func NewTrackingLogger ¶
func NewTrackingLogger(ctx context.Context, declaration *api.TrackingDeclaration) TrackingLogger
type UnexpectedStreamServerError ¶
type UnexpectedStreamServerError struct {
Got, Expected string
}
func (UnexpectedStreamServerError) Error ¶
func (e UnexpectedStreamServerError) Error() string
type UpdateFilter ¶
type UpdateFilter func(outgoing chan<- ZonedAlarmUpdate, incoming <-chan ZonedAlarmUpdate)
func FilterAlarmUpdates ¶
func FilterAlarmUpdates(minimumOn time.Duration) UpdateFilter
type VersionCommand ¶
type VersionCommand struct{}
func (*VersionCommand) Execute ¶
func (c *VersionCommand) Execute([]string) error
type WebPushAction ¶
type WebPushData ¶
type WebPushData struct {
OnActionClick map[string]WebPushTargetAction `json:"onActionClick,omitempty"`
}
type WebPushNotification ¶
type WebPushNotification struct { Title string `json:"title,omitempty"` // Mandatory Body string `json:"body,omitempty"` // Mandatory Actions []WebPushAction `json:"actions,omitempty"` Data WebPushData `json:"data,omitempty"` Icon string `json:"icon,omitempty"` // Yes we would like something : https://web.dev/push-notifications-display-a-notification/#icon Image string `json:"image,omitempty"` // Preferably not see https://web.dev/push-notifications-display-a-notification/#image Badge string `json:"badge,omitempty"` // Yes we would like something : https://web.dev/push-notifications-display-a-notification/#badge Vibrate []int `json:"vibrate,omitempty"` // Seems uneffective Sound string `json:"sound.omitempty"` // Doesn't work }
func NewMultiWebPushNotification ¶
func NewMultiWebPushNotification(updates []ZonedAlarmUpdate) WebPushNotification
func NewSingleWebPushNotification ¶
func NewSingleWebPushNotification(update ZonedAlarmUpdate) WebPushNotification
func NewWebPushNotification ¶
func NewWebPushNotification(updates []ZonedAlarmUpdate) (WebPushNotification, error)
type WebPushTargetAction ¶
type ZoneNotFoundError ¶
type ZoneNotFoundError string
func (ZoneNotFoundError) Error ¶
func (z ZoneNotFoundError) Error() string
type ZonedAlarmUpdate ¶
type ZonedAlarmUpdate struct { Zone string Update *api.AlarmUpdate }
func (ZonedAlarmUpdate) ID ¶
func (u ZonedAlarmUpdate) ID() string
Source Files ¶
- alarm_logger.go
- alarm_update_batcher.go
- alarm_update_filter.go
- climate_data_downsampler.go
- climate_logger.go
- constants.go
- generators.go
- notification_sender.go
- notifier.go
- olympus.go
- olympus_grpc_wrapper.go
- options.go
- persistent_map.go
- run.go
- service_logger.go
- timed_values.go
- tracking_logger.go
- utils.go
- version.go
- version_command.go
- web_server.go