Documentation ¶
Index ¶
- func NewBufferedChannel[V any](initBufferSize int) *bufferedChannel[V]
- func WaitSynced[ObjectContent any](stopCh <-chan struct{}, informer Informer[ObjectContent]) bool
- func WaitSyncedWithTimeout[ObjectContent any](stopCh <-chan struct{}, timeout time.Duration, ...) bool
- type Callback
- type Clock
- type Event
- type EventDispatcher
- type EventHandler
- type EventHandlerFunc
- type EventType
- type Informer
- type Interface
- type ListAndWatch
- type Lister
- type Object
- type ObjectMeta
- type PollListAndWatch
- func (p *PollListAndWatch[ObjectContent]) Create(obj Object[ObjectContent])
- func (p *PollListAndWatch[ObjectContent]) Delete(meta ObjectMeta)
- func (p *PollListAndWatch[ObjectContent]) List(ctx context.Context) ([]Object[ObjectContent], error)
- func (p *PollListAndWatch[ObjectContent]) Update(obj Object[ObjectContent])
- func (p *PollListAndWatch[ObjectContent]) Watch(ctx context.Context, cb Callback[ObjectContent], ...) error
- type TypedEventHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBufferedChannel ¶
func WaitSynced ¶ added in v0.2.6
Types ¶
type Callback ¶ added in v0.2.6
type Callback[ObjectContent any] struct { OnCreate func(obj Object[ObjectContent]) OnUpdate func(obj Object[ObjectContent]) OnDelete func(meta ObjectMeta) }
type EventDispatcher ¶
type EventDispatcher[ObjectContent any] interface { Run(stopCh <-chan struct{}) Push(event Event[ObjectContent]) // should never call AddHandler and deleteHandler after Run AddHandler(handler EventHandler[ObjectContent]) (deleteHandler func()) }
func NewEventDispatcher ¶
func NewEventDispatcher[ObjectContent any]() EventDispatcher[ObjectContent]
type EventHandler ¶
type EventHandlerFunc ¶
func (EventHandlerFunc[ObjectContent]) Handle ¶
func (ehf EventHandlerFunc[ObjectContent]) Handle(event Event[ObjectContent])
type Informer ¶
type Interface ¶
type Interface[ObjectContent any] interface { Create(ctx context.Context, object Object[ObjectContent]) (Object[ObjectContent], error) // List return all objects List(ctx context.Context) ([]Object[ObjectContent], error) Get(ctx context.Context, name string) (Object[ObjectContent], error) Update(ctx context.Context, object Object[ObjectContent]) (Object[ObjectContent], error) Delete(ctx context.Context, name string) error }
Interface is used to access remote resources. may implmented by HTTP API or MySQL, etc.
type ListAndWatch ¶ added in v0.2.6
type Object ¶
type Object[Content any] struct { ObjectMeta Content Content }
type ObjectMeta ¶
type PollListAndWatch ¶ added in v0.2.6
type PollListAndWatch[ObjectContent any] struct { ListFunc func(ctx context.Context) ([]Object[ObjectContent], error) // required PollPeriod time.Duration // required // OnListError will be called when List error // it will block list // can be nil, will ignore list error OnListError func(err error, continuousCount int) // contains filtered or unexported fields }
func (*PollListAndWatch[ObjectContent]) Create ¶ added in v0.2.6
func (p *PollListAndWatch[ObjectContent]) Create(obj Object[ObjectContent])
func (*PollListAndWatch[ObjectContent]) Delete ¶ added in v0.2.6
func (p *PollListAndWatch[ObjectContent]) Delete(meta ObjectMeta)
func (*PollListAndWatch[ObjectContent]) List ¶ added in v0.2.6
func (p *PollListAndWatch[ObjectContent]) List(ctx context.Context) ([]Object[ObjectContent], error)
func (*PollListAndWatch[ObjectContent]) Update ¶ added in v0.2.6
func (p *PollListAndWatch[ObjectContent]) Update(obj Object[ObjectContent])
type TypedEventHandler ¶
type TypedEventHandler[ObjectContent any] struct { OnCreate EventHandlerFunc[ObjectContent] OnUpdate EventHandlerFunc[ObjectContent] OnDelete EventHandlerFunc[ObjectContent] }
func (TypedEventHandler[ObjectContent]) Handle ¶
func (teh TypedEventHandler[ObjectContent]) Handle(event Event[ObjectContent])
Click to show internal directories.
Click to hide internal directories.