service

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyticsReader

type AnalyticsReader interface {
	QuerySummary(ctx context.Context, params domain.SummaryParams) ([]domain.SummaryRow, bool, error)
	QueryUsageByMeta(ctx context.Context, params domain.MetaUsageParams) ([]domain.MetaUsageRow, bool, error)
	Ping(ctx context.Context) error
}

AnalyticsReader defines the analytical query capabilities.

type UsageService

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

UsageService handles business logic for usage events

func NewUsageService

func NewUsageService(repo *repository.Repository) *UsageService

NewUsageService creates a new usage service

func (*UsageService) Analytics

func (s *UsageService) Analytics() AnalyticsReader

Analytics returns the configured AnalyticsReader, if any.

func (*UsageService) AnalyticsMissing

func (s *UsageService) AnalyticsMissing() bool

AnalyticsMissing reports ClickHouse configured but not connected yet.

func (*UsageService) ExpectAnalytics

func (s *UsageService) ExpectAnalytics()

ExpectAnalytics marks ClickHouse as configured, so readiness can report it missing until WithAnalytics is called.

func (*UsageService) GetSummary

func (s *UsageService) GetSummary(ctx context.Context, params domain.SummaryParams) ([]domain.SummaryRow, bool, error)

GetSummary returns aggregated usage statistics

func (*UsageService) GetUsageByMeta

func (s *UsageService) GetUsageByMeta(ctx context.Context, params domain.MetaUsageParams) ([]domain.MetaUsageRow, bool, error)

GetUsageByMeta returns usage aggregated over events carrying a meta key/value, split by an optional second meta key plus vendor and model.

func (*UsageService) RecordEvent

func (s *UsageService) RecordEvent(ctx context.Context, event *domain.UsageEvent) (bool, error)

RecordEvent records a single usage event

func (*UsageService) RecordEvents

func (s *UsageService) RecordEvents(ctx context.Context, events []*domain.UsageEvent) (created, duplicates int, err error)

RecordEvents records multiple usage events in a batch

func (*UsageService) WithAnalytics

func (s *UsageService) WithAnalytics(r AnalyticsReader) *UsageService

WithAnalytics configures an analytical engine (e.g., ClickHouse).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL