events

package
v0.0.0-...-04cb942 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// EventTypeCreated ...
	EventTypeCreated = "CREATED"
	// EventTypeUpdated ...
	EventTypeUpdated = "UPDATED"
	// EventTypeDeleted ...
	EventTypeDeleted = "DELETED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	EventMetadata
	ID        string                    `json:"id"`
	Changes   []*EventChange            `json:"changes"`
	OldValues map[string]EventDataValue `json:"oldValues"`
	NewValues map[string]EventDataValue `json:"newValues"`
}

Event ...

func NewEvent

func NewEvent(meta EventMetadata) Event

NewEvent ...

func (*Event) AddNewValue

func (e *Event) AddNewValue(column string, v EventDataValue)

AddNewValue ...

func (*Event) AddOldValue

func (e *Event) AddOldValue(column string, v EventDataValue)

AddOldValue ...

func (*Event) Change

func (e *Event) Change(column string) (ec *EventChange)

Change ...

func (Event) ChangedColumns

func (e Event) ChangedColumns() []string

ChangedColumns returns list of names of changed columns

func (Event) HasChangedColumn

func (e Event) HasChangedColumn(c string) bool

HasChangedColumn check if given event has changes on specific column

type EventChange

type EventChange struct {
	Name     string `json:"name"`
	OldValue string `json:"oldValue"`
	NewValue string `json:"newValue"`
}

EventChange ...

func (*EventChange) NewValueAs

func (ec *EventChange) NewValueAs(data interface{}) error

NewValueAs ...

func (*EventChange) OldValueAs

func (ec *EventChange) OldValueAs(data interface{}) error

OldValueAs ...

func (*EventChange) SetNewValue

func (ec *EventChange) SetNewValue(value interface{}) error

SetNewValue ...

func (*EventChange) SetOldValue

func (ec *EventChange) SetOldValue(value interface{}) error

SetOldValue ...

type EventDataValue

type EventDataValue interface{}

EventDataValue ...

type EventMetadata

type EventMetadata struct {
	Type        EventType `json:"type"`
	Entity      string    `json:"entity"`
	EntityID    string    `json:"entityId"`
	Date        time.Time `json:"date"`
	PrincipalID *string   `json:"principalId"`
}

EventMetadata ...

type EventType

type EventType string

EventType ...

Jump to

Keyboard shortcuts

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