informer

package
v0.3.11-8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EtcdInformerPrefix     = "/onecloud/informer"
	EtcdInformerClientsKey = "@clients"

	EventTypeCreate = "CREATE"
	EventTypeUpdate = "UPDATE"
	EventTypeDelete = "DELETE"
)
View Source
const (
	ErrBackendNotInit = errors.Error("InformerBackend not init")
)

Variables

This section is empty.

Functions

func AddWatchedResources

func AddWatchedResources(resources ...string)

func Create

func Create(ctx context.Context, obj *ModelObject) error

func Delete

func Delete(ctx context.Context, obj *ModelObject) error

func DeleteWatchedResources

func DeleteWatchedResources(resources ...string)

func GetWatchResources

func GetWatchResources() sets.String

func Init

func Init(be IInformerBackend)

func IsInit

func IsInit() bool

func Set

func Set(be IInformerBackend)

func Update

func Update(ctx context.Context, obj *ModelObject, oldObj *jsonutils.JSONDict) error

Types

type EtcdBackend

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

func NewEtcdBackend

func NewEtcdBackend(opt *etcd.SEtcdOptions, onKeepaliveFailure func()) (*EtcdBackend, error)

func (*EtcdBackend) Create

func (b *EtcdBackend) Create(ctx context.Context, obj *ModelObject) error

func (*EtcdBackend) Delete

func (b *EtcdBackend) Delete(ctx context.Context, obj *ModelObject) error

func (*EtcdBackend) GetType

func (b *EtcdBackend) GetType() string

func (*EtcdBackend) PutSession

func (b *EtcdBackend) PutSession(ctx context.Context, key, val string) error

func (*EtcdBackend) PutWithLease

func (b *EtcdBackend) PutWithLease(ctx context.Context, key, val string, ttlSeconds int64) error

func (*EtcdBackend) StartClientWatch

func (b *EtcdBackend) StartClientWatch(ctx context.Context)

func (*EtcdBackend) Update

func (b *EtcdBackend) Update(ctx context.Context, obj *ModelObject, oldObj *jsonutils.JSONDict) error

type EtcdBackendForClient

type EtcdBackendForClient struct {
	*EtcdBackend
	// contains filtered or unexported fields
}

func NewEtcdBackendForClient

func NewEtcdBackendForClient(opt *etcd.SEtcdOptions) (*EtcdBackendForClient, error)

func (*EtcdBackendForClient) StartClientWatch

func (b *EtcdBackendForClient) StartClientWatch(ctx context.Context)

func (*EtcdBackendForClient) Unwatch

func (b *EtcdBackendForClient) Unwatch(key string)

func (*EtcdBackendForClient) Watch

type IInformerBackend

type IInformerBackend interface {
	GetType() string
	Create(ctx context.Context, obj *ModelObject) error
	Update(ctx context.Context, obj *ModelObject, oldObj *jsonutils.JSONDict) error
	Delete(ctx context.Context, obj *ModelObject) error
}

func GetDefaultBackend

func GetDefaultBackend() IInformerBackend

type IWatcher

type IWatcher interface {
	Watch(ctx context.Context, key string, handler ResourceEventHandler) error
	Unwatch(key string)
}

type ModelObject

type ModelObject struct {
	Object        *jsonutils.JSONDict
	KeywordPlural string
	Id            string
	IsJoint       bool
	MasterId      string
	SlaveId       string
}

func NewJointModel

func NewJointModel(obj interface{}, keywordPlural, masterId, slaveId string) *ModelObject

func NewModel

func NewModel(obj interface{}, keywordPlural, id string) *ModelObject

type ResourceEventHandler

type ResourceEventHandler interface {
	OnAdd(obj *jsonutils.JSONDict)
	OnUpdate(oldObj, newObj *jsonutils.JSONDict)
	OnDelete(obj *jsonutils.JSONDict)
}

type TEventType

type TEventType string

Jump to

Keyboard shortcuts

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