broadcastmessage

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: 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,
) API

type AggregationResult

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

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

type EditRequest

type EditRequest 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"`

	Author  string            `bson:"author,omitempty" json:"author,omitempty" swaggerignore:"true"`
	Created *datetime.CpsTime `bson:"created,omitempty" json:"-" swaggerignore:"true"`
	Updated *datetime.CpsTime `bson:"updated,omitempty" json:"-" swaggerignore:"true"`
}

type FilteredQuery

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

type Response

type Response struct {
	ID      string           `bson:"_id" json:"_id"`
	Color   string           `bson:"color" json:"color"`
	Message string           `bson:"message" json:"message"`
	Start   datetime.CpsTime `bson:"start" json:"start" swaggertype:"integer"`
	End     datetime.CpsTime `bson:"end" json:"end" swaggertype:"integer"`

	Author  *author.Author    `bson:"author,omitempty" json:"author,omitempty"`
	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, r CreateRequest) (*Response, error)
	GetByID(ctx context.Context, id string) (*Response, error)
	Find(ctx context.Context, query FilteredQuery) (*AggregationResult, error)
	Update(ctx context.Context, r UpdateRequest) (*Response, error)
	Delete(ctx context.Context, id, userID string) (bool, error)
	GetActive(ctx context.Context) ([]Response, error)
}

func NewStore

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

type UpdateRequest

type UpdateRequest struct {
	EditRequest `bson:",inline"`
	ID          string `bson:"_id" json:"-"`
}

Jump to

Keyboard shortcuts

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