eventhub

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 6 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// InstanceEventTopic discover event
	InstanceEventTopic = "instance_event"
	// LeaderChangeEventTopic leader change
	LeaderChangeEventTopic = "leader_change_event"
	// ConfigFilePublishTopic config file release publish
	ConfigFilePublishTopic = "configfile_publish"
	// CacheInstanceEventTopic record cache occur instance add/update/del event
	CacheInstanceEventTopic = "cache_instance_event"
	// CacheClientEventTopic record cache occur client add/update/del event
	CacheClientEventTopic = "cache_client_event"
	// CacheNamespaceEventTopic record cache occur namespace add/update/del event
	CacheNamespaceEventTopic = "cache_namespace_event"
	// ClientEventTopic .
	ClientEventTopic = "client_event"
)

事件主题

Variables

View Source
var (
	ErrorEventhubNotInitialize = errors.New("eventhub not initialize")
)

Functions

func InitEventHub

func InitEventHub()

InitEventHub initialize event hub

func Publish

func Publish(topic string, event Event) error

Publish pushlish event to topic @param topic Topic name @param event Event object

func RegisterPublisher added in v1.18.0

func RegisterPublisher(topic string, opt PublishOption) error

func Shutdown

func Shutdown()

Shutdown shutdown event hub

Types

type CacheClientEvent added in v1.18.0

type CacheClientEvent struct {
	Client    *model.Client
	EventType EventType
}

type CacheInstanceEvent added in v1.18.0

type CacheInstanceEvent struct {
	Instance  *model.Instance
	EventType EventType
}

type CacheNamespaceEvent added in v1.18.0

type CacheNamespaceEvent struct {
	OldItem   *model.Namespace
	Item      *model.Namespace
	EventType EventType
}

type Event

type Event interface{}

Event evnt type

type EventType added in v1.18.0

type EventType int

EventType common event type

const (
	// EventCreated value create event
	EventCreated EventType = iota
	// EventUpdated value update event
	EventUpdated
	// EventDeleted value delete event
	EventDeleted
)

type Handler

type Handler interface {
	// PreProcess do preprocess logic for event
	PreProcess(context.Context, any) any
	// OnEvent event process logic
	OnEvent(ctx context.Context, any2 any) error
}

Handler event handler

type HandlerFunc added in v1.18.0

type HandlerFunc func(ctx context.Context, any2 any) error

type PublishConfigFileEvent added in v1.17.3

type PublishConfigFileEvent struct {
	Message *model.SimpleConfigFileRelease
}

PublishConfigFileEvent 事件对象,包含类型和事件消息

type PublishOption added in v1.18.0

type PublishOption struct {
	WaitHaveSub bool
}

PublishOption .

type SubOption

type SubOption func(s *SubOptions)

SubOption subscription option func

func WithQueueSize

func WithQueueSize(size int) SubOption

WithQueueSize set event queue size

type SubOptions

type SubOptions struct {
	QueueSize int
}

SubOptions subscripion options

type SubscribtionContext added in v1.17.3

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

func Subscribe

func Subscribe(topic string, handler Handler, opts ...SubOption) (*SubscribtionContext, error)

Subscribe subscribe topic

func SubscribeWithFunc added in v1.18.0

func SubscribeWithFunc(topic string, handler HandlerFunc, opts ...SubOption) (*SubscribtionContext, error)

SubscribeWithFunc subscribe topic use func

func (*SubscribtionContext) Cancel added in v1.17.3

func (s *SubscribtionContext) Cancel()

Jump to

Keyboard shortcuts

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