stats

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("stats not found")
)
View Source
var Module = fx.Module(
	"stats",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("stats")
	}),
	fx.Provide(newRepository, fx.Private),
	fx.Provide(queue.NewStatsQueue),
	fx.Provide(NewService),
	fx.Invoke(func(lc fx.Lifecycle, s *Service, log *zap.Logger) {
		wg := sync.WaitGroup{}
		ctx, cancel := context.WithCancel(context.Background())
		lc.Append(fx.Hook{
			OnStart: func(_ context.Context) error {
				wg.Add(1)
				go func() {
					defer wg.Done()

					log.Info("stats processing started")
					err := s.Process(ctx)
					if err != nil && err != context.Canceled {
						log.Error("failed to process stats", zap.Error(err))
					}
					log.Info("stats processing stopped")
				}()
				return nil
			},
			OnStop: func(_ context.Context) error {
				cancel()
				wg.Wait()
				return nil
			},
		})
	}),
)

Functions

This section is empty.

Types

type Labels

type Labels map[string]string

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(stats *repository, links *links.Service, queue *queue.StatsQueue, log *zap.Logger) *Service

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (api.Stats, error)

func (*Service) Process

func (s *Service) Process(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳