tgutil

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf return Error with the function info.

func NewError

func NewError(info string) error

NewError return Error with the function info.

Types

type UUIDMap

type UUIDMap[T any] interface {
	// New create a (id -> T) mapping and return id.
	New() string

	// Get return (T, alive) by id, return nil if id does not exist.
	Get(id string) (*T, bool)

	// Del delete uuid.
	Del(id string)

	// SetAlive flag of id
	SetAlive(id string, alive bool)

	// Size return the number of T.
	Size() int

	// Destroy the resource hold by the State.
	Destroy()
}

UUIDMap provide a goroutine-safe mapping from UUID to T.

func NewUUIDMap

func NewUUIDMap[T any](
	constructor func() *T, destructor func(*T), ttl time.Duration) UUIDMap[T]

NewUUIDMap create T by providing the constructor and destructor the of T.

Jump to

Keyboard shortcuts

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