messageratestats

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntervalMinute = "minute"
	IntervalHour   = "hour"
)
View Source
const MinutePointsNumber = 61 // [0;60] = 61

Variables

This section is empty.

Functions

func GetWebsocketHandler

func GetWebsocketHandler(
	hub websocket.Hub,
	pgPoolProvider postgres.PoolProvider,
	logger zerolog.Logger,
	tickDuration time.Duration,
) func(ctx context.Context)

func ValidateListRequest

func ValidateListRequest(sl validator.StructLevel)

Types

type API

type API interface {
	List(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
) API

type ListRequest

type ListRequest struct {
	Interval string           `form:"interval" json:"interval" binding:"required,oneof=minute hour"`
	From     datetime.CpsTime `form:"from" json:"from" binding:"required" swaggertype:"integer"`
	To       datetime.CpsTime `form:"to" json:"to" binding:"required" swaggertype:"integer"`
}

type RatePerMinute

type RatePerMinute struct {
	Time int64 `json:"time"`
	Rate int64 `json:"rate"`
}

type StatsListResponse

type StatsListResponse struct {
	Data []StatsResponse `json:"data"`
	Meta struct {
		DeletedBefore *datetime.CpsTime `json:"deleted_before,omitempty" swaggertype:"integer"`
	} `json:"meta"`
}

type StatsResponse

type StatsResponse struct {
	ID   int64 `bson:"_id" json:"time"`
	Rate int64 `bson:"received" json:"rate"`
}

type Store

type Store interface {
	Find(context.Context, ListRequest) ([]StatsResponse, error)
	// GetDeletedBeforeForHours gets the lower bound time value for hourly request.
	GetDeletedBeforeForHours(ctx context.Context) (*datetime.CpsTime, error)
}

func NewStore

func NewStore(db mongo.DbClient, pgPoolProvider postgres.PoolProvider) Store

NewStore creates new store.

Jump to

Keyboard shortcuts

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