events

package
v0.4.24 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 3 Imported by: 18

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 added in v0.1.11

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

NewValueAs ...

func (*EventChange) OldValueAs added in v0.1.11

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

OldValueAs ...

func (*EventChange) SetNewValue added in v0.1.11

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

func (*EventChange) SetOldValue added in v0.1.11

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