db

package
v0.0.0-...-d2438c5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ClusterDefaultOfflineThreshold = 30

ClusterDefaultOfflineThreshold is the default value for the cluster.offline_threshold configuration key, expressed in seconds.

View Source
const DiscoveryDefaultOfflineThreshold = 120

DiscoveryDefaultOfflineThreshold is the default value for the discovery.offline_threshold configuration key, expressed in seconds.

Variables

View Source
var (
	// ErrAlreadyDefined hapens when the given entry already exists,
	// for example a container.
	ErrAlreadyDefined = fmt.Errorf("already exists")

	// ErrNoSuchObject is in the case of joins (and probably other) queries,
	// we don't get back sql.ErrNoRows when no rows are returned, even though we do
	// on selects without joins. Instead, you can use this error to
	// propagate up and generate proper 404s to the client when something
	// isn't found so we don't abuse sql.ErrNoRows any more than we
	// already do.
	ErrNoSuchObject = errors.Errorf("No such object")
)
View Source
var ErrSomeNodesAreBehind = errors.Errorf("some nodes are behind this node's version")

ErrSomeNodesAreBehind is returned by OpenCluster if some of the nodes in the cluster have a schema or API version that is less recent than this node.

Functions

func UnsafeClusterDB

func UnsafeClusterDB(c *Cluster) database.DB

UnsafeClusterDB accesses the cluster database, mainly for tests, so that we don't expose the DB directly on the Cluster.

func UnsafeNodeID

func UnsafeNodeID(c *Cluster) int64

UnsafeNodeID accesses the node ID from the cluster, mainly for tests, so that we don't expose the node ID directly on the Cluster.

Types

type Cluster

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

Cluster mediates access to data stored in the cluster dqlite database.

func NewCluster

func NewCluster(cluster QueryCluster, options ...ClusterOption) *Cluster

NewCluster creates a new Cluster object.

func (*Cluster) Close

func (c *Cluster) Close() error

Close the database facade.

func (*Cluster) DB

func (c *Cluster) DB() database.DB

DB returns the underlying database

func (*Cluster) EnterExclusive

func (c *Cluster) EnterExclusive() error

EnterExclusive acquires a lock on the cluster db, so any successive call to Transaction will block until ExitExclusive has been called.

func (*Cluster) ExitExclusive

func (c *Cluster) ExitExclusive(f func(*ClusterTx) error) error

ExitExclusive runs the given transaction and then releases the lock acquired with EnterExclusive.

func (*Cluster) NodeID

func (c *Cluster) NodeID(id int64)

NodeID sets the the node NodeID associated with this cluster instance. It's used for backward-compatibility of all db-related APIs that were written before clustering and don't accept a node NodeID, so in those cases we automatically use this value as implicit node NodeID.

func (*Cluster) Open

func (c *Cluster) Open(
	store cluster.ServerStore,
	address, dir string,
	timeout time.Duration,
	options ...dqlite.DriverOption,
) error

Open creates a new Cluster object for interacting with the dqlite database.

- store: Function used to connect to the dqlite backend. - address: Network address of this node (or empty string). - dir: Base database directory (e.g. /var/lib/thermionic/database) - options: Driver options that can be passed to the cluster when opening the db.

The address and api parameters will be used to determine if the cluster database matches our version, and possibly trigger a schema update. If the schema update can't be performed right now, because some nodes are still behind, an Upgrading error is returned.

func (*Cluster) SchemaVersion

func (c *Cluster) SchemaVersion() int

SchemaVersion returns the underlying schema version for the cluster

func (*Cluster) Transaction

func (c *Cluster) Transaction(f func(*ClusterTx) error) error

Transaction creates a new ClusterTx object and transactionally executes the cluster database interactions invoked by the given function. If the function returns no error, all database changes are committed to the cluster database database, otherwise they are rolled back.

If EnterExclusive has been called before, calling Transaction will block until ExitExclusive has been called as well to release the lock.

type ClusterExclusiveLocker

type ClusterExclusiveLocker interface {

	// EnterExclusive acquires a lock on the cluster db, so any successive call to
	// Transaction will block until ExitExclusive has been called.
	EnterExclusive() error

	// ExitExclusive runs the given transaction and then releases the lock acquired
	// with EnterExclusive.
	ExitExclusive(func(*ClusterTx) error) error
}

ClusterExclusiveLocker defines an exclusive lock for doing certain operations on the cluster.

type ClusterOpener

type ClusterOpener interface {

	// Open creates a new Cluster object for interacting with the dqlite database.
	//
	// - store: Function used to connect to the dqlite backend.
	// - address: Network address of this node (or empty string).
	// - dir: Base database directory (e.g. /var/lib/thermionic/database)
	// - options: Driver options that can be passed to the cluster when opening the db.
	//
	// The address and api parameters will be used to determine if the cluster
	// database matches our version, and possibly trigger a schema update. If the
	// schema update can't be performed right now, because some nodes are still
	// behind, an Upgrading error is returned.
	Open(cluster.ServerStore, string, string, time.Duration, ...dqlite.DriverOption) error
}

ClusterOpener represents a way to open a cluster

type ClusterOption

type ClusterOption func(*clusterOptions)

ClusterOption to be passed to NewCluster to customize the resulting instance.

func WithClockForCluster

func WithClockForCluster(clock clock.Clock) ClusterOption

WithClockForCluster sets the clock on the clusterOptions

func WithClusterTxProviderForCluster

func WithClusterTxProviderForCluster(clusterTxProvider ClusterTxProvider) ClusterOption

WithClusterTxProviderForCluster sets the clusterTxProvider on the clusterOptions

func WithFileSystemForCluster

func WithFileSystemForCluster(fileSystem fsys.FileSystem) ClusterOption

WithFileSystemForCluster sets the fileSystem on the clusterOptions

func WithLoggerForCluster

func WithLoggerForCluster(logger log.Logger) ClusterOption

WithLoggerForCluster sets the logger on the clusterOptions

func WithSleeperForCluster

func WithSleeperForCluster(sleeper clock.Sleeper) ClusterOption

WithSleeperForCluster sets the sleeper on the clusterOptions

func WithTransactionForCluster

func WithTransactionForCluster(transaction Transaction) ClusterOption

WithTransactionForCluster sets the transaction on the clusterOptions

type ClusterTransactioner

type ClusterTransactioner interface {

	// Transaction creates a new ClusterTx object and transactionally executes the
	// cluster database interactions invoked by the given function. If the function
	// returns no error, all database changes are committed to the cluster database
	// database, otherwise they are rolled back.
	//
	// If EnterExclusive has been called before, calling Transaction will block
	// until ExitExclusive has been called as well to release the lock.
	Transaction(f func(*ClusterTx) error) error
}

ClusterTransactioner represents a way to run transaction on the cluster

type ClusterTx

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

ClusterTx models a single interaction with a cluster database.

It wraps low-level database.Tx objects and offers a high-level API to fetch and update data.

func NewClusterTx

func NewClusterTx(tx database.Tx, nodeID int64) *ClusterTx

NewClusterTx creates a new transaction node with sane defaults

func NewClusterTxWithQuery

func NewClusterTxWithQuery(tx database.Tx, nodeID int64, query Query) *ClusterTx

NewClusterTxWithQuery creates a new transaction node with sane defaults

func (*ClusterTx) Config

func (c *ClusterTx) Config() (map[string]string, error)

Config fetches all cluster config keys.

func (*ClusterTx) NodeAdd

func (c *ClusterTx) NodeAdd(name, address string, schema, api int) (int64, error)

NodeAdd adds a node to the current list of nodes that are part of the cluster. It returns the ID of the newly inserted row.

func (*ClusterTx) NodeAddress

func (c *ClusterTx) NodeAddress() (string, error)

NodeAddress returns the address of the node this method is invoked on.

func (*ClusterTx) NodeByAddress

func (c *ClusterTx) NodeByAddress(address string) (NodeInfo, error)

NodeByAddress returns the pending node with the given network address.

func (*ClusterTx) NodeByName

func (c *ClusterTx) NodeByName(name string) (NodeInfo, error)

NodeByName returns the node with the given name.

func (*ClusterTx) NodeHeartbeat

func (c *ClusterTx) NodeHeartbeat(address string, heartbeat time.Time) error

NodeHeartbeat updates the heartbeat column of the node with the given address.

func (*ClusterTx) NodeID

func (c *ClusterTx) NodeID(id int64)

NodeID sets the the node NodeID associated with this cluster transaction.

func (*ClusterTx) NodeIsEmpty

func (c *ClusterTx) NodeIsEmpty(id int64) (string, error)

NodeIsEmpty returns an empty string if the node with the given ID has anything associated with it. Otherwise, it returns a message say what's left.

func (*ClusterTx) NodeIsOutdated

func (c *ClusterTx) NodeIsOutdated() (bool, error)

NodeIsOutdated returns true if there's some cluster node having an API or schema version greater than the node this method is invoked on.

func (*ClusterTx) NodeName

func (c *ClusterTx) NodeName() (string, error)

NodeName returns the name of the node this method is invoked on.

func (*ClusterTx) NodeOfflineThreshold

func (c *ClusterTx) NodeOfflineThreshold() (time.Duration, error)

NodeOfflineThreshold returns the amount of time that needs to elapse after which a series of unsuccessful heartbeat will make the node be considered offline.

func (*ClusterTx) NodePending

func (c *ClusterTx) NodePending(id int64, pending bool) error

NodePending toggles the pending flag for the node. A node is pending when it's been accepted in the cluster, but has not yet actually joined it.

func (*ClusterTx) NodePendingByAddress

func (c *ClusterTx) NodePendingByAddress(address string) (NodeInfo, error)

NodePendingByAddress returns the pending node with the given network address.

func (*ClusterTx) NodeRemove

func (c *ClusterTx) NodeRemove(id int64) error

NodeRemove removes the node with the given id.

func (*ClusterTx) NodeRename

func (c *ClusterTx) NodeRename(old, new string) error

NodeRename changes the name of an existing node.

Return an error if a node with the same name already exists.

func (*ClusterTx) NodeUpdate

func (c *ClusterTx) NodeUpdate(id int64, name, address string) error

NodeUpdate updates the name an address of a node.

func (*ClusterTx) NodeUpdateVersion

func (c *ClusterTx) NodeUpdateVersion(id int64, version [2]int) error

NodeUpdateVersion updates the schema and API version of the node with the given id. This is used only in tests.

func (*ClusterTx) Nodes

func (c *ClusterTx) Nodes() ([]NodeInfo, error)

Nodes returns all nodes part of the cluster.

If this instance is not clustered, a list with a single node whose address is 0.0.0.0 is returned.

func (*ClusterTx) NodesCount

func (c *ClusterTx) NodesCount() (int, error)

NodesCount returns the number of nodes in the cluster.

Since there's always at least one node row, even when not-clustered, the return value is greater than zero

func (*ClusterTx) OperationAdd

func (c *ClusterTx) OperationAdd(uuid string, opType OperationType) (int64, error)

OperationAdd adds a new operations to the table.

func (*ClusterTx) OperationByUUID

func (c *ClusterTx) OperationByUUID(uuid string) (Operation, error)

OperationByUUID returns the operation with the given UUID.

func (*ClusterTx) OperationNodes

func (c *ClusterTx) OperationNodes() ([]string, error)

OperationNodes returns a list of nodes that have running operations

func (*ClusterTx) OperationRemove

func (c *ClusterTx) OperationRemove(uuid string) error

OperationRemove removes the operation with the given UUID.

func (*ClusterTx) Operations

func (c *ClusterTx) Operations() ([]Operation, error)

Operations returns all operations associated with this node.

func (*ClusterTx) OperationsUUIDs

func (c *ClusterTx) OperationsUUIDs() ([]string, error)

OperationsUUIDs returns the UUIDs of all operations associated with this node.

func (*ClusterTx) ServiceAdd

func (c *ClusterTx) ServiceAdd(
	name,
	address,
	daemonAddress, daemonNonce string,
) (int64, error)

ServiceAdd adds a service to the current list of services that are part of the cluster. It returns the ID of the newly inserted row.

func (*ClusterTx) ServiceByName

func (c *ClusterTx) ServiceByName(name string) (ServiceNodeInfo, error)

ServiceByName returns the service with the given name.

func (*ClusterTx) ServiceNodeOfflineThreshold

func (c *ClusterTx) ServiceNodeOfflineThreshold() (time.Duration, error)

ServiceNodeOfflineThreshold returns the amount of time that needs to elapse after which a series of unsuccessful heartbeat will make the service node be considered offline.

func (*ClusterTx) ServiceNodes

func (c *ClusterTx) ServiceNodes() ([]ServiceNodeInfo, error)

ServiceNodes returns all service services part of the cluster.

func (*ClusterTx) ServiceRemove

func (c *ClusterTx) ServiceRemove(id int64) error

ServiceRemove removes the service with the given id.

func (*ClusterTx) ServiceUpdate

func (c *ClusterTx) ServiceUpdate(
	id int64,
	name,
	address,
	daemonAddress, daemonNonce string,
) error

ServiceUpdate updates the name an address of a service.

func (*ClusterTx) TaskAdd

func (c *ClusterTx) TaskAdd(uuid, query string, schedule int64, status int) (int64, error)

TaskAdd adds a new tasks to the table.

func (*ClusterTx) TaskByUUID

func (c *ClusterTx) TaskByUUID(uuid string) (Task, error)

TaskByUUID returns the operation with the given UUID.

func (*ClusterTx) TaskNodes

func (c *ClusterTx) TaskNodes() ([]string, error)

TaskNodes returns a list of nodes that have running tasks

func (*ClusterTx) TaskRemove

func (c *ClusterTx) TaskRemove(uuid string) error

TaskRemove removes the operation with the given UUID.

func (*ClusterTx) TaskUpdateResult

func (c *ClusterTx) TaskUpdateResult(uuid, res string, status int) error

TaskUpdateResult updates the result of the operation with the given UUID

func (*ClusterTx) Tasks

func (c *ClusterTx) Tasks() ([]Task, error)

Tasks returns all tasks associated with this node.

func (*ClusterTx) TasksByScheduleRange

func (c *ClusterTx) TasksByScheduleRange(from, to time.Time, status int) ([]Task, error)

TasksByScheduleRange returns a series of tasks within the time range

func (*ClusterTx) TasksUUIDs

func (c *ClusterTx) TasksUUIDs() ([]string, error)

TasksUUIDs returns the UUIDs of all tasks associated with this node.

func (*ClusterTx) UpdateConfig

func (c *ClusterTx) UpdateConfig(values map[string]string) error

UpdateConfig updates the given cluster configuration keys in the config table. Config keys set to empty values will be deleted.

type ClusterTxProvider

type ClusterTxProvider interface {

	// New creates a ClusterTx with the sane defaults
	New(database.Tx, int64) *ClusterTx
}

ClusterTxProvider creates ClusterTx which can be used by the cluster

type ConfigQuery

type ConfigQuery interface {
	// SelectConfig executes a query statement against a "config" table, which
	// must have 'key' and 'value' columns. By default this query returns all
	// keys, but additional WHERE filters can be specified.
	//
	// Returns a map of key names to their associated values.
	SelectConfig(database.Tx, string, string, ...interface{}) (map[string]string, error)

	// UpdateConfig updates the given keys in the given table. Config keys set to
	// empty values will be deleted.
	UpdateConfig(database.Tx, string, map[string]string) error
}

ConfigQuery defines queries to the database for configuration queries

type CountQuery

type CountQuery interface {

	// Count returns the number of rows in the given table.
	Count(database.Tx, string, string, ...interface{}) (int, error)
}

CountQuery defines queries to the database for count queries

type Node

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

Node mediates access to the data stored in the node-local SQLite database.

func NewNode

func NewNode(fileSystem fsys.FileSystem) *Node

NewNode creates a new Node object.

func (*Node) Close

func (n *Node) Close() error

Close the database facade.

func (*Node) DB

func (n *Node) DB() database.DB

DB returns the low level database handle to the node-local SQLite database.

func (*Node) Dir

func (n *Node) Dir() string

Dir returns the directory of the underlying database file.

func (*Node) Open

func (n *Node) Open(dir string, fresh func(*Node) error) error

Open a new node.

The fresh hook parameter is used by the daemon to mark all known patch names as applied when a brand new database is created.

func (*Node) Transaction

func (n *Node) Transaction(f func(*NodeTx) error) error

Transaction creates a new NodeTx object and transactionally executes the node-level database interactions invoked by the given function. If the function returns no error, all database changes are committed to the node-level database, otherwise they are rolled back.

type NodeInfo

type NodeInfo struct {
	ID            int64     // Stable node identifier
	Name          string    // User-assigned name of the node
	Address       string    // Network address of the node
	Description   string    // Node description (optional)
	Schema        int       // Schema version of the code running the node
	APIExtensions int       // Number of API extensions of the code running on the node
	Heartbeat     time.Time // Timestamp of the last heartbeat
}

NodeInfo holds information about a single instance in a cluster.

func (NodeInfo) IsOffline

func (n NodeInfo) IsOffline(clock clock.Clock, threshold time.Duration) bool

IsOffline returns true if the last successful heartbeat time of the node is older than the given threshold.

func (NodeInfo) Version

func (n NodeInfo) Version() [2]int

Version returns the node's version, composed by its schema level and number of extensions.

type NodeOpener

type NodeOpener interface {

	// Open a new node.
	//
	// The function hook parameter is used by the daemon to mark all known
	// patch names as applied when a brand new database is created.
	Open(string, func(*Node) error) error
}

NodeOpener represents a way to open a node

type NodeTransactioner

type NodeTransactioner interface {

	// Transaction creates a new NodeTx object and transactionally executes the
	// node-level database interactions invoked by the given function. If the
	// function returns no error, all database changes are committed to the
	// node-level database, otherwise they are rolled back.
	Transaction(f func(*NodeTx) error) error
}

NodeTransactioner represents a way to run transaction on the node

type NodeTx

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

NodeTx models a single interaction with a node-local database.

It wraps low-level db.Tx objects and offers a high-level API to fetch and update data.

func NewNodeTx

func NewNodeTx(tx database.Tx) *NodeTx

NewNodeTx creates a new transaction node with sane defaults

func NewNodeTxWithQuery

func NewNodeTxWithQuery(tx database.Tx, query Query) *NodeTx

NewNodeTxWithQuery creates a new transaction node with sane defaults

func (*NodeTx) Config

func (n *NodeTx) Config() (map[string]string, error)

Config fetches all node-level config keys.

func (*NodeTx) RaftNodeAdd

func (n *NodeTx) RaftNodeAdd(address string) (int64, error)

RaftNodeAdd adds a node to the current list of nodes that are part of the dqlite Raft cluster. It returns the ID of the newly inserted row.

func (*NodeTx) RaftNodeAddress

func (n *NodeTx) RaftNodeAddress(id int64) (string, error)

RaftNodeAddress returns the address of the raft node with the given ID, if any matching row exists.

func (*NodeTx) RaftNodeAddresses

func (n *NodeTx) RaftNodeAddresses() ([]string, error)

RaftNodeAddresses returns the addresses of all nodes that are members of the dqlite Raft cluster (possibly including the local node). If this instance is not running in clustered mode, an empty list is returned.

func (*NodeTx) RaftNodeDelete

func (n *NodeTx) RaftNodeDelete(id int64) error

RaftNodeDelete removes a node from the current list of nodes that are part of the dqlite Raft cluster.

func (*NodeTx) RaftNodeFirst

func (n *NodeTx) RaftNodeFirst(address string) error

RaftNodeFirst adds a the first node if the cluster. It ensures that the database ID is 1, to match the server ID of first raft log entry.

This method is supposed to be called when there are no rows in raft_nodes, and it will replace whatever existing row has ID 1.

func (*NodeTx) RaftNodes

func (n *NodeTx) RaftNodes() ([]RaftNode, error)

RaftNodes returns information about all nodes that are members of the dqlite Raft cluster (possibly including the local node). If this instance is not running in clustered mode, an empty list is returned.

func (*NodeTx) RaftNodesReplace

func (n *NodeTx) RaftNodesReplace(nodes []RaftNode) error

RaftNodesReplace replaces the current list of raft nodes.

func (*NodeTx) UpdateConfig

func (n *NodeTx) UpdateConfig(values map[string]string) error

UpdateConfig updates the given node-level configuration keys in the config table. Config keys set to empty values will be deleted.

type ObjectsQuery

type ObjectsQuery interface {
	// SelectObjects executes a statement which must yield rows with a specific
	// columns schema. It invokes the given Dest hook for each yielded row.
	SelectObjects(database.Tx, q.Dest, string, ...interface{}) error

	// UpsertObject inserts or replaces a new row with the given column values,
	// to the given table using columns order. For example:
	//
	// UpsertObject(tx, "cars", []string{"id", "brand"}, []interface{}{1, "ferrari"})
	//
	// The number of elements in 'columns' must match the one in 'values'.
	UpsertObject(database.Tx, string, []string, []interface{}) (int64, error)

	// DeleteObject removes the row identified by the given ID. The given table
	// must have a primary key column called 'id'.
	//
	// It returns a flag indicating if a matching row was actually found and
	// deleted or not.
	DeleteObject(database.Tx, string, int64) (bool, error)
}

ObjectsQuery defines queries to the database for generic object queries

type Operation

type Operation struct {
	ID          int64         // Stable database identifier
	UUID        string        // User-visible identifier
	NodeAddress string        // Address of the node the operation is running on
	Type        OperationType // Type of the operation
}

Operation holds information about a single operation running on a node in the cluster.

type OperationType

type OperationType string

OperationType is a identifier code identifying the type of an Operation.

type Query

type Query interface {
	ConfigQuery
	ObjectsQuery
	StringsQuery
	CountQuery
}

Query defines different queries for accessing the database

type QueryCluster

type QueryCluster interface {
	database.DBAccessor

	// Open the cluster database object.
	//
	// The name argument is the name of the cluster database. It defaults to
	// 'db.bin', but can be overwritten for testing.
	//
	// The dialer argument is a function that returns a gRPC dialer that can be
	// used to connect to a database node using the gRPC SQL package.
	Open(cluster.ServerStore, ...dqlite.DriverOption) error

	// EnsureSchema applies all relevant schema updates to the cluster database.
	//
	// Before actually doing anything, this function will make sure that all nodes
	// in the cluster have a schema version and a number of API extensions that
	// match our one. If it's not the case, we either return an error (if some
	// nodes have version greater than us and we need to be upgraded), or return
	// false and no error (if some nodes have a lower version, and we need to wait
	// till they get upgraded and restarted).
	EnsureSchema(string, string) (bool, error)

	// SchemaVersion returns the underlying schema version for the cluster
	SchemaVersion() int
}

QueryCluster defines an interface for interacting with the cluster DB

type QueryNode

type QueryNode interface {

	// Open the node-local database object.
	Open(string) error

	// EnsureSchema applies all relevant schema updates to the node-local
	// database.
	//
	// Return the initial schema version found before starting the update, along
	// with any error occurred.
	EnsureSchema(hookFn schema.Hook) (int, error)

	// DB return the current database source.
	DB() database.DB
}

QueryNode represents a local node in a cluster

type RaftNode

type RaftNode struct {
	ID      int64  // Stable node identifier
	Address string // Network address of the node
}

RaftNode holds information about a single node in the dqlite raft cluster.

type ServiceNodeInfo

type ServiceNodeInfo struct {
	ID            int64     // Stable node identifier
	Name          string    // User-assigned name of the node
	Address       string    // Network address of the node
	DaemonAddress string    // Daemon address that's associated with the service
	DaemonNonce   string    // Daemon nonce for secure communication with the dameon
	Heartbeat     time.Time // Timestamp of the last heartbeat
}

ServiceNodeInfo holds information about a single instance in a cluster.

func (ServiceNodeInfo) IsOffline

func (n ServiceNodeInfo) IsOffline(clock clock.Clock, threshold time.Duration) bool

IsOffline returns true if the last successful heartbeat time of the node is older than the given threshold.

type StringsQuery

type StringsQuery interface {

	// SelectStrings executes a statement which must yield rows with a single
	// string column. It returns the list of column values.
	SelectStrings(database.Tx, string, ...interface{}) ([]string, error)
}

StringsQuery defines queries to the database for string queries

type Task

type Task struct {
	ID          int64  // Stable database identifier
	UUID        string // User-visible identifier
	Query       string
	Schedule    int64
	Result      string
	Status      int
	NodeAddress string // Address of the node the operation is running on
}

Task holds information about a single operation running on a node in the cluster.

type Transaction

type Transaction interface {
	// Transaction executes the given function within a database transaction.
	Transaction(database.DB, func(database.Tx) error) error
}

Transaction defines a method for executing transactions over the database

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package query implements helpers around database/sql to execute various kinds of very common SQL queries.
Package query implements helpers around database/sql to execute various kinds of very common SQL queries.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package schema offers utilities to create and maintain a database schema.
Package schema offers utilities to create and maintain a database schema.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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