Documentation ¶
Index ¶
- Variables
- func GetTestDBHost() string
- type Config
- type Handler
- func (db *Handler) BeginEndEntityOperations() (*Transaction, error)
- func (db *Handler) CheckConnectionContext(ctx context.Context) error
- func (db *Handler) GetLabelOfLatestEE(signerID string, youngerThan time.Duration) (label, x5u string, err error)
- func (db *Handler) Monitor(pollInterval time.Duration, quit chan bool)
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoSuitableEEFound is returned when no suitable key is found in database ErrNoSuitableEEFound = fmt.Errorf("no suitable key found in database") )
Functions ¶
func GetTestDBHost ¶
func GetTestDBHost() string
GetTestDBHost returns the env var AUTOGRAPH_DB_HOST value or default of 127.0.0.1
Types ¶
type Config ¶
type Config struct { Name string User string Password string Host string SSLMode string SSLRootCert string MaxOpenConns int MaxIdleConns int MonitorPollInterval time.Duration }
Config holds the parameters to connect to a database
type Handler ¶
Handler handles a database connection
func (*Handler) BeginEndEntityOperations ¶
func (db *Handler) BeginEndEntityOperations() (*Transaction, error)
BeginEndEntityOperations creates a database transaction that locks the endentities table, this should be called before doing any lookup or generation operation with endentities.
This global lock will effectively prevent any sort of concurrent operation, which is exactly what we want in the case of key generation. Being slow and blocking is OK, risking two key generation the happen in parallel is not.
func (*Handler) CheckConnectionContext ¶
CheckConnectionContext runs a test query against the database and returns an error if it fails
type Transaction ¶
Transaction owns a sql transaction
func (*Transaction) InsertEE ¶
func (tx *Transaction) InsertEE(x5u, label, signerID string) (err error)
InsertEE uses an existing transaction to insert an end-entity in database