service

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: Apache-2.0 Imports: 12 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
}

func NewDB

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

func (*DB) CreateServiceTx

func (db *DB) CreateServiceTx(ctx context.Context, tx *sql.Tx, s *Service) (*Service, error)

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, id string) error

Delete implements the ServiceInterface interface.

func (*DB) DeleteManyTx

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

func (*DB) DeleteTx

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

func (*DB) FindAll

func (db *DB) FindAll(ctx context.Context) ([]Service, error)

func (*DB) FindAllByEP

func (db *DB) FindAllByEP(ctx context.Context, epID string) ([]Service, error)

func (*DB) FindMany

func (db *DB) FindMany(ctx context.Context, ids []string) ([]Service, error)

FindMany returns slice of Service objects given a slice of serviceIDs

func (*DB) FindOne

func (db *DB) FindOne(ctx context.Context, id string) (*Service, error)

func (*DB) FindOneForUpdate

func (db *DB) FindOneForUpdate(ctx context.Context, tx *sql.Tx, id string) (*Service, error)

func (*DB) FindOneForUser

func (db *DB) FindOneForUser(ctx context.Context, userID, serviceID string) (*Service, error)

func (*DB) Insert

func (db *DB) Insert(ctx context.Context, s *Service) (*Service, error)

func (*DB) LegacySearch

func (db *DB) LegacySearch(ctx context.Context, opts *LegacySearchOptions) ([]Service, error)

LegacySearch will return a list of matching services and the total number of matches available.

func (*DB) Search

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

Search will return a list of matching services and the total number of matches available.

func (*DB) Update

func (db *DB) Update(ctx context.Context, s *Service) error

Update implements the ServiceStore interface.

func (*DB) UpdateTx

func (db *DB) UpdateTx(ctx context.Context, tx *sql.Tx, s *Service) error

type LegacySearchOptions

type LegacySearchOptions struct {
	// Search is matched case-insensitive against the service name and description.
	Search string

	// FavoritesUserID specifies the UserID whose favorite services want to be displayed.
	FavoritesUserID string

	// FavoritesOnly controls filtering the results to those marked as favorites by FavoritesUserID.
	FavoritesOnly bool

	// FavoritesFirst indicates that services marked as favorite (by FavoritesUserID) should be returned first (before any non-favorites).
	FavoritesFirst bool

	// Limit, if not zero, will limit the number of results.
	Limit int
}

LegacySearchOptions contains criteria for filtering and sorting services.

type SearchCursor

type SearchCursor struct {
	Name       string `json:"n"`
	IsFavorite bool   `json:"f"`
}

type SearchOptions

type SearchOptions struct {
	// Search is matched case-insensitive against the service name and description.
	Search string `json:"s,omitempty"`

	// FavoritesUserID specifies the UserID whose favorite services want to be displayed.
	FavoritesUserID string `json:"u,omitempty"`

	// FavoritesOnly controls filtering the results to those marked as favorites by FavoritesUserID.
	FavoritesOnly bool `json:"o,omitempty"`

	// Omit specifies a list of service IDs to exclude from the results.
	Omit []string `json:"m,omitempty"`

	// FavoritesFirst indicates that services marked as favorite (by FavoritesUserID) should be returned first (before any non-favorites).
	FavoritesFirst bool `json:"f,omitempty"`

	// Limit will limit the number of results.
	Limit int `json:"-"`

	After SearchCursor `json:"a,omitempty"`
}

SearchOptions contains criteria for filtering and sorting services.

type Service

type Service struct {
	ID                 string `json:"id"`
	Name               string `json:"name"`
	Description        string `json:"description"`
	EscalationPolicyID string `json:"escalation_policy_id"`
	// contains filtered or unexported fields
}

func (Service) EscalationPolicyName

func (s Service) EscalationPolicyName() string

func (Service) IsUserFavorite

func (s Service) IsUserFavorite() bool

IsUserFavorite returns a boolean value based on if the service is a favorite of the user or not.

func (Service) Normalize

func (s Service) Normalize() (*Service, error)

Normalize will validate and 'normalize' the ContactMethod -- such as making email lower-case and setting carrier to "" (for non-phone types).

type Store

type Store interface {
	FindMany(context.Context, []string) ([]Service, error)

	FindOne(context.Context, string) (*Service, error)
	FindOneForUpdate(ctx context.Context, tx *sql.Tx, id string) (*Service, error)
	FindOneForUser(ctx context.Context, userID, serviceID string) (*Service, error)
	FindAll(context.Context) ([]Service, error)
	DeleteManyTx(context.Context, *sql.Tx, []string) error
	Insert(context.Context, *Service) (*Service, error)
	CreateServiceTx(context.Context, *sql.Tx, *Service) (*Service, error)

	Update(context.Context, *Service) error
	UpdateTx(context.Context, *sql.Tx, *Service) error

	Delete(ctx context.Context, id string) error
	DeleteTx(ctx context.Context, tx *sql.Tx, id string) error

	FindAllByEP(context.Context, string) ([]Service, error)
	LegacySearch(ctx context.Context, opts *LegacySearchOptions) ([]Service, error)
	Search(ctx context.Context, opts *SearchOptions) ([]Service, error)
}

Jump to

Keyboard shortcuts

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