Back to godoc.org
github.com/interuss/dss / pkg / rid / cockroach

Package cockroach

v0.0.1
Latest Go to latest

The latest major version is .

Published: May 21, 2020 | License: Apache-2.0 | Module: github.com/interuss/dss

Overview

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

Index

Variables

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

type ISAStore

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

ISAStore is an implementation of the ISARepo for CRDB.

func (*ISAStore) Delete

func (c *ISAStore) Delete(ctx context.Context, isa *ridmodels.IdentificationServiceArea) (*ridmodels.IdentificationServiceArea, []*ridmodels.Subscription, error)

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

func (c *ISAStore) Get(ctx context.Context, id dssmodels.ID) (*ridmodels.IdentificationServiceArea, error)

Get returns the isa identified by "id".

func (*ISAStore) Insert

func (c *ISAStore) Insert(ctx context.Context, isa *ridmodels.IdentificationServiceArea) (*ridmodels.IdentificationServiceArea, []*ridmodels.Subscription, error)

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

func (c *ISAStore) Update(ctx context.Context, isa *ridmodels.IdentificationServiceArea) (*ridmodels.IdentificationServiceArea, []*ridmodels.Subscription, error)

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

func (c *SubscriptionStore) Delete(ctx context.Context, s *ridmodels.Subscription) (*ridmodels.Subscription, error)

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

func (*SubscriptionStore) Get

func (c *SubscriptionStore) Get(ctx context.Context, id dssmodels.ID) (*ridmodels.Subscription, error)

Get returns the subscription identified by "id".

func (*SubscriptionStore) Insert

func (c *SubscriptionStore) Insert(ctx context.Context, s *ridmodels.Subscription) (*ridmodels.Subscription, error)

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

func (*SubscriptionStore) Search

func (c *SubscriptionStore) Search(ctx context.Context, cells s2.CellUnion) ([]*ridmodels.Subscription, error)

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

func (c *SubscriptionStore) Update(ctx context.Context, s *ridmodels.Subscription) (*ridmodels.Subscription, error)

Update updates the Subscription.. not yet implemented.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier