autograph: Index | Files

package database

import ""


Package Files

connect.go queries.go


var (
    // ErrNoSuitableEEFound is returned when no suitable key is found in database
    ErrNoSuitableEEFound = errors.New("no suitable key found in database")

type Config Uses

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 Uses

type Handler struct {

Handler handles a database connection

func Connect Uses

func Connect(config Config) (*Handler, error)

Connect creates a database connection and returns a handler

func (*Handler) BeginEndEntityOperations Uses

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 Uses

func (db *Handler) CheckConnectionContext(ctx context.Context) error

CheckConnectionContext runs a test query against the database and returns an error if it fails

func (*Handler) GetLabelOfLatestEE Uses

func (db *Handler) GetLabelOfLatestEE(signerID string, youngerThan time.Duration) (label, x5u string, err error)

GetLabelOfLatestEE returns the label of the latest end-entity for the specified signer that is no older than a given duration

func (*Handler) Monitor Uses

func (db *Handler) Monitor(pollInterval time.Duration, quit chan bool)

Monitor queries the database every pollInterval until it gets a quit signal logging an error when the test query fails. It can be used in a goroutine to check when the database becomes unavailable.

type Transaction Uses

type Transaction struct {
    ID  uint64

Transaction owns a sql transaction

func (*Transaction) End Uses

func (tx *Transaction) End() error

End commits a transaction

func (*Transaction) InsertEE Uses

func (tx *Transaction) InsertEE(x5u, label, signerID string, hsmHandle uint) (err error)

InsertEE uses an existing transaction to insert an end-entity in database

Package database imports 10 packages (graph) and is imported by 4 packages. Updated 2020-10-28. Refresh now. Tools for package owners.