messageratestats

package
Version: v0.0.0-...-ce3930f Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IntervalMinute = "minute"
	IntervalHour   = "hour"
)

Variables

This section is empty.

Functions

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 AggregationResult

type AggregationResult struct {
	Data       []StatsResponse `bson:"data" json:"data"`
	TotalCount int64           `bson:"total_count" json:"total_count"`
}

func (AggregationResult) GetData

func (r AggregationResult) GetData() interface{}

func (AggregationResult) GetTotal

func (r AggregationResult) GetTotal() int64

type ListRequest

type ListRequest struct {
	pagination.Query
	Interval string        `form:"interval" json:"interval" binding:"required,oneof=minute hour"`
	From     types.CpsTime `form:"from" json:"from" binding:"required" swaggertype:"integer"`
	To       types.CpsTime `form:"to" json:"to" binding:"required" swaggertype:"integer"`
	Sort     string        `form:"sort" json:"sort"`
	SortBy   string        `form:"sort_by" json:"sort_by" binding:"oneoforempty=_id received"`
}

type StatsResponse

type StatsResponse struct {
	ID       int64 `bson:"_id" json:"_id"`
	Received int64 `bson:"received" json:"received"`
}

type Store

type Store interface {
	Find(context.Context, ListRequest) (*AggregationResult, error)
}

func NewStore

func NewStore(db mongo.DbClient) Store

NewStore creates new store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL