events

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 8 Imported by: 27

Documentation

Index

Constants

View Source
const (
	// EventTypeCreated ...
	EventTypeCreated = "CREATED"
	// EventTypeUpdated ...
	EventTypeUpdated = "UPDATED"
	// EventTypeDeleted ...
	EventTypeDeleted = "DELETED"
)
View Source
const (
	ORMChangeEvent = "com.graphql.orm.change"
)

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, value interface{})

AddNewValue ...

func (*Event) AddOldValue

func (e *Event) AddOldValue(column string, value interface{})

AddOldValue ...

func (*Event) Change

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

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

func (Event) NewValue

func (e Event) NewValue(c string) (*EventDataValue, bool)

NewValue returns new value for column

func (Event) OldValue

func (e Event) OldValue(c string) (*EventDataValue, bool)

OldValue returns old value for column

type EventChange

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

EventChange ...

type EventController

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

func NewEventController

func NewEventController() (ec EventController, err error)

func (*EventController) SendEvent

func (c *EventController) SendEvent(ctx context.Context, e *Event) (err error)

SendEvent ...

type EventDataValue

type EventDataValue interface{}

type EventMetadata

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

type EventType

type EventType string

EventType ...

Jump to

Keyboard shortcuts

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