event

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

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 added in v0.19.28

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"`
}

func (*CircuitEvent) String added in v0.19.28

func (event *CircuitEvent) String() string

type CircuitEventHandler added in v0.19.28

type CircuitEventHandler interface {
	AcceptCircuitEvent(event *CircuitEvent)
}

type CircuitEventType added in v0.19.28

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

type CircuitPath added in v0.19.28

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

func (*CircuitPath) String added in v0.19.28

func (self *CircuitPath) 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{})

	Dispatch(event Event)

	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)

	CircuitEventHandler
	LinkEventHandler
	MetricsEventHandler
	MetricsMessageHandler
	RouterEventHandler
	ServiceEventHandler
	TerminatorEventHandler
	UsageEventHandler
}

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

type DispatcherMock added in v0.19.28

type DispatcherMock struct{}

func (DispatcherMock) AcceptCircuitEvent added in v0.19.28

func (d DispatcherMock) AcceptCircuitEvent(*CircuitEvent)

func (DispatcherMock) AcceptLinkEvent added in v0.19.28

func (d DispatcherMock) AcceptLinkEvent(*LinkEvent)

func (DispatcherMock) AcceptMetricsEvent added in v0.19.28

func (d DispatcherMock) AcceptMetricsEvent(*MetricsEvent)

func (DispatcherMock) AcceptMetricsMsg added in v0.19.28

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

func (DispatcherMock) AcceptRouterEvent added in v0.19.28

func (d DispatcherMock) AcceptRouterEvent(*RouterEvent)

func (DispatcherMock) AcceptServiceEvent added in v0.19.28

func (d DispatcherMock) AcceptServiceEvent(*ServiceEvent)

func (DispatcherMock) AcceptTerminatorEvent added in v0.19.28

func (d DispatcherMock) AcceptTerminatorEvent(*TerminatorEvent)

func (DispatcherMock) AcceptUsageEvent added in v0.19.28

func (d DispatcherMock) AcceptUsageEvent(*UsageEvent)

func (DispatcherMock) AddCircuitEventHandler added in v0.19.28

func (d DispatcherMock) AddCircuitEventHandler(CircuitEventHandler)

func (DispatcherMock) AddLinkEventHandler added in v0.19.28

func (d DispatcherMock) AddLinkEventHandler(LinkEventHandler)

func (DispatcherMock) AddMetricsEventHandler added in v0.19.28

func (d DispatcherMock) AddMetricsEventHandler(MetricsEventHandler)

func (DispatcherMock) AddMetricsMapper added in v0.19.28

func (d DispatcherMock) AddMetricsMapper(MetricsMapper)

func (DispatcherMock) AddMetricsMessageHandler added in v0.19.28

func (d DispatcherMock) AddMetricsMessageHandler(MetricsMessageHandler)

func (DispatcherMock) AddRouterEventHandler added in v0.19.28

func (d DispatcherMock) AddRouterEventHandler(RouterEventHandler)

func (DispatcherMock) AddServiceEventHandler added in v0.19.28

func (d DispatcherMock) AddServiceEventHandler(ServiceEventHandler)

func (DispatcherMock) AddTerminatorEventHandler added in v0.19.28

func (d DispatcherMock) AddTerminatorEventHandler(TerminatorEventHandler)

func (DispatcherMock) AddUsageEventHandler added in v0.19.28

func (d DispatcherMock) AddUsageEventHandler(UsageEventHandler)

func (DispatcherMock) Dispatch added in v0.19.28

func (d DispatcherMock) Dispatch(Event)

func (DispatcherMock) GetFormatterFactory added in v0.22.0

func (d DispatcherMock) GetFormatterFactory(formatterType string) FormatterFactory

func (DispatcherMock) NewFilteredMetricsAdapter added in v0.19.28

func (DispatcherMock) ProcessSubscriptions added in v0.22.0

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

func (DispatcherMock) RegisterEventHandlerFactory added in v0.19.28

func (d DispatcherMock) RegisterEventHandlerFactory(string, HandlerFactory)

func (DispatcherMock) RegisterEventType added in v0.19.28

func (d DispatcherMock) RegisterEventType(string, TypeRegistrar)

func (DispatcherMock) RegisterEventTypeFunctions added in v0.22.0

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

func (DispatcherMock) RegisterFormatterFactory added in v0.22.0

func (d DispatcherMock) RegisterFormatterFactory(string, FormatterFactory)

func (DispatcherMock) RemoveAllSubscriptions added in v0.22.0

func (d DispatcherMock) RemoveAllSubscriptions(interface{})

func (DispatcherMock) RemoveCircuitEventHandler added in v0.19.28

func (d DispatcherMock) RemoveCircuitEventHandler(CircuitEventHandler)

func (DispatcherMock) RemoveLinkEventHandler added in v0.19.28

func (d DispatcherMock) RemoveLinkEventHandler(LinkEventHandler)

func (DispatcherMock) RemoveMetricsEventHandler added in v0.19.28

func (d DispatcherMock) RemoveMetricsEventHandler(MetricsEventHandler)

func (DispatcherMock) RemoveMetricsMessageHandler added in v0.19.28

func (d DispatcherMock) RemoveMetricsMessageHandler(MetricsMessageHandler)

func (DispatcherMock) RemoveRouterEventHandler added in v0.19.28

func (d DispatcherMock) RemoveRouterEventHandler(RouterEventHandler)

func (DispatcherMock) RemoveServiceEventHandler added in v0.19.28

func (d DispatcherMock) RemoveServiceEventHandler(ServiceEventHandler)

func (DispatcherMock) RemoveTerminatorEventHandler added in v0.19.28

func (d DispatcherMock) RemoveTerminatorEventHandler(TerminatorEventHandler)

func (DispatcherMock) RemoveUsageEventHandler added in v0.19.28

func (d DispatcherMock) RemoveUsageEventHandler(UsageEventHandler)

type Event

type Event interface {
	Handle()
}

type FormattedEventSink added in v0.22.0

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 added in v0.22.0

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

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

type FormatterFactoryF added in v0.22.0

type FormatterFactoryF func(sink FormattedEventSink) io.Closer

FormatterFactoryF is a function version of FormatterFactory

func (FormatterFactoryF) NewFormatter added in v0.22.0

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

type HandlerFactory added in v0.19.28

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 added in v0.19.28

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

type LinkEvent added in v0.19.28

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 added in v0.19.28

func (event *LinkEvent) String() string

type LinkEventHandler added in v0.19.28

type LinkEventHandler interface {
	AcceptLinkEvent(event *LinkEvent)
}

type LinkEventType added in v0.19.28

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

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

type MetricsEvent added in v0.19.28

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 added in v0.19.28

type MetricsEventHandler interface {
	AcceptMetricsEvent(event *MetricsEvent)
}

type MetricsEventHandlerF added in v0.19.28

type MetricsEventHandlerF func(event *MetricsEvent)

func (MetricsEventHandlerF) AcceptMetricsEvent added in v0.19.28

func (self MetricsEventHandlerF) AcceptMetricsEvent(event *MetricsEvent)

type MetricsMapper added in v0.19.28

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

type MetricsMessageHandler added in v0.19.28

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

type MetricsMessageHandlerF added in v0.19.28

type MetricsMessageHandlerF func(msg *metrics_pb.MetricsMessage)

func (MetricsMessageHandlerF) AcceptMetricsMsg added in v0.19.28

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

type RegistrationHandler added in v0.19.28

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 added in v0.19.28

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 added in v0.19.28

func (event *RouterEvent) String() string

type RouterEventHandler added in v0.19.28

type RouterEventHandler interface {
	AcceptRouterEvent(event *RouterEvent)
}

type RouterEventType added in v0.19.28

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

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

type ServiceEvent added in v0.19.28

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 added in v0.19.28

func (event *ServiceEvent) String() string

type ServiceEventHandler added in v0.19.28

type ServiceEventHandler interface {
	AcceptServiceEvent(event *ServiceEvent)
}

type Subscription added in v0.22.0

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 added in v0.19.28

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"`
}

func (*TerminatorEvent) String added in v0.19.28

func (event *TerminatorEvent) String() string

type TerminatorEventHandler added in v0.19.28

type TerminatorEventHandler interface {
	AcceptTerminatorEvent(event *TerminatorEvent)
}

type TerminatorEventType added in v0.19.28

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 added in v0.22.0

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 added in v0.22.0

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 added in v0.19.28

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 added in v0.19.28

func (event *UsageEvent) String() string

type UsageEventHandler added in v0.19.28

type UsageEventHandler interface {
	AcceptUsageEvent(event *UsageEvent)
}

type UsageEventV3 added in v0.20.0

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 added in v0.20.0

func (event *UsageEventV3) String() string

type UsageEventV3Handler added in v0.20.0

type UsageEventV3Handler interface {
	AcceptUsageEventV3(event *UsageEventV3)
}

Jump to

Keyboard shortcuts

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