types

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InterruptTimeout = 200 * time.Millisecond

InterruptTimeout timeout for interrupt signal when exiting a Cmd

View Source
var KillTimeout = 1000 * time.Millisecond

KillTimeout timeout for kill signal when exiting a Cmd

Functions

This section is empty.

Types

type AbstractPublisher

type AbstractPublisher interface {
	Init(config map[string]any, Indices []*Index)
	Terminate()

	InternalInit(name string)
	InternalTerminate()
	Insert(rows []*InsertsRow)
	Update(rows []*UpdateRow)
	Delete(rows []*DeleteRow)
}

type AbstractSubscriber

type AbstractSubscriber interface {
	Init(config map[string]any)

	PrepareListen(indices []*Index)
	Listen()
	Terminate()

	InternalInit(eventChannel *chan *interface{}, name string)
	InternalTerminate()
	DispatchEvent(event *interface{})

	GetAllRecordsForIndex(index *Index) <-chan Record
	GetFullRecordsForIndex(references []string, index *Index) <-chan Record
	GetFullRecordsForRelationUpdate(results RelationsUpdate, index *Index) <-chan Record
}

type Cmd

type Cmd struct {
	*exec.Cmd

	// Prefix prepended to outputs if provided
	OutputPrefix string
	// ShowOutput prints output to log
	ShowOutput bool
	// DropEmptyLines stops empty lines being received
	DropEmptyLines bool

	// InputChan is the channel attached to the command stdin
	InputChan chan string
	// OutputChan is the channel attached to the command stdout
	OutputChan chan string
}

Cmd wraps an exec/Cmd and provides a pipe based interface

func Command

func Command(name string, arg ...string) *Cmd

Command Creates a command

func (*Cmd) Exit

func (cmd *Cmd) Exit() error

Exit a running command This attempts a wait, with timeout based interrupt and kill signals

func (*Cmd) Interrupt

func (cmd *Cmd) Interrupt()

Interrupt sends an os.Interrupt to the process if running

func (*Cmd) Start

func (cmd *Cmd) Start() error

Start wraps Cmd.Start and hooks channels if provided

type DeleteEvent

type DeleteEvent struct {
	Index     string
	Reference string
}

type DeleteRow

type DeleteRow struct {
	Index     string
	Reference string
}

type Fields

type Fields struct {
	Simple   []*SimpleField
	Scripted []*ScriptedField
}

func (*Fields) Len

func (fields *Fields) Len() int

func (*Fields) Parse

func (fields *Fields) Parse(config any) error

type ForeignKey

type ForeignKey struct {
	Local        string
	Parent       string
	PivotLocal   string `json:"pivot_local"`
	PivotTable   string `json:"pivot_table"`
	PivotFields  Fields
	PivotRelated string `json:"pivot_related"`
}

type Index

type Index struct {
	Name      string
	Table     string
	Fields    Fields
	Relations Relations
	Wheres    Wheres

	ReferenceField string
	Settings       map[string]any
	Mappings       map[string]any

	Plugins    Plugins
	Subscriber *AbstractSubscriber
	Publishers []*AbstractPublisher
	ChunkSize  int

	WaitingEvents *WaitingEvents

	Logger *zerolog.Logger
	Active bool
}

func (*Index) AddPublisher

func (index *Index) AddPublisher(publisher *AbstractPublisher)

func (*Index) GetAllMapping

func (index *Index) GetAllMapping() map[string]any

func (*Index) GetAllRelations

func (index *Index) GetAllRelations() Relations

func (*Index) GetAllRelationsAsView

func (index *Index) GetAllRelationsAsView() Relations

func (*Index) IndexAllDocuments

func (index *Index) IndexAllDocuments()

func (*Index) Init

func (index *Index) Init(config map[string]interface{})

func (*Index) Parse

func (index *Index) Parse(config map[string]interface{}) error

func (*Index) SetSubscriber

func (index *Index) SetSubscriber(subscriber *AbstractSubscriber)

func (*Index) Terminate

func (index *Index) Terminate()

type InsertEvent

type InsertEvent struct {
	Index     string
	Reference string
}

type InsertsRow

type InsertsRow struct {
	Index     string
	Reference string
	Record    map[string]interface{}
}

type Plugin

type Plugin struct {
	sync.Mutex
	Name string
	Args []string
	// contains filtered or unexported fields
}

func (*Plugin) Apply

func (plugin *Plugin) Apply(record *Record) error

func (*Plugin) Init

func (plugin *Plugin) Init() error

func (*Plugin) Terminate

func (plugin *Plugin) Terminate() error

type Plugins

type Plugins []*Plugin

func (*Plugins) Apply

func (plugins *Plugins) Apply(record *Record) error

func (*Plugins) Parse

func (plugins *Plugins) Parse(config any) error

type Record

type Record struct {
	Reference string
	Data      map[string]interface{}
}

type Relation

type Relation struct {
	Table string
	Name  string

	Type       string // 'one_to_one', 'one_to_many', 'many_to_many'
	SoftDelete bool
	Fields     Fields

	Wheres    Wheres
	Relations Relations
	Mappings  map[string]any

	Parent    *Relation
	UniqueKey string

	ForeignKey ForeignKey
	UniqueName string

	UsingView   bool
	ViewName    string
	ViewCreated bool
}

func (*Relation) GetAllRelations

func (relation *Relation) GetAllRelations() Relations

func (*Relation) GetFullName

func (relation *Relation) GetFullName() string

func (*Relation) GetMapping

func (relation *Relation) GetMapping() map[string]any

func (*Relation) Parse

func (relation *Relation) Parse(config any, parent *Relation) error

type RelationUpdateEvent

type RelationUpdateEvent struct {
	Index     string
	Relation  string
	Reference string
	Pivot     bool
}

type Relations

type Relations map[string]*Relation

func (*Relations) Parse

func (relations *Relations) Parse(config any, parent *Relation) error

type RelationsUpdate

type RelationsUpdate map[*Relation][]*RelationUpdateEvent

type ScriptedField

type ScriptedField struct {
	Alias  string
	Script string
}

type SimpleField

type SimpleField struct {
	Alias string
	Field string
}

type UpdateEvent

type UpdateEvent struct {
	Index                 string
	Reference             string
	OldReference          string
	SoftDeleted           bool
	PreviouslySoftDeleted bool
}

type UpdateRow

type UpdateRow struct {
	Index     string
	Reference string
	Record    map[string]interface{}
}

type Where

type Where struct {
	Column    string `json:"column"`
	Condition string `json:"condition"`
}

type Wheres

type Wheres []*Where

func (*Wheres) Parse

func (wheres *Wheres) Parse(config any) error

Jump to

Keyboard shortcuts

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