nonce

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, logger *log.Logger, 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