services

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package main/services contains the concrete services used by Itero middleware server.

Index

Constants

View Source
const PollNotifDelay = 20 * time.Second

PollNotifDelay is the default duration during which notifications are kept in the list. This duration must be strictly greater than the period between pulls of the frontend.

View Source
const TmplBaseDir = "email"

TmplBaseDir is the directory to find email templates into.

Variables

This section is empty.

Functions

func ClosePollService

func ClosePollService(evtManager events.Manager, log slog.StackedLeveled) *closePollService

func EmailService

func EmailService(sender emailsender.Sender, log slog.StackedLeveled) emailService

EmailService constructs the email service. This service listen to events and send emails to users.

func NextRoundService

func NextRoundService(evtManager events.Manager, log slog.StackedLeveled) *nextRoundService

func StartPollService

func StartPollService(evtManager events.Manager, log slog.StackedLeveled) *startPollService

Types

type ClosePollEvent

type ClosePollEvent struct {
	Poll uint32
}

ClosePollEvent is type of events send when a poll is closed.

type CreatePollEvent

type CreatePollEvent struct {
	Poll uint32
}

type CreateUserEvent

type CreateUserEvent struct {
	User uint32
}

type DeletePollEvent

type DeletePollEvent struct {
	Poll         uint32
	Title        string
	Participants map[uint32]bool
}

type NextRoundEvent

type NextRoundEvent struct {
	Poll  uint32
	Round uint8
}

NextRoundEvent is the type of events send when a new round starts.

type PollNotifAction

type PollNotifAction uint8
const (
	PollNotifStart PollNotifAction = iota
	PollNotifNext
	PollNotifTerm
	PollNotifDelete
)

type PollNotifChannel

type PollNotifChannel = <-chan []*PollNotification

PollNotifChannel provides lists of recent notifications.

func RunPollNotif

func RunPollNotif(delay time.Duration, evtManager events.Manager) (PollNotifChannel, error)

type PollNotifList

type PollNotifList struct {
	// contains filtered or unexported fields
}

PollNotifList is a list of PollNotification that removes too old elements.

func NewPollNotifList

func NewPollNotifList(delay time.Duration) *PollNotifList

func (*PollNotifList) Add

func (self *PollNotifList) Add(notif *PollNotification)

Add adds a notification to the list. The list may be tidied.

func (*PollNotifList) Copy

func (self *PollNotifList) Copy() *PollNotifList

Copy construct a copy of the current list. The original list is never tidied but the constructed one always is.

func (*PollNotifList) Slice

func (self *PollNotifList) Slice() []*PollNotification

Slice return the list of notifications. The list is always tidied first.

func (*PollNotifList) Tidy

func (self *PollNotifList) Tidy()

Tidy removes too old notifications from the list.

type PollNotification

type PollNotification struct {
	Timestamp    time.Time
	Id           uint32
	Action       PollNotifAction
	Round        uint8
	Title        string
	Participants map[uint32]bool
}

func NewPollNotification

func NewPollNotification(evt events.Event) (ret *PollNotification)

type ReverifyEvent

type ReverifyEvent struct {
	User uint32
}

type StartPollEvent

type StartPollEvent struct {
	Poll uint32
}

StartPollEvent is send when a poll is started.

type VoteEvent

type VoteEvent struct {
	Poll uint32
}

Jump to

Keyboard shortcuts

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