event

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRateLimitngQueue

func NewRateLimitngQueue(numWorkers int, stop <-chan struct{}) (inChan chan<- Resource, outChan <-chan Resource)

NewRateLimitngQueue returns new rate limiting resource event queue

func NewUniqueQueue

func NewUniqueQueue(stop <-chan struct{}, size ...int) (inChan chan<- Resource, outChan <-chan Resource)

NewUniqueQueue returns a queue for events which ensures that events in the queue are unique it takes optional arguments ioSize and bufSize ioSize is the size of in and out buffered channels bufSize is the size of internal buffer in the queue

Types

type Handler

type Handler interface {
	OnChange(r Resource)
}

Handler is the interface for notifying resource changes

type HandlerFuncs

type HandlerFuncs struct {
	OnChangeFunc func(r Resource)
	NameFunc     func() string
}

HandlerFuncs is a utility for creating event handler with functions

func (HandlerFuncs) OnChange

func (f HandlerFuncs) OnChange(r Resource)

OnChange is the callback for notifying when resource is changed

type Resource

type Resource struct {
	PartnerID      string            `json:"pa,omitempty"`
	OrganizationID string            `json:"or,omitempty"`
	ProjectID      string            `json:"pr,omitempty"`
	ID             string            `json:"id,omitempty"`
	Name           string            `json:"n,omitempty"`
	EventType      ResourceEventType `json:"t,omitempty"`
	Username       string            `json:"un,omitempty"`
	Account        string            `json:"acc,omitempty"`
}

Resource represents an event generated when resource changes it should be looked as an parameter to the event handler callback

func (Resource) Key

func (sr Resource) Key() string

Key is the key for this event which can be used as a cache key etc

type ResourceEventType

type ResourceEventType int

ResourceEventType is type of resource event

const (
	EventTypeNotSet ResourceEventType = iota
	ResourceCreate
	ResourceUpdate
	ResourceDelete
	ResourceUpdateStatus
)

Resource event types

Jump to

Keyboard shortcuts

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