resource

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckableResource

type CheckableResource interface {
	Resource
	IsUsable() bool
}

type Container

type Container[T Resource] interface {
	io.Closer
	GetOpen(key string, open func() (T, error)) (T, error)
	CloseUnused(isUsed func(key string) bool) error
}

type Resource

type Resource = io.Closer

type Singleton

type Singleton[T Resource] struct {
	// contains filtered or unexported fields
}

Singleton represents a set of resources identified by an unique key.

func NewSingleton

func NewSingleton[T Resource](log *log.Logger) *Singleton[T]

func (*Singleton[T]) Close

func (s *Singleton[T]) Close() error

func (*Singleton[T]) CloseUnused

func (s *Singleton[T]) CloseUnused(isUsed func(key string) bool) error

func (*Singleton[T]) GetOpen

func (s *Singleton[T]) GetOpen(key string, open func() (T, error)) (T, error)

type Tracker

type Tracker[T Resource] struct {
	C Container[T]
	// contains filtered or unexported fields
}

Tracker is a container wrapper that tracks whether resources were used since last MarkAllUnused call.

func NewTracker

func NewTracker[T Resource](c Container[T]) *Tracker[T]

func (*Tracker[T]) Close

func (t *Tracker[T]) Close() error

func (*Tracker[T]) CloseUnused

func (t *Tracker[T]) CloseUnused(isUsed func(key string) bool) error

func (*Tracker[T]) GetOpen

func (t *Tracker[T]) GetOpen(key string, open func() (T, error)) (T, error)

func (*Tracker[T]) MarkAllUnused

func (t *Tracker[T]) MarkAllUnused()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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