eventdb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	FindByCode(event.Code) (EventDef, bool)
}

Database defines interface for event databases

func New

func New(defs []EventDef) Database

New returns a in memory Database.

type EventDef

type EventDef struct {
	Code        event.Code `json:"code"`
	Type        event.Type `json:"type"`
	Codename    string     `json:"codename"`
	Tags        []string   `json:"tags,omitempty"`
	Description string     `json:"description,omitempty"`
	Fields      []FieldDef `json:"fields,omitempty"`
	RaisedBy    []string   `json:"raised_by,omitempty"`
}

EventDef defines events.

func EventDefsFromFile

func EventDefsFromFile(path string) ([]EventDef, error)

EventDefsFromFile returns event definitions from files.

func (*EventDef) Complete

func (def *EventDef) Complete(e event.Event) event.Event

Complete event information from definition.

func (*EventDef) ValidateData

func (def *EventDef) ValidateData(e event.Event) error

ValidateData checks if event data is ok.

type FieldDef

type FieldDef struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Required bool   `json:"required"`
}

FieldDef stores field definitions.

Jump to

Keyboard shortcuts

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