events

package
v0.0.0-...-e65fa06 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

func ToJSON

func ToJSON(e *Event) ([]byte, error)

Types

type DatabaseEvent

type DatabaseEvent struct {
	CreatedAt     time.Time
	UpdatedAt     time.Time
	DeletedAt     gorm.DeletedAt `gorm:"index"`
	EventID       string
	CorrelationID string       `gorm:"index"`
	Timestamp     time.Time    `gorm:"index"`
	SourceName    string       `gorm:"index"`
	SourceID      string       `gorm:"index"`
	TypeName      string       `gorm:"index"`
	Data          pgtype.JSONB `gorm:"type:jsonb"`
	IsHandled     bool         `gorm:"index"`
	HandledByName string       `gorm:"index"`
	HandledByID   string       `gorm:"index"`
}

func GetAll

func GetAll(db *gorm.DB) ([]*DatabaseEvent, error)

func (*DatabaseEvent) Create

func (d *DatabaseEvent) Create(givenDB *gorm.DB) (*gorm.DB, error)

func (*DatabaseEvent) Delete

func (d *DatabaseEvent) Delete(givenDB *gorm.DB) (*gorm.DB, error)

func (*DatabaseEvent) TableName

func (d *DatabaseEvent) TableName() string

func (*DatabaseEvent) Update

func (d *DatabaseEvent) Update(givenDB *gorm.DB) (*gorm.DB, error)

type Event

type Event struct {
	EventID       ksuid.KSUID     `json:"event_id"`
	CorrelationID ksuid.KSUID     `json:"correlation_id"`
	Timestamp     time.Time       `json:"timestamp"`
	SourceName    string          `json:"source_name"`
	SourceID      ksuid.KSUID     `json:"source_uuid"`
	TypeName      string          `json:"type_name"`
	Data          json.RawMessage `json:"data"`
}

func FromJSON

func FromJSON(data []byte) (*Event, error)

func NewWithCorrelation

func NewWithCorrelation(correlationID ksuid.KSUID, typeName string, data json.RawMessage) *Event

func NewWithoutCorrelation

func NewWithoutCorrelation(typeName string, data json.RawMessage) *Event

func (*Event) FromJSON

func (e *Event) FromJSON(data []byte) error

func (*Event) SetSource

func (e *Event) SetSource(name string, id ksuid.KSUID)

func (*Event) String

func (e *Event) String() string

func (*Event) ToConsumedDatabaseEvent

func (e *Event) ToConsumedDatabaseEvent() (*DatabaseEvent, error)

func (*Event) ToDatabaseEvent

func (e *Event) ToDatabaseEvent() (*DatabaseEvent, error)

func (*Event) ToJSON

func (e *Event) ToJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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