dutyscheduler

package
v0.0.0-...-445d1fb Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNamesDoNotMatch = errors.New("name of the given does match that of the project's")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Name string

	Applicants     string
	MessagePattern string `mapstructure:"message"`

	Period      string
	SkipDayOffs bool `mapstructure:"skip_dayoffs"`

	Vacation vacationdb.Config

	Channel string
	Persist bool

	MyTeam myteam.Config `mapstructure:"myteam"`
}

func NewConfig

func NewConfig() Config

func (*Config) Print

func (cfg *Config) Print()

func (Config) StatePersistenceEnabled

func (cfg Config) StatePersistenceEnabled() bool

StatePersistenceEnabled reports whether any project has state persistence enabled

func (*Config) Validate

func (cfg *Config) Validate() error

type DutyScheduler

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

DutyScheduler schedules persons of duty in given periods of time. On any change it sends a notification to the given communication channel.

func NewDutyScheduler

func NewDutyScheduler(
	cfg Config,
	stateDumper stateDumper,
	dayOffsDB dayOffsDB,
) (*DutyScheduler, error)

NewDutyScheduler creates a new DutyScheduler and starts an event scheduling routine.

func (DutyScheduler) ProjectName

func (sch DutyScheduler) ProjectName() string

ProjectName returns a name of the project that this scheduler processes.

func (*DutyScheduler) SetNotifyChannel

func (sch *DutyScheduler) SetNotifyChannel(ch notifyChannel)

SetNotifyChannel changes notify channel to the given.

func (*DutyScheduler) Shutdown

func (sch *DutyScheduler) Shutdown()

Shutdown finished scheduler gracefully.

type Event

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

Event represents a change for a given project

type PeriodType

type PeriodType string
const (
	EverySecond PeriodType = "every second"
	EveryMinute PeriodType = "every minute"
	EveryHour   PeriodType = "every hour"
	EveryDay    PeriodType = "every day"
	EveryWeek   PeriodType = "every week"
	Every2Weeks PeriodType = "every 2 weeks"
	Every4Weeks PeriodType = "every 4 weeks"
)

func (PeriodType) ToDuration

func (t PeriodType) ToDuration() time.Duration

func (PeriodType) Validate

func (t PeriodType) Validate() error

type Project

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

Project represents an actual project with employes that take duty cyclically after given period of time

func NewProject

func NewProject(name, applicants string, period PeriodType) (*Project, error)

NewProject created a new project with the given parameters. Mostly used for testing purposes

func NewProjectFromConfig

func NewProjectFromConfig(config Config) (*Project, error)

func (*Project) CurrentPerson

func (p *Project) CurrentPerson() string

func (*Project) DumpState

func (p *Project) DumpState(w io.StringWriter) error

func (*Project) LastChange

func (p *Project) LastChange() time.Time

func (*Project) Name

func (p *Project) Name() string

func (*Project) NextPerson

func (p *Project) NextPerson() string

func (*Project) RestoreState

func (p *Project) RestoreState(state statedumper.SchedulingState) error

func (*Project) SetDayOffsDB

func (p *Project) SetDayOffsDB(db dayOffsDB)

func (*Project) SetLogger

func (p *Project) SetLogger(logger *logrus.Entry)

func (*Project) SetTimeOfLastChange

func (p *Project) SetTimeOfLastChange(t time.Time)

func (*Project) SetVacationDB

func (p *Project) SetVacationDB(db vacationdb.VacationDB)

func (*Project) ShouldChangePerson

func (p *Project) ShouldChangePerson() bool

ShouldChangePerson reports whether the person of duty should be changed given the circumstances

func (*Project) StatePersistenceEnabled

func (p *Project) StatePersistenceEnabled() bool

func (*Project) TimeTillNextChange

func (p *Project) TimeTillNextChange() time.Duration

Jump to

Keyboard shortcuts

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