resources

package
v0.0.0-...-75be81d Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyObserver

type DummyObserver struct{}

func (DummyObserver) AfterAlloc

func (observer DummyObserver) AfterAlloc(ctx context.Context, resources []string)

func (DummyObserver) AfterDealloc

func (observer DummyObserver) AfterDealloc(ctx context.Context, resources []string)

func (DummyObserver) AfterInit

func (observer DummyObserver) AfterInit(ctx context.Context, resources []core.Resource)

func (DummyObserver) AfterLoad

func (observer DummyObserver) AfterLoad(ctx context.Context, resources []core.Resource)

func (DummyObserver) BeforeAlloc

func (observer DummyObserver) BeforeAlloc(ctx context.Context, n int) error

func (DummyObserver) BeforeDealloc

func (observer DummyObserver) BeforeDealloc(ctx context.Context, resources []string) error

func (DummyObserver) BeforeInit

func (observer DummyObserver) BeforeInit(ctx context.Context, resources []core.Resource) error

func (DummyObserver) BeforeLoad

func (observer DummyObserver) BeforeLoad(ctx context.Context, ids []string) error

func (DummyObserver) OnAllocError

func (observer DummyObserver) OnAllocError(ctx context.Context, n int, err error)

func (DummyObserver) OnDeallocError

func (observer DummyObserver) OnDeallocError(ctx context.Context, resources []string, err error)

func (DummyObserver) OnInitError

func (observer DummyObserver) OnInitError(ctx context.Context, resources []core.Resource, err error)

func (DummyObserver) OnLoadError

func (observer DummyObserver) OnLoadError(ctx context.Context, ids []string, err error)

type FunctionalObserver

type FunctionalObserver struct {
	BeforeLoadF     func(ctx context.Context, ids []string) error
	AfterLoadF      func(ctx context.Context, resources []core.Resource)
	OnLoadErrorF    func(ctx context.Context, ids []string, err error)
	BeforeAllocF    func(ctx context.Context, n int) error
	AfterAllocF     func(ctx context.Context, resources []string)
	OnAllocErrorF   func(ctx context.Context, n int, err error)
	BeforeInitF     func(ctx context.Context, resources []core.Resource) error
	AfterInitF      func(ctx context.Context, resources []core.Resource)
	OnInitErrorF    func(ctx context.Context, resources []core.Resource, err error)
	BeforeDeallocF  func(ctx context.Context, resources []string) error
	AfterDeallocF   func(ctx context.Context, resources []string)
	OnDeallocErrorF func(ctx context.Context, resources []string, err error)
}

func (FunctionalObserver) AfterAlloc

func (observer FunctionalObserver) AfterAlloc(ctx context.Context, resources []string)

func (FunctionalObserver) AfterDealloc

func (observer FunctionalObserver) AfterDealloc(ctx context.Context, resources []string)

func (FunctionalObserver) AfterInit

func (observer FunctionalObserver) AfterInit(ctx context.Context, resources []core.Resource)

func (FunctionalObserver) AfterLoad

func (observer FunctionalObserver) AfterLoad(ctx context.Context, resources []core.Resource)

func (FunctionalObserver) BeforeAlloc

func (observer FunctionalObserver) BeforeAlloc(ctx context.Context, n int) error

func (FunctionalObserver) BeforeDealloc

func (observer FunctionalObserver) BeforeDealloc(ctx context.Context, resources []string) error

func (FunctionalObserver) BeforeInit

func (observer FunctionalObserver) BeforeInit(ctx context.Context, resources []core.Resource) error

func (FunctionalObserver) BeforeLoad

func (observer FunctionalObserver) BeforeLoad(ctx context.Context, ids []string) error

func (FunctionalObserver) OnAllocError

func (observer FunctionalObserver) OnAllocError(ctx context.Context, n int, err error)

func (FunctionalObserver) OnDeallocError

func (observer FunctionalObserver) OnDeallocError(ctx context.Context, resources []string, err error)

func (FunctionalObserver) OnInitError

func (observer FunctionalObserver) OnInitError(ctx context.Context, resources []core.Resource, err error)

func (FunctionalObserver) OnLoadError

func (observer FunctionalObserver) OnLoadError(ctx context.Context, ids []string, err error)

type Notifier

type Notifier struct {
	Broker core.Broker
	Topic  string

	Logger *slog.Logger

	DummyObserver
}

func (Notifier) AfterInit

func (notifier Notifier) AfterInit(ctx context.Context, resources []core.Resource)

type Observable

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

func Observe

func Observe(raw core.ResourceDB, observer Observer) *Observable

func (*Observable) Alloc

func (storage *Observable) Alloc(ctx context.Context, amount int) ([]string, error)

func (*Observable) Dealloc

func (storage *Observable) Dealloc(ctx context.Context, ids []string) error

func (*Observable) Init

func (storage *Observable) Init(ctx context.Context, resources []core.Resource) error

func (*Observable) Load

func (storage *Observable) Load(ctx context.Context, ids ...string) ([]core.Resource, error)

type Observer

type Observer interface {
	BeforeLoad(ctx context.Context, ids []string) error
	AfterLoad(ctx context.Context, resources []core.Resource)
	OnLoadError(ctx context.Context, ids []string, err error)

	BeforeAlloc(ctx context.Context, n int) error
	AfterAlloc(ctx context.Context, resources []string)
	OnAllocError(ctx context.Context, n int, err error)

	BeforeInit(ctx context.Context, resources []core.Resource) error
	AfterInit(ctx context.Context, resources []core.Resource)
	OnInitError(ctx context.Context, resources []core.Resource, err error)

	BeforeDealloc(ctx context.Context, resources []string) error
	AfterDealloc(ctx context.Context, resources []string)
	OnDeallocError(ctx context.Context, resources []string, err error)
}

Jump to

Keyboard shortcuts

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