db

package
v0.0.0-...-eff5e3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2019 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseOpts

type DatabaseOpts struct {
	AccountNotifier       chan *core.Account
	AuthorizationNotifier chan *core.Authorization
	ChallengeNotifier     chan *core.Challenge
	CertificateNotifier   chan *core.Certificate
	OrderNotifier         chan *core.Order
	RevocationNotifier    chan *core.RevokedCertificate

	// Send notifications on updates. If set to true, updated records will be sent to the notification channels along
	// with new records.
	NotifyOnUpdate bool

	// Message router.
	Receiver chan interface{}

	// Logger
	Logger *logrus.Logger
}

Options for implementing notifiers. If fields are nil, messages are dropped. Notification channels are designed for live updates from the database for closer testing, if needed.

func NewDefaultDatabaseOpts

func NewDefaultDatabaseOpts() *DatabaseOpts

Generate some default configurations for the database. All channels are set to a length of 10, NotifyOnUpdate is set to false.

type ExistingAccountError

type ExistingAccountError struct {
	MatchingAccount *core.Account
}

ExistingAccountError is an error type indicating when an operation fails because the MatchingAccount has a key conflict.

func (ExistingAccountError) Error

func (e ExistingAccountError) Error() string

type GravelStore

type GravelStore interface {
	GetAccountByID(id string) *core.Account
	GetAccountByKey(key crypto.PublicKey) (*core.Account, error)

	// Note that this function should *NOT* be used for key changes. It assumes
	// the public key associated to the account does not change. Use ChangeAccountKey
	// to change the account's public key.
	UpdateAccountByID(id string, acct *core.Account) error
	AddAccount(acct *core.Account) (int, error)
	ChangeAccountKey(acct *core.Account, newKey *jose.JSONWebKey) error
	AddOrder(order *core.Order) (int, error)
	GetOrderByID(id string) *core.Order
	AddAuthorization(authz *core.Authorization) (int, error)
	GetAuthorizationByID(id string) *core.Authorization

	// FindValidAuthorization fetches the first, if any, valid and unexpired authorization for the
	// provided identifier, from the ACME account matching accountID.
	FindValidAuthorization(accountID string, identifier acme.Identifier) *core.Authorization
	AddChallenge(chal *core.Challenge) (int, error)
	GetChallengeByID(id string) *core.Challenge
	AddCertificate(cert *core.Certificate) (int, error)
	GetCertificateByID(id string) *core.Certificate
	GetCertificateByDER(der []byte) *core.Certificate
	GetRevokedCertificateByDER(der []byte) *core.RevokedCertificate
	RevokeCertificate(cert *core.RevokedCertificate)
	GetCertificateBySerial(serialNumber *big.Int) *core.Certificate
	GetRevokedCertificateBySerial(serialNumber *big.Int) *core.RevokedCertificate

	// Handles notifications in and out of the database.
	NotificationHandler()
}

Interface reference for a database.

func NewMemoryStore

func NewMemoryStore(opts *DatabaseOpts) GravelStore

type InMemoryStore

type InMemoryStore struct {
	// contains filtered or unexported fields
}

Gravel's internal database for handling records. Information here is designed to be exported through notifiers, as seen in DatabaseOpts.

func (*InMemoryStore) AddAccount

func (m *InMemoryStore) AddAccount(acct *core.Account) (int, error)

func (*InMemoryStore) AddAuthorization

func (m *InMemoryStore) AddAuthorization(authz *core.Authorization) (int, error)

func (*InMemoryStore) AddCertificate

func (m *InMemoryStore) AddCertificate(cert *core.Certificate) (int, error)

func (*InMemoryStore) AddChallenge

func (m *InMemoryStore) AddChallenge(chal *core.Challenge) (int, error)

func (*InMemoryStore) AddOrder

func (m *InMemoryStore) AddOrder(order *core.Order) (int, error)

func (*InMemoryStore) ChangeAccountKey

func (m *InMemoryStore) ChangeAccountKey(acct *core.Account, newKey *jose.JSONWebKey) error

func (*InMemoryStore) FindValidAuthorization

func (m *InMemoryStore) FindValidAuthorization(accountID string, identifier acme.Identifier) *core.Authorization

func (*InMemoryStore) GetAccountByID

func (m *InMemoryStore) GetAccountByID(id string) *core.Account

func (*InMemoryStore) GetAccountByKey

func (m *InMemoryStore) GetAccountByKey(key crypto.PublicKey) (*core.Account, error)

func (*InMemoryStore) GetAuthorizationByID

func (m *InMemoryStore) GetAuthorizationByID(id string) *core.Authorization

func (*InMemoryStore) GetCertificateByDER

func (m *InMemoryStore) GetCertificateByDER(der []byte) *core.Certificate

GetCertificateByDER loops over all certificates to find the one that matches the provided DER bytes. This method is linear and it's not optimized to give you a quick response.

func (*InMemoryStore) GetCertificateByID

func (m *InMemoryStore) GetCertificateByID(id string) *core.Certificate

func (*InMemoryStore) GetCertificateBySerial

func (m *InMemoryStore) GetCertificateBySerial(serialNumber *big.Int) *core.Certificate

GetCertificateBySerial loops over all certificates to find the one that matches the provided serial number. This method is linear and it's not optimized to give you a quick response.

func (*InMemoryStore) GetChallengeByID

func (m *InMemoryStore) GetChallengeByID(id string) *core.Challenge

func (*InMemoryStore) GetOrderByID

func (m *InMemoryStore) GetOrderByID(id string) *core.Order

func (*InMemoryStore) GetRevokedCertificateByDER

func (m *InMemoryStore) GetRevokedCertificateByDER(der []byte) *core.RevokedCertificate

GetCertificateByDER loops over all revoked certificates to find the one that matches the provided DER bytes. This method is linear and it's not optimized to give you a quick response.

func (*InMemoryStore) GetRevokedCertificateBySerial

func (m *InMemoryStore) GetRevokedCertificateBySerial(serialNumber *big.Int) *core.RevokedCertificate

GetRevokedCertificateBySerial loops over all revoked certificates to find the one that matches the provided serial number. This method is linear and it's not optimized to give you a quick response.

func (*InMemoryStore) NotificationHandler

func (m *InMemoryStore) NotificationHandler()

Handle the internal message routing.

func (*InMemoryStore) RevokeCertificate

func (m *InMemoryStore) RevokeCertificate(cert *core.RevokedCertificate)

func (*InMemoryStore) UpdateAccountByID

func (m *InMemoryStore) UpdateAccountByID(id string, acct *core.Account) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL