Documentation
¶
Index ¶
- Constants
- func NewNamedDriver(config driver.Config, dbProvider postgres.DbProvider) fdbdriver.NamedDriver
- func NewPersistenceWithOpts[V drivercommon.DBObject](cfg *postgres.ConfigProvider, dbProvider postgres.DbProvider, ...) (V, error)
- type Driver
- func (d *Driver) NewEndorseTx(name driver.PersistenceName, params ...string) (fdbdriver.EndorseTxStore, error)
- func (d *Driver) NewEnvelope(name driver.PersistenceName, params ...string) (fdbdriver.EnvelopeStore, error)
- func (d *Driver) NewMetadata(name driver.PersistenceName, params ...string) (fdbdriver.MetadataStore, error)
- func (d *Driver) NewVault(name driver.PersistenceName, params ...string) (cdriver.VaultStore, error)
- type EndorseTxStore
- type EnvelopeStore
- type MetadataStore
- type VaultStore
Constants ¶
const (
Persistence cdriver.PersistenceType = "postgres"
)
Variables ¶
This section is empty.
Functions ¶
func NewNamedDriver ¶
func NewNamedDriver(config driver.Config, dbProvider postgres.DbProvider) fdbdriver.NamedDriver
func NewPersistenceWithOpts ¶
func NewPersistenceWithOpts[V drivercommon.DBObject](cfg *postgres.ConfigProvider, dbProvider postgres.DbProvider, name driver.PersistenceName, constructor fsqlcommon.PersistenceConstructor[V], params ...string) (V, error)
NewPersistenceWithOpts constructs a V backed by the postgres persistence configured under name and params: it resolves the connection options and table names, opens the database, and invokes constructor to build the store, preparing its schema with migrate.CreateSchema. With skipCreateTable it runs no schema step and fails with migrate.ErrPending if the store has steps pending.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func NewDriverWithDbProvider ¶
func NewDriverWithDbProvider(config driver.Config, dbProvider postgres.DbProvider) *Driver
func (*Driver) NewEndorseTx ¶
func (d *Driver) NewEndorseTx(name driver.PersistenceName, params ...string) (fdbdriver.EndorseTxStore, error)
func (*Driver) NewEnvelope ¶
func (d *Driver) NewEnvelope(name driver.PersistenceName, params ...string) (fdbdriver.EnvelopeStore, error)
func (*Driver) NewMetadata ¶
func (d *Driver) NewMetadata(name driver.PersistenceName, params ...string) (fdbdriver.MetadataStore, error)
func (*Driver) NewVault ¶
func (d *Driver) NewVault(name driver.PersistenceName, params ...string) (cdriver.VaultStore, error)
type EndorseTxStore ¶
type EndorseTxStore struct {
*common.EndorseTxStore
}
func NewEndorseTxStore ¶
func NewEndorseTxStore(dbs *drivercommon.RWDB, tables common.TableNames) (*EndorseTxStore, error)
type EnvelopeStore ¶
type EnvelopeStore struct {
*common.EnvelopeStore
}
func NewEnvelopeStore ¶
func NewEnvelopeStore(dbs *drivercommon.RWDB, tables common.TableNames) (*EnvelopeStore, error)
type MetadataStore ¶
type MetadataStore struct {
*common.MetadataStore
}
func NewMetadataStore ¶
func NewMetadataStore(dbs *drivercommon.RWDB, tables common.TableNames) (*MetadataStore, error)
type VaultStore ¶
type VaultStore struct {
*fsqlcommon.VaultStore
// contains filtered or unexported fields
}
func NewVaultStore ¶
func NewVaultStore(dbs *drivercommon.RWDB, tables fsqlcommon.TableNames) (*VaultStore, error)
NewVaultStore creates a postgres-backed VaultStore for the given read/write database and table names.
func (*VaultStore) CreateSchema ¶
func (db *VaultStore) CreateSchema() error
CreateSchema creates the status and state tables if they do not exist. The state table's primary key is (ns, pkey). An existing table is then brought to that layout: pkey is converted from TEXT to BYTEA when needed (see convertTextKeysTx), and a primary key of (pkey, ns) is reordered to (ns, pkey). Each change reads the layout once without a lock, so an upgraded table never blocks, and again under ACCESS EXCLUSIVE, so replicas sharing the database perform each change once.
func (*VaultStore) Steps ¶ added in v0.28.0
func (db *VaultStore) Steps() []migrate.Step
Steps returns the vault's schema steps. Step 1 creates the status and state tables if they do not exist, converts a TEXT pkey to BYTEA and reorders a primary key of (pkey, ns) to (ns, pkey). Step 2, a contract step, rewrites gob metadata as protobuf (see fsqlcommon.VaultStore.MetadataToProtobuf); binaries that read only gob refuse the vault afterwards.
func (*VaultStore) Store ¶
func (db *VaultStore) Store(ctx context.Context, txIDs []driver.TxID, writes driver.Writes, metaWrites driver.MetaWrites) error
Store marks txIDs busy, upserts writes and metaWrites, and marks txIDs valid, all in one database transaction. Every statement is an upsert, so storing the same transactions again leaves the same rows; this makes a retry safe after a connection lost during COMMIT, when the outcome is unknown. The query timeout bounds the transaction as a whole, COMMIT included. Database errors are mapped by postgres.ErrorMapper.
func (*VaultStore) StoreName ¶ added in v0.28.0
func (db *VaultStore) StoreName() string
StoreName returns the state table name; it identifies the vault in the versions table.