eventc

package
v0.0.0-...-7404c28 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package eventc eventc ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Change   *sfs.ReleaseEventMetaV1
	Instance *sfs.InstanceSpec
	CursorID uint32
}

Event defines the event details.

type Handler

type Handler struct {
	// GetMatchedRelease get the specified app instance's current release id.
	// Note: this function's match pipeline should not use cache data,
	GetMatchedRelease func(kt *kit.Kit, meta *btyp.AppInstanceMeta) (uint32, error)
}

Handler all the call back handles, used to handle schedule jobs.

type Option

type Option struct {
	Observer observer.Interface
	Cache    *lcache.Cache
}

Option defines options to create a scheduler instance.

type Receiver

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

Receiver is defined for the subscriber to control its working state and receive the event messages.

func InitReceiver

func InitReceiver(notify func(event *Event, sn uint64) bool, closeWatch context.CancelFunc) *Receiver

InitReceiver initial a new receiver instance.

func (*Receiver) CloseWatch

func (r *Receiver) CloseWatch()

CloseWatch close sidecar and feed server watch stream.

func (*Receiver) Notify

func (r *Receiver) Notify(event *Event, uid string, sn uint64) bool

Notify send the event to the subscriber.

func (*Receiver) SetState

func (r *Receiver) SetState(state bool)

SetState set the receiver's state

func (*Receiver) State

func (r *Receiver) State() bool

State return the current state of receiver

type Scheduler

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

Scheduler works at all the events handling jobs. 1. it accepts subscribe from sidecar and unsubscribe when the sidecar close the connection. 2. it sends events to all the subscribers and will retry to send event if it fails.

func NewScheduler

func NewScheduler(opt *Option, name string) (*Scheduler, error)

NewScheduler create a new scheduler instance. And, scheduler start accept subscribe and unsubscribe operations, but still not works for events processing, which means scheduler do not match the subscribed instance's release.

func (*Scheduler) Run

func (sch *Scheduler) Run(h *Handler) error

Run start the scheduler's job

func (*Scheduler) Subscribe

func (sch *Scheduler) Subscribe(currentRelease uint32, currentCursorID uint32, subSpec *SubscribeSpec) (uint64, error)

Subscribe register an app instance to subscribe the release event for it. it returns a serial number(as is sn) which represent this app instance's watch identity id.

func (*Scheduler) Unsubscribe

func (sch *Scheduler) Unsubscribe(appID uint32, sn uint64, uid string)

Unsubscribe for the app to unsubscribe the event.

type SubscribeSpec

type SubscribeSpec struct {
	InstSpec *sfs.InstanceSpec
	Receiver *Receiver
}

SubscribeSpec defines the metadata to watch the event.

func (SubscribeSpec) Validate

func (s SubscribeSpec) Validate() error

Validate the SubscribeSpec is valid or not.

type Watcher

type Watcher interface {
	Subscribe(currentRelease uint32, currentCursorID uint32, subSpec *SubscribeSpec) (uint64, error)
	Unsubscribe(appID uint32, sn uint64, uid string)
}

Watcher defines all the supported operations by watch. which is used to watch the resource's change events.

Jump to

Keyboard shortcuts

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