events

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: MIT Imports: 12 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, 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)

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

func (*EventChange) OldValueAs added in v0.1.11

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

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

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"`
	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