oncall

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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