messageratestats

package
v0.0.0-...-0ad5b3e Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 23 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 ListRequest

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

	SearchRequest
}

type SearchRequest

type SearchRequest struct {
	EventTypes     []string `form:"event_types[]" json:"event_types"`
	ConnectorNames []string `form:"connector_names[]" json:"connector_names"`
}

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.

type Watcher

type Watcher interface {
	StartWatch(ctx context.Context, connId, userID, roomId string, data any) error
	StopWatch(connId, roomId string) error
}

func NewWatcher

func NewWatcher(
	hub websocket.Hub,
	store Store,
	encoder encoding.Encoder,
	decoder encoding.Decoder,
	tickDuration time.Duration,
	logger zerolog.Logger,
) Watcher

Jump to

Keyboard shortcuts

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