Documentation
¶
Overview ¶
Package main/services contains the concrete services used by Itero middleware server.
Most services are provided as factories.
Index ¶
- Constants
- func ClosePollService(evtManager events.Manager, log slog.StackedLeveled) *closePollService
- func EmailService(sender emailsender.Sender, log slog.StackedLeveled) emailService
- func NextRoundService(evtManager events.Manager, log slog.StackedLeveled) *nextRoundService
- func StartPollService(evtManager events.Manager, log slog.StackedLeveled) *startPollService
- type ClosePollEvent
- type CreatePollEvent
- type CreateUserEvent
- type DeletePollEvent
- type ForgotEvent
- type NextRoundEvent
- type PollNotifAction
- type PollNotifChannel
- type PollNotification
- type ReverifyEvent
- type StartPollEvent
- type VoteEvent
Constants ¶
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.
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
ClosePollService is the factory for the service that terminates polls when their last round is over.
func EmailService ¶
func EmailService(sender emailsender.Sender, log slog.StackedLeveled) emailService
EmailService is the factory for the service that sends emails to users. Emails are sent when some events are received.
func NextRoundService ¶
func NextRoundService(evtManager events.Manager, log slog.StackedLeveled) *nextRoundService
NextRoundService is the factory for the service that changes the current round of polls.
func StartPollService ¶
func StartPollService(evtManager events.Manager, log slog.StackedLeveled) *startPollService
StartPollService is the factory for the service that starts polls that was created as waiting.
Types ¶
type ClosePollEvent ¶
type ClosePollEvent struct {
Poll uint32
}
ClosePollEvent is sent when a poll has been marked as terminated.
type CreatePollEvent ¶
type CreatePollEvent struct {
Poll uint32
}
CreatePollEvent is sents when a new poll has been created.
type CreateUserEvent ¶
type CreateUserEvent struct {
User uint32
}
CreateUserEvent is sent when a new user has been created.
type DeletePollEvent ¶
DeletePollEvent is sent when a poll has been deleted.
type ForgotEvent ¶ added in v0.1.5
type ForgotEvent struct {
User uint32
}
ForgotEvent is sent when a user requests to change its password.
type NextRoundEvent ¶
NextRoundEvent is sent when a new round starts. It is not sent for the first round.
type PollNotifAction ¶
type PollNotifAction uint8
const ( PollNotifStart PollNotifAction = iota PollNotifNext PollNotifTerm PollNotifDelete )
type PollNotifChannel ¶
type PollNotifChannel = <-chan []*PollNotification
PollNotifChannel provides lists of recent notifications.
A factory is binded to this type in root.IoC. The factory calls RunPollNotif with PollNotifDelay as delay.
func RunPollNotif ¶
RunPollNotif lanches the service that provides notifications.
The service provides the list of currenlty active notifications through the returned PollNotifChannel. Notifications correspond to events received from the given event Manager. Notifications are kept in the list of active notification for the given duration.
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)
NewPollNotification creates a new notification from an event. Some fields may be left uninitialized. Timestamp is always set to now.
type ReverifyEvent ¶
type ReverifyEvent struct {
User uint32
}
ReverifyEvent is sent when the user asks for its email address to be verified.
type StartPollEvent ¶
type StartPollEvent struct {
Poll uint32
}
StartPollEvent is sent when a poll has started.