monitor

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseEvent

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

BaseEvent is a base struct for creating an Event

func NewBaseEvent

func NewBaseEvent(ctx context.Context, eventType EventType, entities map[string]Entity) BaseEvent

NewBaseEvent creates a new BaseEvent

func (BaseEvent) Context

func (e BaseEvent) Context() context.Context

Context - return event calling context

func (BaseEvent) Entities

func (e BaseEvent) Entities() map[string]Entity

Entities returns BaseEvent entities

func (BaseEvent) EventType

func (e BaseEvent) EventType() EventType

EventType returns BaseEvent eventType

type Client

type Client interface {
	ErrorChannel() <-chan error
	EventChannel() <-chan Event

	Context() context.Context
	Close()
}

Client is an unified interface for GRPC monitoring API client

func NewClient

func NewClient(cc *grpc.ClientConn, eventFactory EventFactory, streamConstructor EventStreamConstructor) (Client, error)

NewClient creates a new Client on given GRPC connection with given EventFactory and EventStreamConstructor

type Entity

type Entity interface {
	GetId() string
}

Entity is an interface for event entities

type Event

type Event interface {
	EventType() EventType
	Entities() map[string]Entity

	Message() (interface{}, error)

	// A caller context to use with opentracing.
	Context() context.Context
}

Event is an unified interface for GRPC monitoring API event

type EventFactory

type EventFactory interface {
	NewEvent(ctx context.Context, eventType EventType, entities map[string]Entity) Event
	EventFromMessage(ctx context.Context, message interface{}) (Event, error)
	FactoryName() string
}

EventFactory is an interface for Event factory

type EventStream

type EventStream interface {
	Recv() (interface{}, error)
	Context() context.Context
}

EventStream is an unified interface for blocking receiver

type EventStreamConstructor

type EventStreamConstructor func(ctx context.Context, cc *grpc.ClientConn) (EventStream, error)

EventStreamConstructor is a type for EventStream constructor

type EventType

type EventType string

EventType is an enum for event types

const (
	// EventTypeInitialStateTransfer is a type of the event sent to recipient when it starts monitoring
	EventTypeInitialStateTransfer EventType = "INITIAL_STATE_TRANSFER"
	// EventTypeUpdate is a type of the event sent on entity update
	EventTypeUpdate EventType = "UPDATE"
	// EventTypeDelete is a type of the event sent on entity delete
	EventTypeDelete EventType = "DELETE"
)

type Recipient

type Recipient interface {
	SendMsg(msg interface{}) error
}

Recipient is an unified interface for receiving stream

type Server

type Server interface {
	Update(ctx context.Context, entity Entity)
	Delete(ctx context.Context, entity Entity)

	AddRecipient(recipient Recipient)
	DeleteRecipient(recipient Recipient)
	MonitorEntities(stream grpc.ServerStream)
	SendAll(event Event)
	Serve()
	Entities() map[string]Entity
}

Server is an unified interface for GRPC monitoring API server

func NewServer

func NewServer(eventFactory EventFactory) Server

NewServer creates a new Server with given EventFactory

Directories

Path Synopsis
Package connectionmonitor - implementation of connection monotor client and server
Package connectionmonitor - implementation of connection monotor client and server

Jump to

Keyboard shortcuts

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