sqlobjectstore

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// ErrNotFound is returned when a requested object or hash is not found
	ErrNotFound = errors.Error("not found")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LookupOption

type LookupOption func(*LookupOptions)

LookupOptions

func FilterByHash

func FilterByHash(h object.Hash) LookupOption

func FilterByObjectType

func FilterByObjectType(typePatterns ...string) LookupOption

func FilterByOwner

func FilterByOwner(h crypto.PublicKey) LookupOption

func FilterByStreamHash

func FilterByStreamHash(h object.Hash) LookupOption

type LookupOptions

type LookupOptions struct {
	// Lookups are used to perform db queries for these filters
	// TODO find a better name for this
	Lookups struct {
		ObjectHashes []object.Hash
		StreamHashes []object.Hash
		ContentTypes []string
		Owners       []crypto.PublicKey
	}
	// filters are the lookups equivalents for matching objects for pubsub
	Filters []SqlStoreFilter
}

LookupOptions

type Option

type Option func(*Options)

func WithTTL

func WithTTL(minutes int) Option

type Options

type Options struct {
	TTL int // minutes
}

type SqlStoreFilter

type SqlStoreFilter func(object.Object) bool

type SqlStorePubSub

type SqlStorePubSub interface {
	Publish(object.Object)
	Subscribe(...SqlStoreFilter) SqlStoreSubscription
}

SqlStorePubSub -

func NewSqlStorePubSub

func NewSqlStorePubSub() SqlStorePubSub

NewSqlStore constructs and returns a new SqlStorePubSub

type SqlStoreSubscription

type SqlStoreSubscription interface {
	Next() (object.Object, error)
	Cancel()
}

SqlStoreSubscription is returned for every subscription

type Store

type Store struct {
	// contains filtered or unexported fields
}

func New

func New(
	db *sql.DB,
) (*Store, error)

func (*Store) Close

func (st *Store) Close() error

func (*Store) Filter

func (st *Store) Filter(
	lookupOptions ...LookupOption,
) ([]object.Object, error)

func (*Store) Get

func (st *Store) Get(
	hash object.Hash,
) (object.Object, error)

func (*Store) GetRelations

func (st *Store) GetRelations(
	parent object.Hash,
) ([]object.Hash, error)

func (*Store) Put

func (st *Store) Put(
	obj object.Object,
	opts ...Option,
) error

func (*Store) Remove

func (st *Store) Remove(
	hash object.Hash,
) error

func (*Store) Subscribe

func (st *Store) Subscribe(
	lookupOptions ...LookupOption,
) SqlStoreSubscription

func (*Store) UpdateTTL

func (st *Store) UpdateTTL(
	hash object.Hash,
	minutes int,
) error

Jump to

Keyboard shortcuts

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