event

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBSession

func NewDBSession() (*mgo.Session, error)

NewDBSession returns a mongoDB session

Types

type Event

type Event struct {
	ID           string            `json:"eventId" bson:"_id"`
	Stream       int32             `json:"stream"`
	Time         ZeroableTime      `json:"eventTime"`
	Type         string            `json:"eventType"`
	TypeVersion  string            `json:"eventTypeVersion"`
	CEVersion    string            `json:"cloudEventVersion"`
	Source       string            `json:"eventSource"`
	Subject      string            `json:"eventSubject"`
	Acknowledged ZeroableTime      `json:"eventAcknowledged,omitempty"`
	Metadata     map[string]string `json:"extensions,omitempty"`
	ContentType  string            `json:"contentType,omitempty"`
	Data         []byte            `json:"data,omitempty"`
}

Event is the main event structure for all events throughout the system TODO(tcfw) move to protobuf?

func NewEvent

func NewEvent() *Event

NewEvent fills an event with basic info

func (*Event) SetDataFromString

func (e *Event) SetDataFromString(data string)

SetDataFromString converts a string to bytes and stores in data

func (*Event) SetDataFromStruct

func (e *Event) SetDataFromStruct(jsonStruct interface{}) error

SetDataFromStruct converts a struct to JSON as raw bytes to be stored

func (*Event) SetID

func (e *Event) SetID()

SetID sets a new ID for the event based on UUID

func (*Event) ToProtobuf

func (e *Event) ToProtobuf() *pbEvent.Event

ToProtobuf converts structed event to protobuf event

type ZeroableTime

type ZeroableTime struct {
	time.Time
}

ZeroableTime converts to "null" string for zero times when converting to JSON

func (ZeroableTime) MarshalJSON

func (t ZeroableTime) MarshalJSON() ([]byte, error)

MarshalJSON converts struct to JSON type

Directories

Path Synopsis
Package evntsrc_event is a generated protocol buffer package.
Package evntsrc_event is a generated protocol buffer package.
github.com/tcfw/evntsrc
Package evntsrc is a generated protocol buffer package.
Package evntsrc is a generated protocol buffer package.
github.com/tcfw/evntsrc/internal/event/protos
Package protos is a generated protocol buffer package.
Package protos is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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