broadcastmessage

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewValidator

func NewValidator(dbClient mongo.DbClient) *baseValidator

Types

type API

type API interface {
	common.CrudAPI
	GetActive(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	onChangeListener chan<- bool,
	actionLogger logger.ActionLogger,
) API

type AggregationResult

type AggregationResult struct {
	Data       []BroadcastMessage `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 BroadcastMessage

type BroadcastMessage struct {
	ID      string `bson:"_id" json:"_id" binding:"id"`
	Payload `bson:",inline"`
}

type FilteredQuery

type FilteredQuery struct {
	pagination.FilteredQuery
	SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=_id message"`
}

type Payload

type Payload struct {
	Color   string           `bson:"color" json:"color" binding:"required,iscolor"`
	Message string           `bson:"message" json:"message" binding:"required"`
	Start   datetime.CpsTime `bson:"start" json:"start" binding:"required" swaggertype:"integer"`
	End     datetime.CpsTime `bson:"end" json:"end" binding:"required" swaggertype:"integer"`

	Created *datetime.CpsTime `bson:"created,omitempty" json:"created,omitempty" swaggertype:"integer"`
	Updated *datetime.CpsTime `bson:"updated,omitempty" json:"updated,omitempty" swaggertype:"integer"`

	Maintenance bool `bson:"-" json:"maintenance,omitempty"`
}

type Service

type Service interface {
	Start(ctx context.Context, ch <-chan bool)
}

Service is used to implement websocket room for broadcast messages.

func NewService

func NewService(
	store Store,
	websocketHub websocket.Hub,
	interval time.Duration,
	logger zerolog.Logger,
) Service

type Store

type Store interface {
	Insert(ctx context.Context, model *BroadcastMessage) error
	GetById(ctx context.Context, id string) (*BroadcastMessage, error)
	Find(ctx context.Context, query FilteredQuery) (*AggregationResult, error)
	Update(ctx context.Context, model *BroadcastMessage) (bool, error)
	Delete(ctx context.Context, id string) (bool, error)
	GetActive(ctx context.Context) ([]BroadcastMessage, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	maintenanceAdapter config.MaintenanceAdapter,
) Store

Jump to

Keyboard shortcuts

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