Help us shape the future of Go! Take the 2026 Go Developer Survey

deny

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SystemNow

func SystemNow() int64

SystemNow returns the current system time

Types

type Store

type Store struct {
	sync.Mutex

	// map of IDs currently connected, with expiry time
	AllowList map[string]int64

	// bookingIDs currently denied, with expiry time
	DenyList map[string]int64

	// Now is a function for getting the time - useful for mocking in test
	// note time is in int64 format
	Now func() int64 `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Store tracks current connections, and those that have been denied (cancelled)

func New

func New() *Store

New returns a store with the maps initialised

func (*Store) Allow

func (s *Store) Allow(ID string, expiresAt int64)

Allow reverts a denied ID back to being allowed

func (*Store) Deny

func (s *Store) Deny(ID string, expiresAt int64)

Deny adds and ID to the deny list

func (*Store) GetAllowList

func (s *Store) GetAllowList() []string

GetAllowList returns the entire allow list

func (*Store) GetDenyList

func (s *Store) GetDenyList() []string

GetDenyList returns the entire deny list

func (*Store) IsDenied

func (s *Store) IsDenied(ID string) bool

IsDenied checks if an ID is on the denied list

func (*Store) Prune

func (s *Store) Prune()

Prune removes stale entries from the Allow, Deny lists

func (*Store) SetNowFunc

func (s *Store) SetNowFunc(nf func() int64)

SetNowFunc allows providing an alternative source of the current time, for testing purposes

Jump to

Keyboard shortcuts

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