oncall

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB implements the Store interface from Postgres.

func NewDB

func NewDB(ctx context.Context, db *sql.DB, ruleStore rule.Store) (*DB, error)

NewDB will create a new DB, preparing required statements using the provided context.

func (*DB) HistoryBySchedule

func (db *DB) HistoryBySchedule(ctx context.Context, scheduleID string, start, end time.Time) ([]Shift, error)

HistoryBySchedule will return the list of shifts that overlap the start and end time for the given schedule.

func (*DB) OnCallUsersByService

func (db *DB) OnCallUsersByService(ctx context.Context, serviceID string) ([]ServiceOnCallUser, error)

OnCallUsersByService will return the current set of users who are on-call for the given service.

type ServiceOnCallUser

type ServiceOnCallUser struct {
	StepNumber int    `json:"step_number"`
	UserID     string `json:"user_id"`
	UserName   string `json:"user_name"`
}

ServiceOnCallUser represents a currently on-call user for a service.

type Shift

type Shift struct {
	UserID    string    `json:"user_id"`
	Start     time.Time `json:"start_time"`
	End       time.Time `json:"end_time"`
	Truncated bool      `json:"truncated"`
}

A Shift represents a duration a user is on-call. If truncated is true, then the End time does not represent the time the user stopped being on call, instead it indicates they were still on-call at that time.

type Store

type Store interface {
	OnCallUsersByService(ctx context.Context, serviceID string) ([]ServiceOnCallUser, error)

	// HistoryBySchedule(ctx context.Context, stepID string, start, end time.Time) ([]Shift, error)
	HistoryBySchedule(ctx context.Context, scheduleID string, start, end time.Time) ([]Shift, error)
}

Store allows retrieving and calculating on-call information.

Jump to

Keyboard shortcuts

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