Documentation
¶
Index ¶
Constants ¶
View Source
const StoreCtxKey storeCtxKey = "store"
Variables ¶
View Source
var ( ErrNotFound = errors.New("talkgroup not found") ErrNoSuchSystem = errors.New("no such system") ErrInvalidOrderBy = errors.New("invalid pagination orderBy value") ErrReference = errors.New("item is still referenced, cannot delete") ErrSystemAndTGsSpecified = errors.New("system filter and individual talkgroups specified") )
Functions ¶
Types ¶
type FilterCache ¶
type FilterCache interface {
// RegisterFilter registers a filter with the cache so it may be updated if referenced tags change.
RegisterFilter(Filter)
// UnregisterFilter unregisters a filter.
UnregisterFilter(Filter)
}
FilterCache allows tgstore to track tag changes to keep filters updated.
type Option ¶
type Option func(*options)
func WithFilter ¶
func WithPagination ¶
func WithPagination(p *Pagination, defPerPage int, totalDest *int) Option
type Pagination ¶
type Pagination struct {
common.Pagination
OrderBy *TGOrder `json:"orderBy"`
Direction *common.SortDirection `json:"dir"`
}
func (*Pagination) SortDir ¶
func (p *Pagination) SortDir() (string, error)
SortDir computes the sortField_order string used by the GetTalkgroupsP SQL query.
type Store ¶
type Store interface {
// UpdateTG updates a talkgroup record.
UpdateTG(ctx context.Context, input database.UpdateTalkgroupParams) (*tgsp.Talkgroup, error)
// UpsertTGs upserts a slice of talkgroups.
UpsertTGs(ctx context.Context, system int, input []database.UpsertTalkgroupParams) ([]*tgsp.Talkgroup, error)
// CreateSystem creates a new system with the specified name and ID.
CreateSystem(ctx context.Context, id int, name string, learned bool) error
// TG retrieves a Talkgroup from the Store.
TG(ctx context.Context, tg tgsp.ID) (*tgsp.Talkgroup, error)
// TGs retrieves many talkgroups from the Store.
TGs(ctx context.Context, tgs tgsp.IDs, opts ...Option) ([]*tgsp.Talkgroup, error)
// TGsByTags gets talkgroups by tags any, all, and not.
TGsByTags(ctx context.Context, tagsAll, tagsAny, tagsNot []string) (tgsp.IDs, error)
// LearnSystem learns the system from a call.
LearnSystem(ctx context.Context, call *calls.Call) error
// LearnTG learns the talkgroup from a Call.
LearnTG(ctx context.Context, call *calls.Call) (*tgsp.Talkgroup, error)
// SystemTGs retrieves all Talkgroups associated with a System.
SystemTGs(ctx context.Context, systemID int, opts ...Option) ([]*tgsp.Talkgroup, error)
// DeleteTG deletes a talkgroup record.
DeleteTG(ctx context.Context, id tgsp.ID) error
// DeleteSystem deletes a system. The system must have no talkgroups or incidents.
DeleteSystem(ctx context.Context, id int) error
// SystemName retrieves a system name from the store. It returns the record and whether one was found.
SystemName(ctx context.Context, id int) (string, bool)
// Tags returns all distinct tags.
Tags(ctx context.Context) ([]string, error)
// Hint hints the Store that the provided talkgroups will be asked for.
Hint(ctx context.Context, tgs []tgsp.ID) error
// Load loads the provided talkgroup ID tuples into the Store.
Load(ctx context.Context, tgs database.TGTuplesU) error
// Invalidate invalidates any caching in the Store.
Invalidate()
// Weight returns the final weight of this talkgroup, including its static and rules-derived weight.
Weight(ctx context.Context, id tgsp.ID, t time.Time) float64
FilterCache
Metrics() *TGStoreMetrics
// Hupper
HUP(*config.Config)
}
type TGStoreMetrics ¶
type TGStoreMetrics struct {
CacheHitCount prometheus.Counter `help:"Talkgroup cache hits"`
CacheMissCount prometheus.Counter `help:"Talkgroup cache misses"`
}
Click to show internal directories.
Click to hide internal directories.