timer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

This file contains the lock timer manager struct and methods. A lock timer manager is used for handling a map of lock timers which perform a callback when they expire. They can be removed or refreshed before they expire.

Index

Constants

This section is empty.

Variables

View Source
var ErrLockDoesNotExistOrInvalidKey = errors.New("lock does not exist or an invalid key was used")

Can be returned from Refresh() when the lock + key combo is not found in the lockTimers map

Functions

This section is empty.

Types

type Manager

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

Manager for a map of lock times

func NewManager

func NewManager(otf onTimeoutFunc) (m *Manager, shutdown func())

NewManager initializes a new Manager with the provided onTimeoutFunc.

Parameter: onTimeoutFunc function to run when lock times out Returns a pointer to Manager and a shutdown function.

func (*Manager) Add

func (m *Manager) Add(name string, key string, timeout time.Duration)

Add creates and adds a lock timer to the map

func (*Manager) Refresh

func (m *Manager) Refresh(name string, key string, timeout time.Duration) (bool, error)

Refresh refreshes a lock timer

func (*Manager) Remove

func (m *Manager) Remove(name string, key string)

Remove removes a lock timer from the map

Jump to

Keyboard shortcuts

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