services

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 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.

Most services are provided as factories.

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

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

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

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

type NextRoundEvent struct {
	Poll  uint32
	Round uint8
}

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

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

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.

type VoteEvent

type VoteEvent struct {
	Poll uint32
}

VoteEvent is sent when a new ballot has been accepted for a poll.

Jump to

Keyboard shortcuts

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