sysevents

package
v0.0.0-...-0172641 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//InternalPrefix prefix to all internal channels
	InternalPrefix = "_INTERNAL."

	//InternalChannelPrefix Default channel prefix
	InternalChannelPrefix = "io.evntsrc."
)

Variables

This section is empty.

Functions

func BroadcastEvent

func BroadcastEvent(ctx context.Context, event EventInterface) error

BroadcastEvent attempts to connect to nats server to pub any event and saves to stream

func BroadcastNonStreamingEvent

func BroadcastNonStreamingEvent(ctx context.Context, event EventInterface) error

BroadcastNonStreamingEvent broadcasts an event like BroadcastEvent but uses the non-streaming engine

func ListenForBroadcast

func ListenForBroadcast(serviceName string, eventType string, channel string) (chan []byte, func(), error)

ListenForBroadcast creates a new NATS connection and watches for internal events based on a channel & type using ListenForBroadcastOnNC

func ListenForBroadcastOnNC

func ListenForBroadcastOnNC(nc *nats.Conn, serviceName string, eventType, channel string) (chan []byte, func(), error)

ListenForBroadcastOnNC is the same as ListenForBroadcast but on an existing nats connection

Types

type AuthenticateEvent

type AuthenticateEvent struct {
	*Event
	AuthType string `json:"authType"`
	Success  bool   `json:"success"`
	User     string `json:"user"`
	IP       string `json:"ip"`
	Err      string `json:"error,omitempty"`
}

AuthenticateEvent publishes to events.auth.auth

type Event

type Event struct {
	Channel   string
	Type      string
	CEVersion string
	Source    string
	ID        string
	Time      time.Time
	Metadata  map[string]interface{}
}

Event is the basic structure all events should include

func (*Event) GetChannel

func (e *Event) GetChannel() string

GetChannel returns the event channel

func (*Event) GetMetadata

func (e *Event) GetMetadata() map[string]interface{}

GetMetadata returns the current metadata

func (*Event) GetType

func (e *Event) GetType() string

GetType returns event type

func (*Event) SetChannel

func (e *Event) SetChannel(channel string)

SetChannel overwrites the event channel

func (*Event) SetID

func (e *Event) SetID()

SetID generates a new UUID for the event id

func (*Event) SetMetadata

func (e *Event) SetMetadata(md map[string]interface{})

SetMetadata overrides the existing metadata string map

func (*Event) SetSource

func (e *Event) SetSource(source string)

SetSource applies source

func (*Event) SetTime

func (e *Event) SetTime(eventTime time.Time)

SetTime sets event time from timestamp

type EventInterface

type EventInterface interface {
	GetType() string
	SetSource(string)
	SetTime(time.Time)
	SetID()
	SetMetadata(map[string]interface{})
	GetMetadata() map[string]interface{}
	GetChannel() string
	SetChannel(string)
}

EventInterface provides required funcs to identify common structured events

Jump to

Keyboard shortcuts

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