package state import ( "context" "sync" "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/weather" ) type WeatherState struct { updates []*weather.WeatherUpdate keep int ctx context.Context tracer trace.Tracer meter metric.Meter *sync.RWMutex } type Opts struct { Ctx context.Context KeepLast int } func NewWeatherState(opts *Opts) *WeatherState { if opts.KeepLast < 1 { opts.KeepLast = 1 } return &WeatherState{ updates: make([]*weather.WeatherUpdate, 0), keep: opts.KeepLast, ctx: opts.Ctx, tracer: otel.GetTracer(opts.Ctx, "weatherState"), meter: otel.GetMeter(opts.Ctx, "weatherState"), } }