feat: predictions

This commit is contained in:
Anatoly Antonov 2025-06-25 23:23:16 +03:00
parent 42e7924be9
commit 11be8f351f
42 changed files with 2221 additions and 516 deletions

View file

@ -4,22 +4,20 @@ import (
"context"
"time"
"go.uber.org/zap"
"git.intra.yksa.space/gsn/predictor/internal/pkg/log"
)
type Service struct {
cfg *Config
redis Redis
grib Grib
logger *zap.Logger
cfg *Config
redis Redis
grib Grib
}
func New(cfg *Config, gribService Grib, redisService Redis, logger *zap.Logger) (*Service, error) {
func New(cfg *Config, gribService Grib, redisService Redis) (*Service, error) {
svc := &Service{
cfg: cfg,
redis: redisService,
grib: gribService,
logger: logger,
cfg: cfg,
redis: redisService,
grib: gribService,
}
return svc, nil
@ -42,12 +40,12 @@ func (s *Service) Update(ctx context.Context) error {
// Start starts the service
func (s *Service) Start() {
s.logger.Info("service started")
log.Ctx(context.Background()).Info("service started")
}
// Stop stops the service
func (s *Service) Stop() {
s.logger.Info("service stopped")
log.Ctx(context.Background()).Info("service stopped")
}
// Close closes the service and releases resources
@ -55,3 +53,12 @@ func (s *Service) Close() error {
s.Stop()
return nil
}
func (s *Service) GetGribStatus(ctx context.Context) (ready bool, lastUpdate time.Time, isFresh bool, errMsg string) {
if gribStatus, ok := s.grib.(interface {
GetStatus() (ready bool, lastUpdate time.Time, isFresh bool, errMsg string)
}); ok {
return gribStatus.GetStatus()
}
return false, time.Time{}, false, "grib service does not implement GetStatus"
}