expirationwatch

package
v5.0.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: Apache-2.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpiredItem

type ExpiredItem struct {
	ExpirationTimestamp time.Time
	ID                  string
}

ExpiredItem represents an expired item returned from the Watcher

type Watcher

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

Watcher watches the expiration of items

func New

func New(expirationBuffer time.Duration) *Watcher

New instantiates a new expiration watcher. An expiration buffer (positive or negative) can be specified, causing items to be deemed expired some time before or after their expiration reaches current UTC time. A positive expirationBuffer will make the item expire sooner then UTC, and a negative buffer after.

func (*Watcher) Add

func (w *Watcher) Add(expirationTimestamp time.Time, id string)

Add adds a new item identified by an ID to the expiration watcher

func (*Watcher) ExpiredItems

func (w *Watcher) ExpiredItems() <-chan []ExpiredItem

ExpiredItems returns a read-only channel that can be used to listen for expired items. The channel will be closed if/when the watcher is done watching.

func (*Watcher) Remove

func (w *Watcher) Remove(expirationTimestamp time.Time, id string)

Remove removes the item with a specified id from the expiration watcher

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context, pollingInterval time.Duration) error

Watch starts the expiration watchers poller. It continuously checks all items for expiration until there is an error or the given context is canceled. You usually want to call Watch inside a goroutine.

Jump to

Keyboard shortcuts

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