implement redis and noop recorders
This commit is contained in:
@ -4,11 +4,13 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather/recorder/recorders"
|
||||
)
|
||||
|
||||
@ -21,9 +23,10 @@ type WeatherRecorder struct {
|
||||
}
|
||||
|
||||
type Opts struct {
|
||||
Ctx context.Context
|
||||
Recorder recorders.Recorder // If nil, will use memory recorder
|
||||
KeepLast int
|
||||
AppConfig *config.AmbientLocalExporterConfig
|
||||
Ctx context.Context
|
||||
Recorder recorders.Recorder // If nil, will use memory recorder
|
||||
KeepLast int
|
||||
}
|
||||
|
||||
func MustNewWeatherRecorder(opts *Opts) *WeatherRecorder {
|
||||
@ -36,10 +39,14 @@ func MustNewWeatherRecorder(opts *Opts) *WeatherRecorder {
|
||||
}
|
||||
|
||||
opts.Recorder.Init(opts.Ctx, &recorders.RecorderOpts{
|
||||
AppConfig: opts.AppConfig,
|
||||
RetainLast: opts.KeepLast,
|
||||
BaseCtx: opts.Ctx,
|
||||
})
|
||||
|
||||
zerolog.Ctx(opts.Ctx).Info().Str("recorderType", opts.Recorder.Name()).
|
||||
Msg("weather update recorder ready")
|
||||
|
||||
return &WeatherRecorder{
|
||||
ctx: opts.Ctx,
|
||||
recorder: opts.Recorder,
|
||||
|
Reference in New Issue
Block a user