common

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCacheManager

func RegisterCacheManager(man CacheManager)

func Start

func Start[O lockman.ILockedObject](ctx context.Context, resMan IResourceManager[O])

Types

type CacheManager

type CacheManager interface {
	ReloadHosts(ids []string) ([]interface{}, error)
}

func GetCacheManager

func GetCacheManager() CacheManager

type CommonResourceManager

type CommonResourceManager[O lockman.ILockedObject] struct {
	// contains filtered or unexported fields
}

func NewCommonResourceManager

func NewCommonResourceManager[O lockman.ILockedObject](
	keyword string,
	refreshInterval time.Duration,
	store IResourceStore[O],
) *CommonResourceManager[O]

func (CommonResourceManager[O]) GetAll

func (m CommonResourceManager[O]) GetAll() []O

func (*CommonResourceManager[O]) GetKeyword

func (m *CommonResourceManager[O]) GetKeyword() string

func (*CommonResourceManager[O]) GetRefreshInterval

func (m *CommonResourceManager[O]) GetRefreshInterval() time.Duration

func (CommonResourceManager[O]) GetResource

func (m CommonResourceManager[O]) GetResource(id string) (O, bool)

func (CommonResourceManager[O]) GetStore

func (m CommonResourceManager[O]) GetStore() IResourceStore[O]

func (*CommonResourceManager[O]) Start

func (m *CommonResourceManager[O]) Start(ctx context.Context)

func (*CommonResourceManager[O]) SyncOnce

func (m *CommonResourceManager[O]) SyncOnce() error

type FGetDBObject

type FGetDBObject func(man db.IModelManager, id string, obj *jsonutils.JSONDict) (db.IModel, error)

type IResourceManager

type IResourceManager[O lockman.ILockedObject] interface {
	GetKeyword() string

	GetRefreshInterval() time.Duration
	GetStore() IResourceStore[O]
	GetResource(id string) (O, bool)

	SyncOnce() error

	Start(ctx context.Context)
}

type IResourceStore

type IResourceStore[O lockman.ILockedObject] interface {
	GetInformerResourceManager() informer.IResourceManager

	Init() error
	Get(id string) (O, bool)
	GetAll() []O
	GetByPrefix(prefixId string) []O
	Add(obj *jsonutils.JSONDict)
	Update(oldObj, newObj *jsonutils.JSONDict)
	Delete(obj *jsonutils.JSONDict)
}

type ResourceStore

type ResourceStore[O lockman.ILockedObject] struct {
	// contains filtered or unexported fields
}

func NewJointResourceStore

func NewJointResourceStore[O lockman.ILockedObject](
	modelMan db.IModelManager,
	res informer.IResourceManager,
	getId func(O) string,
	getWatchId func(*jsonutils.JSONDict) string,
	getDBObject FGetDBObject,
) *ResourceStore[O]

func NewResourceStore

func NewResourceStore[O lockman.ILockedObject](
	modelMan db.IModelManager,
	res informer.IResourceManager,
) *ResourceStore[O]

func (*ResourceStore[O]) Add

func (s *ResourceStore[O]) Add(obj *jsonutils.JSONDict)

func (*ResourceStore[O]) Delete

func (s *ResourceStore[O]) Delete(obj *jsonutils.JSONDict)

func (*ResourceStore[O]) Get

func (s *ResourceStore[O]) Get(id string) (O, bool)

func (*ResourceStore[O]) GetAll

func (s *ResourceStore[O]) GetAll() []O

func (*ResourceStore[O]) GetByPrefix

func (s *ResourceStore[O]) GetByPrefix(prefixId string) []O

func (*ResourceStore[O]) GetInformerResourceManager

func (s *ResourceStore[O]) GetInformerResourceManager() informer.IResourceManager

func (*ResourceStore[O]) Init

func (s *ResourceStore[O]) Init() error

func (*ResourceStore[O]) Update

func (s *ResourceStore[O]) Update(oldObj, newObj *jsonutils.JSONDict)

func (*ResourceStore[O]) WithOnAdd

func (s *ResourceStore[O]) WithOnAdd(onAdd func(db.IModel)) *ResourceStore[O]

func (*ResourceStore[O]) WithOnDelete

func (s *ResourceStore[O]) WithOnDelete(onDelete func(*jsonutils.JSONDict)) *ResourceStore[O]

func (*ResourceStore[O]) WithOnUpdate

func (s *ResourceStore[O]) WithOnUpdate(onUpdate func(old *jsonutils.JSONDict, newObj db.IModel)) *ResourceStore[O]

Jump to

Keyboard shortcuts

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