override

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 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 using a Postgres DB as a backend.

func NewDB

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

NewDB initializes a new DB using an existing sql connection.

func (*DB) CreateUserOverrideTx

func (db *DB) CreateUserOverrideTx(ctx context.Context, tx *sql.Tx, o *UserOverride) (*UserOverride, error)

CreateUserOverrideTx adds a UserOverride to the DB with a new ID.

func (*DB) DeleteUserOverrideTx

func (db *DB) DeleteUserOverrideTx(ctx context.Context, tx *sql.Tx, ids ...string) error

DeleteUserOverride removes a UserOverride from the DB matching the given ID.

func (*DB) FindAllUserOverrides

func (db *DB) FindAllUserOverrides(ctx context.Context, start, end time.Time, t assignment.Target) ([]UserOverride, error)

FindAllUserOverrides will return all UserOverrides that belong to the provided Target within the provided time range.

func (*DB) FindOneUserOverrideTx

func (db *DB) FindOneUserOverrideTx(ctx context.Context, tx *sql.Tx, id string, forUpdate bool) (*UserOverride, error)

func (*DB) Search

func (db *DB) Search(ctx context.Context, opts *SearchOptions) ([]UserOverride, error)

func (*DB) UpdateUserOverride

func (db *DB) UpdateUserOverride(ctx context.Context, o *UserOverride) error

UpdateUserOverride updates an existing UserOverride.

func (*DB) UpdateUserOverrideTx

func (db *DB) UpdateUserOverrideTx(ctx context.Context, tx *sql.Tx, o *UserOverride) error

UpdateUserOverrideTx updates an existing UserOverride, inside an optional transaction.

type SearchCursor

type SearchCursor struct {
	ID string `json:"i,omitempty"`
}

SearchCursor is used to indicate a position in a paginated list.

type SearchOptions

type SearchOptions struct {
	After SearchCursor `json:"a,omitempty"`
	Limit int          `json:"-"`

	// Omit specifies a list of override IDs to exclude from the results.
	Omit []string

	ScheduleID string `json:"d,omitempty"`

	AddUserIDs    []string `json:"u,omitempty"`
	RemoveUserIDs []string `json:"r,omitempty"`
	AnyUserIDs    []string `json:"n,omitempty"`

	Start time.Time `json:"t,omitempty"`
	End   time.Time `json:"e,omitempty"`
}

SearchOptions allow filtering and paginating the list of rotations.

type Store

type Store interface {
	CreateUserOverrideTx(context.Context, *sql.Tx, *UserOverride) (*UserOverride, error)
	FindOneUserOverrideTx(ctx context.Context, tx *sql.Tx, id string, forUpdate bool) (*UserOverride, error)
	DeleteUserOverrideTx(context.Context, *sql.Tx, ...string) error
	FindAllUserOverrides(ctx context.Context, start, end time.Time, t assignment.Target) ([]UserOverride, error)
	UpdateUserOverride(context.Context, *UserOverride) error
	UpdateUserOverrideTx(context.Context, *sql.Tx, *UserOverride) error
	Search(context.Context, *SearchOptions) ([]UserOverride, error)
}

Store is used to manage active overrides.

type UserOverride

type UserOverride struct {
	ID           string    `json:"id,omitempty"`
	AddUserID    string    `json:"add_user_id,omitempty"`
	RemoveUserID string    `json:"remove_user_id,omitempty"`
	Start        time.Time `json:"start_time,omitempty"`
	End          time.Time `json:"end_time,omitempty"`
	Target       assignment.Target
}

A UserOverride is used to add, remove, or change which user is on call.

func (UserOverride) Normalize

func (o UserOverride) Normalize() (*UserOverride, error)

Normalize will validate fields and return a normalized copy.

func (UserOverride) String

func (o UserOverride) String() string

Jump to

Keyboard shortcuts

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