Documentation
¶
Index ¶
- Variables
- type Config
- type DutyScheduler
- type Event
- type PeriodType
- type Project
- func (p *Project) CurrentPerson() string
- func (p *Project) DumpState(w io.StringWriter) error
- func (p *Project) LastChange() time.Time
- func (p *Project) Name() string
- func (p *Project) NextPerson() string
- func (p *Project) RestoreState(state statedumper.SchedulingState) error
- func (p *Project) SetDayOffsDB(db dayOffsDB)
- func (p *Project) SetLogger(logger *logrus.Entry)
- func (p *Project) SetTimeOfLastChange(t time.Time)
- func (p *Project) SetVacationDB(db vacationdb.VacationDB)
- func (p *Project) ShouldChangePerson() bool
- func (p *Project) StatePersistenceEnabled() bool
- func (p *Project) TimeTillNextChange() time.Duration
Constants ¶
This section is empty.
Variables ¶
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 (Config) StatePersistenceEnabled ¶
StatePersistenceEnabled reports whether any project has state persistence enabled
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 (*Project) CurrentPerson ¶
func (*Project) LastChange ¶
func (*Project) NextPerson ¶
func (*Project) RestoreState ¶
func (p *Project) RestoreState(state statedumper.SchedulingState) error
func (*Project) SetDayOffsDB ¶
func (p *Project) SetDayOffsDB(db dayOffsDB)
func (*Project) SetTimeOfLastChange ¶
func (*Project) SetVacationDB ¶
func (p *Project) SetVacationDB(db vacationdb.VacationDB)
func (*Project) ShouldChangePerson ¶
ShouldChangePerson reports whether the person of duty should be changed given the circumstances