driver

package
v0.0.0-...-c1dc28d Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package driver defines the interface for Protavo drivers. This package is primarily used by driver implementors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delete

type Delete struct {
	Document *document.Document
	// contains filtered or unexported fields
}

Delete is a request to delete a document.

func (*Delete) Err

func (o *Delete) Err() error

func (*Delete) ExecuteInWriteTx

func (o *Delete) ExecuteInWriteTx(ctx context.Context, tx WriteTx)

ExecuteInWriteTx executes this operation within the context of tx.

func (*Delete) MarkExecuted

func (o *Delete) MarkExecuted(err error)

type DeleteNamespace

type DeleteNamespace struct {
	Documents []*document.Document
	// contains filtered or unexported fields
}

DeleteNamespace is a request to delete an entire namespace.

func (*DeleteNamespace) Err

func (o *DeleteNamespace) Err() error

func (*DeleteNamespace) ExecuteInWriteTx

func (o *DeleteNamespace) ExecuteInWriteTx(ctx context.Context, tx WriteTx)

ExecuteInWriteTx executes this operation within the context of tx.

func (*DeleteNamespace) MarkExecuted

func (o *DeleteNamespace) MarkExecuted(err error)

type DeleteWhere

type DeleteWhere struct {
	Each   DeleteWhereFunc
	Filter *filter.Filter
	// contains filtered or unexported fields
}

DeleteWhere is a request to delete one or more documents, without checking the current document revisions.

func (*DeleteWhere) Err

func (o *DeleteWhere) Err() error

func (*DeleteWhere) ExecuteInWriteTx

func (o *DeleteWhere) ExecuteInWriteTx(ctx context.Context, tx WriteTx)

ExecuteInWriteTx executes this operation within the context of tx.

func (*DeleteWhere) MarkExecuted

func (o *DeleteWhere) MarkExecuted(err error)

type DeleteWhereFunc

type DeleteWhereFunc func(id string) error

DeleteWhereFunc is a function that is invoked for each document deleted in a delete-where operation.

The delete operation is aborted if it returns a non-nil error.

type Driver

type Driver interface {
	// BeginRead starts a new read-only transaction.
	BeginRead(ctx context.Context, ns string) (ReadTx, error)

	// BeginWrite starts a new read/write transaction.
	BeginWrite(ctx context.Context, ns string) (WriteTx, error)

	// Close closes the driver, freeing any resources and preventing further
	// operations.
	Close() error
}

Driver is an interface for performing operations on a data store.

type Fetch

type Fetch struct {
	Each   FetchFunc
	Filter *filter.Filter
	// contains filtered or unexported fields
}

Fetch is a request to retrieve documents from the store.

func (*Fetch) Err

func (o *Fetch) Err() error

func (*Fetch) ExecuteInReadTx

func (o *Fetch) ExecuteInReadTx(ctx context.Context, tx ReadTx)

ExecuteInReadTx executes this operation within the context of tx.

func (*Fetch) ExecuteInWriteTx

func (o *Fetch) ExecuteInWriteTx(ctx context.Context, tx WriteTx)

ExecuteInWriteTx executes this operation within the context of tx.

func (*Fetch) MarkExecuted

func (o *Fetch) MarkExecuted(err error)

type FetchFunc

type FetchFunc func(*document.Document) (bool, error)

FetchFunc is a function that is invoked for each document found in a fetch operation.

The fetch operation is ended if it returns false or a non-nil error.

type NoOpCloser

type NoOpCloser struct {
	Driver
}

NoOpCloser is a Driver decoarator that prevents calls to Close() from reaching the underlying driver.

func (NoOpCloser) Close

func (NoOpCloser) Close() error

Close is a no-op that always returns nil.

type Operation

type Operation interface {
	// Err returns the error that occurred when the operation was executed, if any.
	// It panics if the operation has not yet been executed.
	Err() error

	// MarkExecuted is called by driver implementors to indicate the result of the
	// operation.
	MarkExecuted(err error)

	// ExecuteInWriteTx executes the operation within the context of a write
	// transaction.
	ExecuteInWriteTx(ctx context.Context, tx WriteTx)
}

Operation is a database operation that can be performed within a transaction.

type ReadOnlyOperation

type ReadOnlyOperation interface {
	Operation

	// ExecuteInReadTx executes the operation within the context of a read
	// transaction.
	ExecuteInReadTx(ctx context.Context, tx ReadTx)
}

ReadOnlyOperation is an operation that can be performed inside transactions that support reading.

type ReadTx

type ReadTx interface {
	Fetch(ctx context.Context, op *Fetch)

	Close() error
}

ReadTx is a transaction that can not modify the database.

type Save

type Save struct {
	Document *document.Document
	Force    bool
	// contains filtered or unexported fields
}

Save is a request to save a document.

func (*Save) Err

func (o *Save) Err() error

func (*Save) ExecuteInWriteTx

func (o *Save) ExecuteInWriteTx(ctx context.Context, tx WriteTx)

ExecuteInWriteTx executes this operation within the context of tx.

func (*Save) MarkExecuted

func (o *Save) MarkExecuted(err error)

type WriteTx

type WriteTx interface {
	ReadTx

	Save(ctx context.Context, op *Save)
	Delete(ctx context.Context, op *Delete)
	DeleteWhere(ctx context.Context, op *DeleteWhere)
	DeleteNamespace(ctx context.Context, op *DeleteNamespace)

	Commit() error
}

WriteTx is a transaction that can read and modify the database.

Directories

Path Synopsis
Package drivertest provides a reusable functional test suite for driver implementors.
Package drivertest provides a reusable functional test suite for driver implementors.

Jump to

Keyboard shortcuts

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