Documentation
¶
Overview ¶
Package storage defines storage interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeString ¶ added in v0.1.16
Postgres requires valid UTF-8 with no 0x00.
func SanitizeStringP ¶ added in v0.1.23
Types ¶
type QueryBatch ¶
type QueryBatch struct {
// contains filtered or unexported fields
}
QueryBatch represents a batch of queries to be executed atomically. We use a custom type that mirrors `pgx.Batch`, but is thread-safe to use and allows introspection for debugging.
func (*QueryBatch) AsPgxBatch ¶
func (b *QueryBatch) AsPgxBatch() pgx.Batch
AsPgxBatch converts a QueryBatch to a pgx.Batch.
func (*QueryBatch) Extend ¶
func (b *QueryBatch) Extend(qb *QueryBatch)
Extend merges another batch into the current batch.
func (*QueryBatch) Len ¶
func (b *QueryBatch) Len() int
Len returns the number of queries in the batch.
func (*QueryBatch) Queries ¶
func (b *QueryBatch) Queries() []*BatchItem
Queries returns the queries in the batch. Each item of the returned slice is composed of the SQL command and its arguments.
func (*QueryBatch) Queue ¶
func (b *QueryBatch) Queue(cmd string, args ...interface{})
Queue adds query to a batch.
type QueryResults ¶
QueryResults represents the results from a read query.
type TargetStorage ¶
type TargetStorage interface {
// SendBatch sends a batch of queries to be applied to target storage.
SendBatch(ctx context.Context, batch *QueryBatch) error
// SendBatchWithOptions is like SendBatch, with custom DB options (e.g. level of tx isolation).
SendBatchWithOptions(ctx context.Context, batch *QueryBatch, opts TxOptions) error
// Query submits a query to fetch data from target storage.
Query(ctx context.Context, sql string, args ...interface{}) (QueryResults, error)
// QueryRow submits a query to fetch a single row of data from target storage.
QueryRow(ctx context.Context, sql string, args ...interface{}) QueryResult
// Exec executes a query without returning any rows.
Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
// Begin starts a new transaction.
// XXX: Not the nicest that this exposes the underlying pgx.Tx interface. Could instead
// return a `TargetStorage`-like interface wrapper, that only exposes Query/QueryRow/SendBatch/SendBatchWithOptions
// and Commit/Rollback.
Begin(ctx context.Context) (Tx, error)
// Close shuts down the target storage client.
Close()
// Name returns the name of the target storage.
Name() string
// Wipe removes all contents of the target storage.
Wipe(ctx context.Context) error
// DisableTriggersAndFKConstraints disables all triggers and foreign key constraints
// in nexus tables. This is useful when inserting blockchain data out of order,
// so that later blocks can refer to (yet unindexed) earlier blocks without violating constraints.
DisableTriggersAndFKConstraints(ctx context.Context) error
// EnableTriggersAndFKConstraints enables all triggers and foreign key constraints
// in the given schema.
// WARNING: This might enable triggers not explicitly disabled by DisableTriggersAndFKConstraints.
// WARNING: This does not enforce/check contraints on rows that were inserted while triggers were disabled.
EnableTriggersAndFKConstraints(ctx context.Context) error
}
TargetStorage defines an interface for reading and writing processed block data.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package client defines the types for storage client responses.
|
Package client defines the types for storage client responses. |
|
queries
Package queries defines the SQL queries used by the storage client.
|
Package queries defines the SQL queries used by the storage client. |
|
Package migrations contains embedded database migration files.
|
Package migrations contains embedded database migration files. |
|
Package oasis implements the source storage interface backed by oasis-node.
|
Package oasis implements the source storage interface backed by oasis-node. |
|
connections
Package connections implements a gRPC connection wrapper.
|
Package connections implements a gRPC connection wrapper. |
|
nodeapi
Package nodeapi defines the types used by Nexus to represent the data returned by the node API.
|
Package nodeapi defines the types used by Nexus to represent the data returned by the node API. |
|
nodeapi/cobalt
Package cobalt implements the Cobalt consensus API.
|
Package cobalt implements the Cobalt consensus API. |
|
nodeapi/damask
Package damask implements a Damask consensus API.
|
Package damask implements a Damask consensus API. |
|
nodeapi/eden
Package eden implements the Eden consensus API.
|
Package eden implements the Eden consensus API. |
|
nodeapi/file
Package file implements a file-backed consensus API.
|
Package file implements a file-backed consensus API. |
|
nodeapi/history
Package history implements a consensus API for historical data.
|
Package history implements a consensus API for historical data. |
|
Package postgres implements the target storage interface backed by PostgreSQL.
|
Package postgres implements the target storage interface backed by PostgreSQL. |
|
testutil
Package testutil provides utilities for testing the postgres client.
|
Package testutil provides utilities for testing the postgres client. |