persistence

package
Version: v0.0.0-...-a400e20 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxConsecutiveClaimKeyFailures = 8
)

Variables

View Source
var ErrDuplicateKey = errors.New("key is already registered")
View Source
var ErrInvalidKeyFormat = errors.New("argument had wrong size")
View Source
var ErrInvalidOneTimeCode = errors.New("argument had wrong size")
View Source
var ErrKeyConsumed = errors.New("keypair has uploaded maximum number of diagnosis keys")
View Source
var ErrNoRecordWritten = errors.New("we tried to write a transaction but no record was written")

ErrNoRecordWritten indicates that, though we should have been able to write a transaction to the DB, for some reason no record was created. This must be a bug with our query logic, because it should never happen.

View Source
var ErrTooManyKeys = errors.New("key limit for keypair exceeded")

ErrTooManyKeys is returned when the client tries to insert one or more keys past their limit, assigned on keypair creation. The entire batch is rejected.

Functions

func MigrateDatabase

func MigrateDatabase(url string) error

MigrateDatabase creates the database and migrates it into the correct state.

Types

type Conn

type Conn interface {
	// Return keys that were SUBMITTED to the Diagnosis Server during the specified
	// UTC date.
	//
	// Only returns keys that correspond to a Key for a date
	// less than 14 days ago.
	FetchKeysForDateNumber(string, uint32, int32) ([]*pb.TemporaryExposureKey, error)
	StoreKeys(*[32]byte, []*pb.TemporaryExposureKey) error
	NewKeyClaim(string, string) (string, error)
	ClaimKey(string, []byte) ([]byte, error)
	PrivForPub([]byte) ([]byte, error)

	CheckClaimKeyBan(string) (triesRemaining int, banDuration time.Duration, err error)
	ClaimKeySuccess(string) error
	ClaimKeyFailure(string) (triesRemaining int, banDuration time.Duration, err error)

	DeleteOldDiagnosisKeys() (int64, error)
	DeleteOldEncryptionKeys() (int64, error)
	DeleteOldFailedClaimKeyAttempts() (int64, error)

	Close() error
}

Conn mediates all access to a MySQL/CloudSQL connection. It exposes a method for each query we support. The one exception is database creation/migrations, which are handled separately.

func Dial

func Dial(url string) (Conn, error)

Dial establishes a MySQL/CloudSQL connection and returns a Conn object, wrapping each available query.

Jump to

Keyboard shortcuts

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