events

package
v0.0.0-...-0bdedc6 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

func Publish

func Publish(e Event, attempts int) error

func Run

func Run(brokersStr, topic string, pub, sub chan Message)

func Subscribe

func Subscribe(t string, channel chan<- RawEvent)

Types

type EndpointCreated

type EndpointCreated struct {
	Ts      time.Time
	Payload *m.EndpointDTO
}

func (*EndpointCreated) Body

func (a *EndpointCreated) Body() ([]byte, error)

func (*EndpointCreated) Id

func (a *EndpointCreated) Id() string

func (*EndpointCreated) Timestamp

func (a *EndpointCreated) Timestamp() time.Time

func (*EndpointCreated) Type

func (a *EndpointCreated) Type() string

type EndpointDeleted

type EndpointDeleted struct {
	Ts      time.Time
	Payload *m.EndpointDTO
}

func (*EndpointDeleted) Body

func (a *EndpointDeleted) Body() ([]byte, error)

func (*EndpointDeleted) Id

func (a *EndpointDeleted) Id() string

func (*EndpointDeleted) Timestamp

func (a *EndpointDeleted) Timestamp() time.Time

func (*EndpointDeleted) Type

func (a *EndpointDeleted) Type() string

type EndpointUpdated

type EndpointUpdated struct {
	Ts      time.Time
	Payload struct {
		Last    *m.EndpointDTO `json:"last"`
		Current *m.EndpointDTO `json:"current"`
	}
}

func (*EndpointUpdated) Body

func (a *EndpointUpdated) Body() ([]byte, error)

func (*EndpointUpdated) Id

func (a *EndpointUpdated) Id() string

func (*EndpointUpdated) Timestamp

func (a *EndpointUpdated) Timestamp() time.Time

func (*EndpointUpdated) Type

func (a *EndpointUpdated) Type() string

type Event

type Event interface {
	Type() string
	Timestamp() time.Time
	Body() ([]byte, error)
	Id() string
}

type Handlers

type Handlers struct {
	sync.Mutex
	Listeners map[string][]chan<- RawEvent
}

func (*Handlers) Add

func (h *Handlers) Add(key string, ch chan<- RawEvent)

func (*Handlers) GetListeners

func (h *Handlers) GetListeners(key string) []chan<- RawEvent

type KafkaPubSub

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

type Message

type Message struct {
	Id      string
	Payload []byte
}

message is the application type for a message. This can contain identity, or a reference to the recevier chan for further demuxing.

type ProbeCreated

type ProbeCreated struct {
	Ts      time.Time
	Payload *m.ProbeDTO
}

func (*ProbeCreated) Body

func (a *ProbeCreated) Body() ([]byte, error)

func (*ProbeCreated) Id

func (a *ProbeCreated) Id() string

func (*ProbeCreated) Timestamp

func (a *ProbeCreated) Timestamp() time.Time

func (*ProbeCreated) Type

func (a *ProbeCreated) Type() string

type ProbeDeleted

type ProbeDeleted struct {
	Ts      time.Time
	Payload *m.ProbeDTO
}

func (*ProbeDeleted) Body

func (a *ProbeDeleted) Body() ([]byte, error)

func (*ProbeDeleted) Id

func (a *ProbeDeleted) Id() string

func (*ProbeDeleted) Timestamp

func (a *ProbeDeleted) Timestamp() time.Time

func (*ProbeDeleted) Type

func (a *ProbeDeleted) Type() string

type ProbeOffline

type ProbeOffline struct {
	Ts      time.Time
	Payload *m.ProbeDTO
}

func (*ProbeOffline) Body

func (a *ProbeOffline) Body() ([]byte, error)

func (*ProbeOffline) Id

func (a *ProbeOffline) Id() string

func (*ProbeOffline) Timestamp

func (a *ProbeOffline) Timestamp() time.Time

func (*ProbeOffline) Type

func (a *ProbeOffline) Type() string

type ProbeOnline

type ProbeOnline struct {
	Ts      time.Time
	Payload *m.ProbeDTO
}

func (*ProbeOnline) Body

func (a *ProbeOnline) Body() ([]byte, error)

func (*ProbeOnline) Id

func (a *ProbeOnline) Id() string

func (*ProbeOnline) Timestamp

func (a *ProbeOnline) Timestamp() time.Time

func (*ProbeOnline) Type

func (a *ProbeOnline) Type() string

type ProbeSessionCreated

type ProbeSessionCreated struct {
	Ts      time.Time
	Payload *m.ProbeSession
}

func (*ProbeSessionCreated) Body

func (a *ProbeSessionCreated) Body() ([]byte, error)

func (*ProbeSessionCreated) Id

func (a *ProbeSessionCreated) Id() string

func (*ProbeSessionCreated) Timestamp

func (a *ProbeSessionCreated) Timestamp() time.Time

func (*ProbeSessionCreated) Type

func (a *ProbeSessionCreated) Type() string

type ProbeSessionDeleted

type ProbeSessionDeleted struct {
	Ts      time.Time
	Payload *m.ProbeSession
}

func (*ProbeSessionDeleted) Body

func (a *ProbeSessionDeleted) Body() ([]byte, error)

func (*ProbeSessionDeleted) Id

func (a *ProbeSessionDeleted) Id() string

func (*ProbeSessionDeleted) Timestamp

func (a *ProbeSessionDeleted) Timestamp() time.Time

func (*ProbeSessionDeleted) Type

func (a *ProbeSessionDeleted) Type() string

type ProbeUpdated

type ProbeUpdated struct {
	Ts      time.Time
	Payload struct {
		Last    *m.ProbeDTO `json:"last"`
		Current *m.ProbeDTO `json:"current"`
	}
}

func (*ProbeUpdated) Body

func (a *ProbeUpdated) Body() ([]byte, error)

func (*ProbeUpdated) Id

func (a *ProbeUpdated) Id() string

func (*ProbeUpdated) Timestamp

func (a *ProbeUpdated) Timestamp() time.Time

func (*ProbeUpdated) Type

func (a *ProbeUpdated) Type() string

type RawEvent

type RawEvent struct {
	Id        string          `json:"id"`
	Type      string          `json:"type"`
	Timestamp time.Time       `json:"timestamp"`
	Body      json.RawMessage `json:"payload"`
	Source    string          `json:"source"`
	Attempts  int             `json:"attempts"`
}

func NewRawEventFromEvent

func NewRawEventFromEvent(e Event) (*RawEvent, error)

Jump to

Keyboard shortcuts

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