Documentation
¶
Overview ¶
Package dashboard implements the admin console subdomain of the platform module: cross-domain reporting aggregates. Every foreign-domain access is a read through a port typed with the platform's own read models; the composition root adapts the owning modules' facades to them.
Index ¶
- type Cache
- type Deps
- type LogReader
- type NodeStatsReader
- type OrderStatsReader
- type Service
- func (s *Service) QueryRevenueStatistics(ctx context.Context) (*dto.RevenueStatisticsResponse, error)
- func (s *Service) QueryServerTotalData(ctx context.Context) (*dto.ServerTotalDataResponse, error)
- func (s *Service) QueryTicketWaitReply(ctx context.Context) (*dto.TicketWaitRelpyResponse, error)
- func (s *Service) QueryUserStatistics(ctx context.Context) (*dto.UserStatisticsResponse, error)
- type TicketStatsReader
- type TrafficStatsReader
- type UserStatsReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) *redis.StringCmd
Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
}
Cache is the dashboard's snapshot cache; the redis client satisfies it structurally.
type Deps ¶
type Deps struct {
Orders OrderStatsReader
Users UserStatsReader
Tickets TicketStatsReader
Nodes NodeStatsReader
Traffic TrafficStatsReader
Logs LogReader
Cache Cache
}
Deps declares the subdomain's dependencies; the module facade forwards them from the composition root.
type LogReader ¶ added in v1.21.0
type LogReader interface {
FindByDatesType(ctx context.Context, dates []string, typ uint8) ([]*log.SystemLog, error)
FindFirstByDateType(ctx context.Context, date string, typ uint8) (*log.SystemLog, error)
}
LogReader reads the archived daily statistics.
type NodeStatsReader ¶
type NodeStatsReader interface {
CountServersByReportStatus(ctx context.Context, cutoff time.Time) (int64, int64, error)
OnlineUserSubscribeGlobal(ctx context.Context) (int64, error)
QueryServerList(ctx context.Context, ids []int64) ([]*readmodel.Server, error)
}
NodeStatsReader reads the node inventory and online counts.
type OrderStatsReader ¶
type OrderStatsReader interface {
QueryDateOrders(ctx context.Context, date time.Time) (readmodel.OrdersTotal, error)
QueryMonthlyOrders(ctx context.Context, date time.Time) (readmodel.OrdersTotal, error)
QueryTotalOrders(ctx context.Context) (readmodel.OrdersTotal, error)
QueryDailyOrdersList(ctx context.Context, date time.Time) ([]readmodel.OrdersTotalWithDate, error)
QueryMonthlyOrdersList(ctx context.Context, date time.Time) ([]readmodel.OrdersTotalWithDate, error)
QueryDateUserCounts(ctx context.Context, date time.Time) (int64, int64, error)
QueryMonthlyUserCounts(ctx context.Context, date time.Time) (int64, int64, error)
QueryTotalUserCounts(ctx context.Context) (int64, int64, error)
}
OrderStatsReader reads the order and revenue totals.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service computes the admin console figures for the platform facade.
func (*Service) QueryRevenueStatistics ¶
func (s *Service) QueryRevenueStatistics(ctx context.Context) (*dto.RevenueStatisticsResponse, error)
QueryRevenueStatistics summarizes order revenue for today, this month (with its daily breakdown) and all time (with the last months' breakdown). The totals are required; a breakdown that cannot be read is left out. The summary is cached for a minute.
func (*Service) QueryServerTotalData ¶
QueryServerTotalData summarizes node traffic for the admin console: today's live totals and rankings, yesterday's archived rankings, the month's traffic so far and the online counts. The summary is cached for a minute.
func (*Service) QueryTicketWaitReply ¶
QueryTicketWaitReply counts the tickets waiting for a staff reply.
func (*Service) QueryUserStatistics ¶
QueryUserStatistics counts registrations and paying users for today, this month (with its daily breakdown) and all time (with the last months' breakdown). Every figure is optional: one whose source fails is logged and left at zero. The summary is cached for a minute.
type TicketStatsReader ¶
TicketStatsReader reads the number of tickets waiting for a reply.
type TrafficStatsReader ¶
type TrafficStatsReader interface {
QueryTrafficSummary(ctx context.Context, start, end time.Time) (*readmodel.TotalTraffic, error)
TopServersTrafficByDay(ctx context.Context, date time.Time, limit int) ([]readmodel.ServerTrafficRanking, error)
TopUsersTrafficByDay(ctx context.Context, date time.Time, limit int) ([]readmodel.UserTrafficRanking, error)
}
TrafficStatsReader reads the traffic totals and rankings.
type UserStatsReader ¶
type UserStatsReader interface {
QueryRegisterUserTotal(ctx context.Context) (int64, error)
QueryRegisterUserTotalByDate(ctx context.Context, date time.Time) (int64, error)
QueryRegisterUserTotalByMonthly(ctx context.Context, date time.Time) (int64, error)
QueryDailyUserStatisticsList(ctx context.Context, date time.Time) ([]readmodel.UserStatisticsWithDate, error)
QueryMonthlyUserStatisticsList(ctx context.Context, date time.Time) ([]readmodel.UserStatisticsWithDate, error)
}
UserStatsReader reads the registration counts.