event

package
v0.24.15 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	MetricsEventsNs      = "metrics"
	MetricsEventsVersion = 3
)
View Source
const (
	UsageEventsNs      = "fabric.usage"
	UsageEventsVersion = 2
)
View Source
const (
	ServiceEventsNs = "services"
)

Variables

Functions

This section is empty.

Types

type CircuitEvent

type CircuitEvent struct {
	Namespace        string            `json:"namespace"`
	Version          uint32            `json:"version"`
	EventType        CircuitEventType  `json:"event_type"`
	CircuitId        string            `json:"circuit_id"`
	Timestamp        time.Time         `json:"timestamp"`
	ClientId         string            `json:"client_id"`
	ServiceId        string            `json:"service_id"`
	TerminatorId     string            `json:"terminator_id"`
	InstanceId       string            `json:"instance_id"`
	CreationTimespan *time.Duration    `json:"creation_timespan,omitempty"`
	Path             CircuitPath       `json:"path"`
	LinkCount        int               `json:"link_count"`
	Cost             *uint32           `json:"path_cost,omitempty"`
	FailureCause     *string           `json:"failure_cause,omitempty"`
	Duration         *time.Duration    `json:"duration,omitempty"`
	Tags             map[string]string `json:"tags"`
}

func (*CircuitEvent) String

func (event *CircuitEvent) String() string

type CircuitEventHandler

type CircuitEventHandler interface {
	AcceptCircuitEvent(event *CircuitEvent)
}

type CircuitEventHandlerWrapper

type CircuitEventHandlerWrapper interface {
	CircuitEventHandler
	IsWrapping(value CircuitEventHandler) bool
}

type CircuitEventType

type CircuitEventType string
const (
	CircuitEventsNs                       = "fabric.circuits"
	CircuitEventsVersion                  = 2
	CircuitCreated       CircuitEventType = "created"
	CircuitUpdated       CircuitEventType = "pathUpdated"
	CircuitDeleted       CircuitEventType = "deleted"
	CircuitFailed        CircuitEventType = "failed"
)

type CircuitPath

type CircuitPath struct {
	Nodes                []string `json:"nodes"`
	Links                []string `json:"links"`
	IngressId            string   `json:"ingress_id"`
	EgressId             string   `json:"egress_id"`
	InitiatorLocalAddr   string   `json:"initiator_local_addr,omitempty"`
	InitiatorRemoteAddr  string   `json:"initiator_remote_addr,omitempty"`
	TerminatorLocalAddr  string   `json:"terminator_local_addr,omitempty"`
	TerminatorRemoteAddr string   `json:"terminator_remote_addr,omitempty"`
}

func (*CircuitPath) String

func (self *CircuitPath) String() string

type ClusterEvent

type ClusterEvent struct {
	Namespace string           `json:"namespace"`
	EventType ClusterEventType `json:"eventType"`
	Timestamp time.Time        `json:"timestamp"`
	Index     uint64           `json:"index,omitempty"`
	Peers     []*ClusterPeer   `json:"peers,omitempty"`
}

func NewClusterEvent

func NewClusterEvent(eventType ClusterEventType) *ClusterEvent

func (*ClusterEvent) String

func (event *ClusterEvent) String() string

type ClusterEventHandler

type ClusterEventHandler interface {
	AcceptClusterEvent(event *ClusterEvent)
}

type ClusterEventHandlerF

type ClusterEventHandlerF func(event *ClusterEvent)

func (ClusterEventHandlerF) AcceptClusterEvent

func (f ClusterEventHandlerF) AcceptClusterEvent(event *ClusterEvent)

type ClusterEventType

type ClusterEventType string
const (
	ClusterEventsNs = "fabric.cluster"

	ClusterPeerConnected    ClusterEventType = "peer.connected"
	ClusterPeerDisconnected ClusterEventType = "peer.disconnected"
	ClusterMembersChanged   ClusterEventType = "members.changed"
	ClusterLeadershipGained ClusterEventType = "leadership.gained"
	ClusterLeadershipLost   ClusterEventType = "leadership.lost"
	ClusterStateReadOnly    ClusterEventType = "state.ro"
	ClusterStateReadWrite   ClusterEventType = "state.rw"
)

type ClusterPeer

type ClusterPeer struct {
	Id         string              `json:"id,omitempty"`
	Addr       string              `json:"addr,omitempty"`
	Version    string              `json:"version,omitempty"`
	ServerCert []*x509.Certificate `json:"-"`
}

func (*ClusterPeer) String

func (self *ClusterPeer) String() string

type Dispatcher

type Dispatcher interface {
	RegisterEventType(eventType string, registrar TypeRegistrar)
	RegisterEventTypeFunctions(eventType string, registrationHandler RegistrationHandler, unregistrationHandler UnregistrationHandler)

	RegisterEventHandlerFactory(eventHandlerType string, factory HandlerFactory)
	RegisterFormatterFactory(formatterType string, factory FormatterFactory)

	GetFormatterFactory(formatterType string) FormatterFactory

	ProcessSubscriptions(handler interface{}, subscriptions []*Subscription) error
	RemoveAllSubscriptions(handler interface{})

	AddCircuitEventHandler(handler CircuitEventHandler)
	RemoveCircuitEventHandler(handler CircuitEventHandler)

	AddLinkEventHandler(handler LinkEventHandler)
	RemoveLinkEventHandler(handler LinkEventHandler)

	AddMetricsMapper(mapper MetricsMapper)

	AddMetricsEventHandler(handler MetricsEventHandler)
	RemoveMetricsEventHandler(handler MetricsEventHandler)

	AddMetricsMessageHandler(handler MetricsMessageHandler)
	RemoveMetricsMessageHandler(handler MetricsMessageHandler)
	NewFilteredMetricsAdapter(sourceFilter *regexp.Regexp, metricFilter *regexp.Regexp, handler MetricsEventHandler) MetricsMessageHandler

	AddRouterEventHandler(handler RouterEventHandler)
	RemoveRouterEventHandler(handler RouterEventHandler)

	AddServiceEventHandler(handler ServiceEventHandler)
	RemoveServiceEventHandler(handler ServiceEventHandler)

	AddTerminatorEventHandler(handler TerminatorEventHandler)
	RemoveTerminatorEventHandler(handler TerminatorEventHandler)

	AddUsageEventHandler(handler UsageEventHandler)
	RemoveUsageEventHandler(handler UsageEventHandler)

	AddClusterEventHandler(handler ClusterEventHandler)
	RemoveClusterEventHandler(handler ClusterEventHandler)

	AddEntityChangeEventHandler(handler EntityChangeEventHandler)
	RemoveEntityChangeEventHandler(handler EntityChangeEventHandler)
	AddEntityChangeSource(store boltz.Store)
	AddGlobalEntityChangeMetadata(k string, v any)

	CircuitEventHandler
	EntityChangeEventHandler
	LinkEventHandler
	MetricsEventHandler
	MetricsMessageHandler
	RouterEventHandler
	ServiceEventHandler
	TerminatorEventHandler
	UsageEventHandler
	ClusterEventHandler
}

The Dispatcher interface manages handlers for a number of events as well as dispatching events to those handlers

type DispatcherMock

type DispatcherMock struct{}

func (DispatcherMock) AcceptCircuitEvent

func (d DispatcherMock) AcceptCircuitEvent(*CircuitEvent)

func (DispatcherMock) AcceptClusterEvent

func (d DispatcherMock) AcceptClusterEvent(*ClusterEvent)

func (DispatcherMock) AcceptEntityChangeEvent

func (d DispatcherMock) AcceptEntityChangeEvent(event *EntityChangeEvent)

func (DispatcherMock) AcceptLinkEvent

func (d DispatcherMock) AcceptLinkEvent(*LinkEvent)

func (DispatcherMock) AcceptMetricsEvent

func (d DispatcherMock) AcceptMetricsEvent(*MetricsEvent)

func (DispatcherMock) AcceptMetricsMsg

func (d DispatcherMock) AcceptMetricsMsg(*metrics_pb.MetricsMessage)

func (DispatcherMock) AcceptRouterEvent

func (d DispatcherMock) AcceptRouterEvent(*RouterEvent)

func (DispatcherMock) AcceptServiceEvent

func (d DispatcherMock) AcceptServiceEvent(*ServiceEvent)

func (DispatcherMock) AcceptTerminatorEvent

func (d DispatcherMock) AcceptTerminatorEvent(*TerminatorEvent)

func (DispatcherMock) AcceptUsageEvent

func (d DispatcherMock) AcceptUsageEvent(*UsageEvent)

func (DispatcherMock) AddCircuitEventHandler

func (d DispatcherMock) AddCircuitEventHandler(CircuitEventHandler)

func (DispatcherMock) AddClusterEventHandler

func (d DispatcherMock) AddClusterEventHandler(ClusterEventHandler)

func (DispatcherMock) AddEntityChangeEventHandler

func (d DispatcherMock) AddEntityChangeEventHandler(handler EntityChangeEventHandler)

func (DispatcherMock) AddEntityChangeSource

func (d DispatcherMock) AddEntityChangeSource(store boltz.Store)

func (DispatcherMock) AddGlobalEntityChangeMetadata

func (d DispatcherMock) AddGlobalEntityChangeMetadata(k string, v any)

func (DispatcherMock) AddLinkEventHandler

func (d DispatcherMock) AddLinkEventHandler(LinkEventHandler)

func (DispatcherMock) AddMetricsEventHandler

func (d DispatcherMock) AddMetricsEventHandler(MetricsEventHandler)

func (DispatcherMock) AddMetricsMapper

func (d DispatcherMock) AddMetricsMapper(MetricsMapper)

func (DispatcherMock) AddMetricsMessageHandler

func (d DispatcherMock) AddMetricsMessageHandler(MetricsMessageHandler)

func (DispatcherMock) AddRouterEventHandler

func (d DispatcherMock) AddRouterEventHandler(RouterEventHandler)

func (DispatcherMock) AddServiceEventHandler

func (d DispatcherMock) AddServiceEventHandler(ServiceEventHandler)

func (DispatcherMock) AddTerminatorEventHandler

func (d DispatcherMock) AddTerminatorEventHandler(TerminatorEventHandler)

func (DispatcherMock) AddUsageEventHandler

func (d DispatcherMock) AddUsageEventHandler(UsageEventHandler)

func (DispatcherMock) GetFormatterFactory

func (d DispatcherMock) GetFormatterFactory(formatterType string) FormatterFactory

func (DispatcherMock) NewFilteredMetricsAdapter

func (DispatcherMock) ProcessSubscriptions

func (d DispatcherMock) ProcessSubscriptions(interface{}, []*Subscription) error

func (DispatcherMock) RegisterEventHandlerFactory

func (d DispatcherMock) RegisterEventHandlerFactory(string, HandlerFactory)

func (DispatcherMock) RegisterEventType

func (d DispatcherMock) RegisterEventType(string, TypeRegistrar)

func (DispatcherMock) RegisterEventTypeFunctions

func (d DispatcherMock) RegisterEventTypeFunctions(string, RegistrationHandler, UnregistrationHandler)

func (DispatcherMock) RegisterFormatterFactory

func (d DispatcherMock) RegisterFormatterFactory(string, FormatterFactory)

func (DispatcherMock) RemoveAllSubscriptions

func (d DispatcherMock) RemoveAllSubscriptions(interface{})

func (DispatcherMock) RemoveCircuitEventHandler

func (d DispatcherMock) RemoveCircuitEventHandler(CircuitEventHandler)

func (DispatcherMock) RemoveClusterEventHandler

func (d DispatcherMock) RemoveClusterEventHandler(ClusterEventHandler)

func (DispatcherMock) RemoveEntityChangeEventHandler

func (d DispatcherMock) RemoveEntityChangeEventHandler(handler EntityChangeEventHandler)

func (DispatcherMock) RemoveLinkEventHandler

func (d DispatcherMock) RemoveLinkEventHandler(LinkEventHandler)

func (DispatcherMock) RemoveMetricsEventHandler

func (d DispatcherMock) RemoveMetricsEventHandler(MetricsEventHandler)

func (DispatcherMock) RemoveMetricsMessageHandler

func (d DispatcherMock) RemoveMetricsMessageHandler(MetricsMessageHandler)

func (DispatcherMock) RemoveRouterEventHandler

func (d DispatcherMock) RemoveRouterEventHandler(RouterEventHandler)

func (DispatcherMock) RemoveServiceEventHandler

func (d DispatcherMock) RemoveServiceEventHandler(ServiceEventHandler)

func (DispatcherMock) RemoveTerminatorEventHandler

func (d DispatcherMock) RemoveTerminatorEventHandler(TerminatorEventHandler)

func (DispatcherMock) RemoveUsageEventHandler

func (d DispatcherMock) RemoveUsageEventHandler(UsageEventHandler)

type EntityChangeEvent

type EntityChangeEvent struct {
	Namespace          string                `json:"namespace"`
	EventId            string                `json:"eventId"`
	EventType          EntityChangeEventType `json:"eventType"`
	Timestamp          time.Time             `json:"timestamp"`
	Metadata           map[string]any        `json:"metadata,omitempty"`
	EntityType         string                `json:"entityType,omitempty"`
	IsParentEvent      *bool                 `json:"isParentEvent,omitempty"`
	InitialState       any                   `json:"initialState,omitempty"`
	FinalState         any                   `json:"finalState,omitempty"`
	PropagateIndicator bool                  `json:"-"`
	IsRecoveryEvent    bool                  `json:"-"`
}

type EntityChangeEventHandler

type EntityChangeEventHandler interface {
	AcceptEntityChangeEvent(event *EntityChangeEvent)
}

type EntityChangeEventHandlerWrapper

type EntityChangeEventHandlerWrapper interface {
	EntityChangeEventHandler
	IsWrapping(value EntityChangeEventHandler) bool
}

type EntityChangeEventType

type EntityChangeEventType string
const (
	EntityChangeEventsNs = "entityChange"

	EntityChangeTypeEntityCreated EntityChangeEventType = "created"
	EntityChangeTypeEntityUpdated EntityChangeEventType = "updated"
	EntityChangeTypeEntityDeleted EntityChangeEventType = "deleted"
	EntityChangeTypeCommitted     EntityChangeEventType = "committed"
)

type FormattedEventSink

type FormattedEventSink interface {
	AcceptFormattedEvent(eventType string, formattedEvent []byte)
}

A FormattedEventSink accepts formatted events, i.e. events that have been turned into string or binary representations

type FormatterFactory

type FormatterFactory interface {
	NewFormatter(sink FormattedEventSink) io.Closer
}

A FormatterFactory returns a formatter which will send events to the given FormattedEventSink

type FormatterFactoryF

type FormatterFactoryF func(sink FormattedEventSink) io.Closer

FormatterFactoryF is a function version of FormatterFactory

func (FormatterFactoryF) NewFormatter

func (self FormatterFactoryF) NewFormatter(sink FormattedEventSink) io.Closer

type HandlerFactory

type HandlerFactory interface {
	NewEventHandler(config map[interface{}]interface{}) (interface{}, error)
}

A HandlerFactory knows how to create a given event handler type using the provided configuration map

type LinkConnection

type LinkConnection struct {
	Id         string `json:"id"`
	LocalAddr  string `json:"local_addr"`
	RemoteAddr string `json:"remote_addr"`
}

type LinkEvent

type LinkEvent struct {
	Namespace   string            `json:"namespace"`
	EventType   LinkEventType     `json:"event_type"`
	Timestamp   time.Time         `json:"timestamp"`
	LinkId      string            `json:"link_id"`
	SrcRouterId string            `json:"src_router_id"`
	DstRouterId string            `json:"dst_router_id"`
	Protocol    string            `json:"protocol"`
	DialAddress string            `json:"dial_address"`
	Cost        int32             `json:"cost"`
	Connections []*LinkConnection `json:"connections,omitempty"`
}

func (*LinkEvent) String

func (event *LinkEvent) String() string

type LinkEventHandler

type LinkEventHandler interface {
	AcceptLinkEvent(event *LinkEvent)
}

type LinkEventType

type LinkEventType string
const (
	LinkEventsNs = "fabric.links"

	LinkDialed                     LinkEventType = "dialed"
	LinkFault                      LinkEventType = "fault"
	LinkDuplicate                  LinkEventType = "duplicate"
	LinkConnected                  LinkEventType = "connected"
	LinkFromRouterNew              LinkEventType = "routerLinkNew"
	LinkFromRouterKnown            LinkEventType = "routerLinkKnown"
	LinkFromRouterDisconnectedDest LinkEventType = "routerLinkDisconnectedDest"
)

type MetricsEvent

type MetricsEvent struct {
	MetricType     string                 `json:"metric_type" mapstructure:"metric_type"`
	Namespace      string                 `json:"namespace"`
	SourceAppId    string                 `json:"source_id" mapstructure:"source_id"`
	SourceEntityId string                 `json:"source_entity_id,omitempty"  mapstructure:"source_entity_id,omitempty"`
	Version        uint32                 `json:"version"`
	Timestamp      time.Time              `json:"timestamp"`
	Metric         string                 `json:"metric"`
	Metrics        map[string]interface{} `json:"metrics"`
	Tags           map[string]string      `json:"tags,omitempty"`
	SourceEventId  string                 `json:"source_event_id" mapstructure:"source_event_id"`
}

type MetricsEventHandler

type MetricsEventHandler interface {
	AcceptMetricsEvent(event *MetricsEvent)
}

type MetricsEventHandlerF

type MetricsEventHandlerF func(event *MetricsEvent)

func (MetricsEventHandlerF) AcceptMetricsEvent

func (self MetricsEventHandlerF) AcceptMetricsEvent(event *MetricsEvent)

type MetricsEventHandlerWrapper

type MetricsEventHandlerWrapper interface {
	MetricsEventHandler
	IsWrapping(value MetricsEventHandler) bool
}

type MetricsMapper

type MetricsMapper func(msg *metrics_pb.MetricsMessage, event *MetricsEvent)

type MetricsMessageHandler

type MetricsMessageHandler interface {
	// AcceptMetricsMsg is called when new metrics become available
	AcceptMetricsMsg(message *metrics_pb.MetricsMessage)
}

type MetricsMessageHandlerF

type MetricsMessageHandlerF func(msg *metrics_pb.MetricsMessage)

func (MetricsMessageHandlerF) AcceptMetricsMsg

func (self MetricsMessageHandlerF) AcceptMetricsMsg(msg *metrics_pb.MetricsMessage)

type MetricsMessageHandlerWrapper

type MetricsMessageHandlerWrapper interface {
	MetricsMessageHandler
	IsWrapping(value MetricsEventHandler) bool
}

type RegistrationHandler

type RegistrationHandler func(handler interface{}, config map[string]interface{}) error

A RegistrationHandler can take a handler, which may implement multiple event handler interfaces, and configure it using the configuration map provided

type RouterEvent

type RouterEvent struct {
	Namespace    string          `json:"namespace"`
	EventType    RouterEventType `json:"event_type"`
	Timestamp    time.Time       `json:"timestamp"`
	RouterId     string          `json:"router_id"`
	RouterOnline bool            `json:"router_online"`
}

func (*RouterEvent) String

func (event *RouterEvent) String() string

type RouterEventHandler

type RouterEventHandler interface {
	AcceptRouterEvent(event *RouterEvent)
}

type RouterEventType

type RouterEventType string
const (
	RouterEventsNs = "fabric.routers"

	RouterOnline  RouterEventType = "router-online"
	RouterOffline RouterEventType = "router-offline"
)

type ServiceEvent

type ServiceEvent struct {
	Namespace        string `json:"namespace"`
	Version          uint32 `json:"version"`
	EventType        string `json:"event_type"`
	ServiceId        string `json:"service_id"`
	TerminatorId     string `json:"terminator_id"`
	Count            uint64 `json:"count"`
	IntervalStartUTC int64  `json:"interval_start_utc"`
	IntervalLength   uint64 `json:"interval_length"`
}

func (*ServiceEvent) String

func (event *ServiceEvent) String() string

type ServiceEventHandler

type ServiceEventHandler interface {
	AcceptServiceEvent(event *ServiceEvent)
}

type Subscription

type Subscription struct {
	Type    string                 `json:"type"`
	Options map[string]interface{} `json:"options"`
}

A Subscription has information to configure an event handler. It contains the EventType to subscribe to and any optional configuration for the subscription. This might include things like event versions or event filtering

type TerminatorEvent

type TerminatorEvent struct {
	Namespace                 string              `json:"namespace"`
	EventType                 TerminatorEventType `json:"event_type"`
	Timestamp                 time.Time           `json:"timestamp"`
	ServiceId                 string              `json:"service_id"`
	TerminatorId              string              `json:"terminator_id"`
	RouterId                  string              `json:"router_id"`
	HostId                    string              `json:"host_id"`
	RouterOnline              bool                `json:"router_online"`
	Precedence                string              `json:"precedence"`
	StaticCost                uint16              `json:"static_cost"`
	DynamicCost               uint16              `json:"dynamic_cost"`
	TotalTerminators          int                 `json:"total_terminators"`
	UsableDefaultTerminators  int                 `json:"usable_default_terminators"`
	UsableRequiredTerminators int                 `json:"usable_required_terminators"`
	PropagateIndicator        bool                `json:"-"`
}

func (*TerminatorEvent) IsModelEvent

func (event *TerminatorEvent) IsModelEvent() bool

func (*TerminatorEvent) String

func (event *TerminatorEvent) String() string

type TerminatorEventHandler

type TerminatorEventHandler interface {
	AcceptTerminatorEvent(event *TerminatorEvent)
}

type TerminatorEventHandlerWrapper

type TerminatorEventHandlerWrapper interface {
	TerminatorEventHandler
	IsWrapping(value TerminatorEventHandler) bool
}

type TerminatorEventType

type TerminatorEventType string
const (
	TerminatorEventsNs = "fabric.terminators"

	TerminatorCreated       TerminatorEventType = "created"
	TerminatorUpdated       TerminatorEventType = "updated"
	TerminatorDeleted       TerminatorEventType = "deleted"
	TerminatorRouterOnline  TerminatorEventType = "router-online"
	TerminatorRouterOffline TerminatorEventType = "router-offline"
)

type TypeRegistrar

type TypeRegistrar interface {
	// Register takes a handler, which may implement multiple event handler
	// interfaces, and configure it using the configuration map provided
	Register(handler interface{}, config map[string]interface{}) error

	// Unregister will remove give handler, if implements the interface for
	// this event type and is registered to receive events of this type
	Unregister(handler interface{})
}

A TypeRegistrar handles registering and unregistering handlers for a given event type

type UnregistrationHandler

type UnregistrationHandler func(handler interface{})

A UnregistrationHandler will remove give handler, if implements the interface for this event type and is registered to receive events of this type

type UsageEvent

type UsageEvent struct {
	Namespace        string            `json:"namespace"`
	Version          uint32            `json:"version"`
	EventType        string            `json:"event_type"`
	SourceId         string            `json:"source_id"`
	CircuitId        string            `json:"circuit_id"`
	Usage            uint64            `json:"usage"`
	IntervalStartUTC int64             `json:"interval_start_utc"`
	IntervalLength   uint64            `json:"interval_length"`
	Tags             map[string]string `json:"tags"`
}

func (*UsageEvent) String

func (event *UsageEvent) String() string

type UsageEventHandler

type UsageEventHandler interface {
	AcceptUsageEvent(event *UsageEvent)
}

type UsageEventV3

type UsageEventV3 struct {
	Namespace        string            `json:"namespace"`
	Version          uint32            `json:"version"`
	SourceId         string            `json:"source_id"`
	CircuitId        string            `json:"circuit_id"`
	Usage            map[string]uint64 `json:"usage"`
	IntervalStartUTC int64             `json:"interval_start_utc"`
	IntervalLength   uint64            `json:"interval_length"`
	Tags             map[string]string `json:"tags"`
}

func (*UsageEventV3) String

func (event *UsageEventV3) String() string

type UsageEventV3Handler

type UsageEventV3Handler interface {
	AcceptUsageEventV3(event *UsageEventV3)
}

type UsageEventV3HandlerWrapper

type UsageEventV3HandlerWrapper interface {
	UsageEventV3Handler
	IsWrapping(value UsageEventV3Handler) bool
}

Jump to

Keyboard shortcuts

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