nonce

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store allows generating and consuming nonce values.

func NewStore added in v0.28.0

func NewStore(ctx context.Context, db *sql.DB) (*Store, error)

NewStore prepares a new Store.

func (*Store) Consume

func (s *Store) Consume(ctx context.Context, id [16]byte) (bool, error)

Consume will record the use of a nonce value.

An error is returned if it is not possible to validate the nonce value. Otherwise true/false is returned to indicate if the id is valid.

The first call to Consume for a given ID will return true, subsequent calls for the same ID will return false.

func (*Store) New

func (s *Store) New() [16]byte

New will generate a new cryptographically random nonce value.

func (*Store) Shutdown

func (s *Store) Shutdown(ctx context.Context) error

Shutdown allows gracefully shutting down the nonce store.

Jump to

Keyboard shortcuts

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