pusher

package
v0.0.0-...-932f233 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PushedItems

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

func (*PushedItems) ResourceList

func (items *PushedItems) ResourceList() core_model.ResourceList

func (*PushedItems) Revision

func (items *PushedItems) Revision() int64

type Pusher

type Pusher interface {
	component.Component
	// AddCallback add callback for target resource type using id
	// for example, id is a unique id for every client, when resource changed for target resourceType, it will invoke callback
	AddCallback(resourceType core_model.ResourceType, id string, callback ResourceChangedCallbackFn, filters ...ResourceChangedEventFilter)
	// RemoveCallback remove callback
	RemoveCallback(resourceType core_model.ResourceType, id string)
	// InvokeCallback invoke a target callback
	// for example, for a push request from client, invoke this function to push resource.
	InvokeCallback(resourceType core_model.ResourceType, id string, request interface{}, requestFilter ResourceRequestFilter)
}

Pusher 's job is to push resource

func NewPusher

func NewPusher(
	resourceManager manager.ResourceManager,
	eventBus events.EventBus,
	newFullResyncTicker func() *time.Ticker,
	resourceTypes []core_model.ResourceType,
) Pusher

type ResourceChangedCallback

type ResourceChangedCallback struct {
	Callback ResourceChangedCallbackFn
	Filters  []ResourceChangedEventFilter
	// contains filtered or unexported fields
}

func (*ResourceChangedCallback) Invoke

func (c *ResourceChangedCallback) Invoke(items PushedItems)

type ResourceChangedCallbackFn

type ResourceChangedCallbackFn func(items PushedItems)

type ResourceChangedCallbacks

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

func NewResourceChangedCallbacks

func NewResourceChangedCallbacks() *ResourceChangedCallbacks

func (*ResourceChangedCallbacks) AddCallBack

func (callbacks *ResourceChangedCallbacks) AddCallBack(
	resourceType core_model.ResourceType,
	id string,
	callback ResourceChangedCallbackFn,
	filters ...ResourceChangedEventFilter,
)

func (*ResourceChangedCallbacks) GetCallBack

func (callbacks *ResourceChangedCallbacks) GetCallBack(resourceType core_model.ResourceType, id string) (*ResourceChangedCallback, bool)

func (*ResourceChangedCallbacks) InvokeCallbacks

func (callbacks *ResourceChangedCallbacks) InvokeCallbacks(resourceType core_model.ResourceType, items PushedItems)

func (*ResourceChangedCallbacks) RemoveCallBack

func (callbacks *ResourceChangedCallbacks) RemoveCallBack(resourceType core_model.ResourceType, id string)

type ResourceChangedEventFilter

type ResourceChangedEventFilter func(resourceList core_model.ResourceList) core_model.ResourceList

type ResourceRequestFilter

type ResourceRequestFilter func(request interface{}, resourceList core_model.ResourceList) core_model.ResourceList

Jump to

Keyboard shortcuts

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