Documentation ¶
Index ¶
- Variables
- func CurrentDBLevels(db FabricCADB) (*util.Levels, error)
- func Migrate(migrator Migrator, currentLevels, srvLevels *util.Levels) error
- type AffiliationRecord
- type CertRecord
- type DB
- func (db *DB) BeginTx() FabricCATx
- func (db *DB) Close() error
- func (db *DB) DriverName() string
- func (db *DB) Exec(funcName, query string, args ...interface{}) (sql.Result, error)
- func (db *DB) Get(funcName string, dest interface{}, query string, args ...interface{}) error
- func (db *DB) IsInitialized() bool
- func (db *DB) MustBegin() *sqlx.Tx
- func (db *DB) NamedExec(funcName, query string, args interface{}) (sql.Result, error)
- func (db *DB) PingContext(ctx context.Context) error
- func (db *DB) Queryx(funcName, query string, args ...interface{}) (*sqlx.Rows, error)
- func (db *DB) Rebind(query string) string
- func (db *DB) Select(funcName string, dest interface{}, query string, args ...interface{}) error
- func (db *DB) SetDBInitialized(b bool)
- func (db *DB) SetMaxOpenConns(n int)
- type FabricCADB
- type FabricCATx
- type Metrics
- type Migrator
- type SqlxDB
- type SqlxTx
- type TX
- func (tx *TX) Commit(funcName string) error
- func (tx *TX) Exec(funcName, query string, args ...interface{}) (sql.Result, error)
- func (tx *TX) Get(funcName string, dest interface{}, query string, args ...interface{}) error
- func (tx *TX) Queryx(funcName, query string, args ...interface{}) (*sqlx.Rows, error)
- func (tx *TX) Rebind(query string) string
- func (tx *TX) Rollback(funcName string) error
- func (tx *TX) Select(funcName string, dest interface{}, query string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( // APICounterOpts define the counter opts for database APIs APICounterOpts = metrics.CounterOpts{ Namespace: "db_api_request", Subsystem: "", Name: "count", Help: "Number of requests made to a database API", LabelNames: []string{"ca_name", "func_name", "dbapi_name"}, StatsdFormat: "%{#fqname}.%{ca_name}.%{func_name}.%{dbapi_name}", } // APIDurationOpts define the duration opts for database APIs APIDurationOpts = metrics.HistogramOpts{ Namespace: "db_api_request", Subsystem: "", Name: "duration", Help: "Time taken in seconds for the request to a database API to be completed", LabelNames: []string{"ca_name", "func_name", "dbapi_name"}, StatsdFormat: "%{#fqname}.%{ca_name}.%{func_name}.%{dbapi_name}", } )
Functions ¶
func CurrentDBLevels ¶
func CurrentDBLevels(db FabricCADB) (*util.Levels, error)
CurrentDBLevels returns current levels from the database
Types ¶
type AffiliationRecord ¶
type AffiliationRecord struct { ID int `db:"id"` Name string `db:"name"` Prekey string `db:"prekey"` Level int `db:"level"` }
AffiliationRecord defines the properties of an affiliation
type CertRecord ¶
type CertRecord struct { ID string `db:"id"` Level int `db:"level"` certdb.CertificateRecord }
CertRecord extends CFSSL CertificateRecord by adding an enrollment ID to the record
type DB ¶
type DB struct { DB SqlxDB // Indicates if database was successfully initialized IsDBInitialized bool CAName string Metrics *Metrics }
DB is an adapter for sqlx.DB and implements FabricCADB interface
func (*DB) BeginTx ¶
func (db *DB) BeginTx() FabricCATx
BeginTx implements BeginTx method of FabricCADB interface
func (*DB) IsInitialized ¶
IsInitialized returns true if db is intialized, else false
func (*DB) PingContext ¶
PingContext pings the database
func (*DB) SetDBInitialized ¶
SetDBInitialized sets the value for Isdbinitialized
func (*DB) SetMaxOpenConns ¶
SetMaxOpenConns sets number of max open connections
type FabricCADB ¶
type FabricCADB interface { IsInitialized() bool SetDBInitialized(bool) // BeginTx has same behavior as MustBegin except it returns FabricCATx // instead of *sqlx.Tx BeginTx() FabricCATx DriverName() string Select(funcName string, dest interface{}, query string, args ...interface{}) error Exec(funcName, query string, args ...interface{}) (sql.Result, error) NamedExec(funcName, query string, arg interface{}) (sql.Result, error) Get(funcName string, dest interface{}, query string, args ...interface{}) error Queryx(funcName, query string, args ...interface{}) (*sqlx.Rows, error) Rebind(query string) string MustBegin() *sqlx.Tx Close() error SetMaxOpenConns(n int) PingContext(ctx context.Context) error }
FabricCADB is the interface that wrapper off SqlxDB
type FabricCATx ¶
type FabricCATx interface { Select(funcName string, dest interface{}, query string, args ...interface{}) error Exec(funcName, query string, args ...interface{}) (sql.Result, error) Queryx(funcName, query string, args ...interface{}) (*sqlx.Rows, error) Get(funcName string, dest interface{}, query string, args ...interface{}) error Rebind(query string) string Commit(funcName string) error Rollback(funcName string) error }
FabricCATx is the interface with functions implemented by sqlx.Tx object that are used by Fabric CA server
type Metrics ¶
type Metrics struct { // APICounter keeps track of number of times a database API is called APICounter metrics.Counter // APIDuration keeps track of time taken for request to complete to a database API APIDuration metrics.Histogram }
Metrics is the set of meters for the database
type Migrator ¶
type Migrator interface { MigrateUsersTable() error MigrateCertificatesTable() error MigrateAffiliationsTable() error MigrateCredentialsTable() error MigrateRAInfoTable() error MigrateNoncesTable() error Rollback() error Commit() error }
Migrator is the interface that defines a migrator
type SqlxDB ¶
type SqlxDB interface { DriverName() string Select(dest interface{}, query string, args ...interface{}) error Exec(query string, args ...interface{}) (sql.Result, error) NamedExec(query string, arg interface{}) (sql.Result, error) Get(dest interface{}, query string, args ...interface{}) error Queryx(query string, args ...interface{}) (*sqlx.Rows, error) Rebind(query string) string MustBegin() *sqlx.Tx Close() error SetMaxOpenConns(n int) PingContext(ctx context.Context) error }
SqlxDB is the interface with functions implemented by sqlx.DB object that are used by Fabric CA server
type SqlxTx ¶
type SqlxTx interface { Queryx(query string, args ...interface{}) (*sqlx.Rows, error) Get(dest interface{}, query string, args ...interface{}) error Select(dest interface{}, query string, args ...interface{}) error Rebind(query string) string Exec(query string, args ...interface{}) (sql.Result, error) Commit() error Rollback() error }
SqlxTx is the contract with sqlx
Directories ¶
Path | Synopsis |
---|---|
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
mocks
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
mocks
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
mocks
Code generated by counterfeiter.
|
Code generated by counterfeiter. |