cockroach

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cockroach provides an implementation of a dss.Store on top of a cockroach DB instance.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultClock is what is used as the Store's clock, returned from Dial.
	DefaultClock = clockwork.NewRealClock()
)

Functions

This section is empty.

Types

type ISAStore

type ISAStore struct {
	*cockroach.DB
	// contains filtered or unexported fields
}

ISAStore is an implementation of the ISARepo for CRDB.

func (*ISAStore) Delete

Delete deletes the IdentificationServiceArea identified by "id" and owned by "owner". Returns the delete IdentificationServiceArea and all Subscriptions affected by the delete.

func (*ISAStore) Get

Get returns the isa identified by "id".

func (*ISAStore) Insert

Insert inserts the IdentificationServiceArea identified by "id" and owned by "owner", affecting "cells" in the time interval ["starts", "ends"].

Returns the created IdentificationServiceArea and all Subscriptions affected by it. TODO: Simplify the logic to insert without a query, such that the insert fails if there's an existing entity.

func (*ISAStore) Search

func (c *ISAStore) Search(ctx context.Context, cells s2.CellUnion, earliest *time.Time, latest *time.Time) ([]*ridmodels.IdentificationServiceArea, error)

Search searches IdentificationServiceArea instances that intersect with "cells" and, if set, the temporal volume defined by "earliest" and "latest".

func (*ISAStore) Update

Update updates the IdentificationServiceArea identified by "id" and owned by "owner", affecting "cells" in the time interval ["starts", "ends"].

Returns the created IdentificationServiceArea and all Subscriptions affected by it. TODO: simplify the logic to just update, without the primary query.

type Store

type Store struct {
	ISA          repos.ISA
	Subscription repos.Subscription
	*cockroach.DB
}

Store is an implementation of dss.Store using Cockroach DB as its backend store.

func NewStore

func NewStore(db *cockroach.DB, logger *zap.Logger) (*Store, error)

NewStore returns a Store instance connected to a cockroach instance via db.

func (*Store) Bootstrap

func (s *Store) Bootstrap(ctx context.Context) error

Bootstrap bootstraps the underlying database with required tables.

TODO: We should handle database migrations properly, but bootstrap both us *and* the database with this manual approach here.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying DB connection.

type SubscriptionStore

type SubscriptionStore struct {
	*cockroach.DB
	// contains filtered or unexported fields
}

SubscriptionStore is an implementation of the SubscriptionRepo for CRDB.

func (*SubscriptionStore) Delete

Delete deletes the subscription identified by "id" and returns the deleted subscription.

func (*SubscriptionStore) Get

Get returns the subscription identified by "id".

func (*SubscriptionStore) Insert

Insert inserts subscription into the store and returns the resulting subscription including its ID.

func (*SubscriptionStore) Search

Search returns all subscriptions in "cells".

func (*SubscriptionStore) SearchByOwner

func (c *SubscriptionStore) SearchByOwner(ctx context.Context, cells s2.CellUnion, owner dssmodels.Owner) ([]*ridmodels.Subscription, error)

SearchByOwner returns all subscriptions in "cells".

func (*SubscriptionStore) Update

Update updates the Subscription.. not yet implemented.

Jump to

Keyboard shortcuts

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