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 scd.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 Store

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

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.

func (*Store) DeleteOperation

func (s *Store) DeleteOperation(ctx context.Context, id scdmodels.ID, owner dssmodels.Owner) (*scdmodels.Operation, []*scdmodels.Subscription, error)

DeleteOperation deletes an operation for the given ID from CockroachDB

func (*Store) DeleteSubscription

func (c *Store) DeleteSubscription(ctx context.Context, id scdmodels.ID, owner dssmodels.Owner, version scdmodels.Version) (*scdmodels.Subscription, error)

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

func (*Store) GetOperation

func (s *Store) GetOperation(ctx context.Context, id scdmodels.ID) (*scdmodels.Operation, error)

GetOperation returns an operation for the given ID from CockroachDB

func (*Store) GetSubscription

func (c *Store) GetSubscription(ctx context.Context, id scdmodels.ID, owner dssmodels.Owner) (*scdmodels.Subscription, error)

GetSubscription returns the subscription identified by "id".

func (*Store) SearchOperations

func (s *Store) SearchOperations(ctx context.Context, v4d *dssmodels.Volume4D, owner dssmodels.Owner) ([]*scdmodels.Operation, error)

SearchOperations returns operations within the 4D volume from CockroachDB

func (*Store) SearchSubscriptions

func (c *Store) SearchSubscriptions(ctx context.Context, cells s2.CellUnion, owner dssmodels.Owner) ([]*scdmodels.Subscription, error)

SearchSubscriptions returns all subscriptions in "cells".

func (*Store) UpsertOperation

func (s *Store) UpsertOperation(ctx context.Context, operation *scdmodels.Operation, key []scdmodels.OVN) (*scdmodels.Operation, []*scdmodels.Subscription, error)

UpsertOperation inserts or updates an operation in CockroachDB

func (*Store) UpsertSubscription

func (c *Store) UpsertSubscription(ctx context.Context, s *scdmodels.Subscription) (*scdmodels.Subscription, []*scdmodels.Operation, error)

UpsertSubscription upserts subscription into the store and returns the resulting subscription including its ID.

Jump to

Keyboard shortcuts

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