label

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
}

DB implements the Store interface using a postgres database.

func NewDB

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

NewDB will Set a DB backend from a sql.DB. An error will be returned if statements fail to prepare.

func (*DB) FindAllByService

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

FindAllByService finds all labels for a particular service. It returns all key-value pairs.

func (*DB) Search

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

func (*DB) SetTx

func (db *DB) SetTx(ctx context.Context, tx *sql.Tx, label *Label) error

SetTx will set a label for the service. It can be used to set the key-value pair for the label, delete a label or update the value given the label's key.

func (*DB) UniqueKeys

func (db *DB) UniqueKeys(ctx context.Context) ([]string, error)

func (*DB) UniqueKeysTx

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

type Label

type Label struct {
	Target assignment.Target
	Key    string `json:"key"`
	Value  string `json:"value"`
}

A Label is a key-value pair assigned to a target.

func (Label) Normalize

func (l Label) Normalize() (*Label, error)

Normalize will validate and normalize the label, returning a copy.

type SearchCursor

type SearchCursor struct {
	Key        string                `json:"k,omitempty"`
	TargetID   string                `json:"t,omitempty"`
	TargetType assignment.TargetType `json:"y,omitempty"`
}

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

type SearchOptions

type SearchOptions struct {
	Search string       `json:"s,omitempty"`
	After  SearchCursor `json:"a,omitempty"`

	// Omit specifies a list of key names to exclude from the results.
	Omit []string `json:"o,omitempty"`

	Limit int `json:"-"`

	UniqueKeys bool `json:"u,omitempty"`
}

SearchOptions allow filtering and paginating the list of rotations.

type Store

type Store interface {
	SetTx(ctx context.Context, tx *sql.Tx, label *Label) error
	FindAllByService(ctx context.Context, serviceID string) ([]Label, error)
	UniqueKeysTx(ctx context.Context, tx *sql.Tx) ([]string, error)
	UniqueKeys(ctx context.Context) ([]string, error)
	Search(ctx context.Context, opts *SearchOptions) ([]Label, error)
}

Store allows the lookup and management of Labels.

Jump to

Keyboard shortcuts

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