trigger

package
v4.1.23 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package trigger provides interface for trigger plugins. A trigger plugin has to implement the following function. - NewTrigger(config map[string]interface{}) (Trigger, error)

The trigger instance returned by this function will be called on Fire() with the filePath (relative to root directory) and indexes that have been written (appended or updated). It is guaranteed that the new content has been written on disk when Fire() is called, so it is safe to read it from disk. Keep in mind that the trigger might be called on the startup, due to the WAL recovery.

Triggers can be configured in the marketstore config file.

triggers:
  - module: xxxTrigger.so
    on: "*/1Min/OHLCV"
    config: <according to the plugin>

The "on" value is matched with the file path to decide whether the trigger is fired or not. It can contain wildcard character "*". As of now, trigger fires only on the running state. Trigger on WAL replay may be added later.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordsToColumnSeries

func RecordsToColumnSeries(
	tbk io.TimeBucketKey,
	ds []io.DataShape,
	tf time.Duration,
	year int16,
	records []Record,
) (*io.ColumnSeries, error)

RecordsToColumnSeries takes a slice of Record, along with the required information for constructing a ColumnSeries, and builds it from the slice of Record.

Types

type Matcher added in v4.1.14

type Matcher struct {
	Trigger Trigger
	// On is a string representing the condition of the trigger
	// fire event.  It is the prefix of file path such as
	// ""*/1Min/OHLC"
	On string
}

Matcher checks if the trigger should be fired or not.

func NewMatcher

func NewMatcher(trigger Trigger, on string) *Matcher

NewMatcher creates a new Matcher.

func NewTriggerMatcher added in v4.1.2

func NewTriggerMatcher(ts *utils.TriggerSetting) *Matcher

func NewTriggerMatchers added in v4.1.2

func NewTriggerMatchers(triggers []*utils.TriggerSetting) []*Matcher

func (*Matcher) Match added in v4.1.14

func (tm *Matcher) Match(keyPath string) bool

Match returns true if keyPath matches the On condition.

type Record

type Record []byte

Record represents a serialized byte buffer for a record written to the DB.

func (*Record) Bytes

func (r *Record) Bytes() []byte

Bytes returns the raw record buffer.

func (*Record) Index

func (r *Record) Index() int64

Index returns the index of the record.

func (*Record) Payload

func (r *Record) Payload() []byte

Payload returns the data payload of the record, excluding the index.

type SymbolLoader

type SymbolLoader interface {
	LoadSymbol(symbolName string) (interface{}, error)
}

SymbolLoader is an interface to retrieve symbol object from plugin.

type Trigger

type Trigger interface {
	// Fire is called when the target file has been modified.
	// keyPath is the string path of the modified file relative
	// from the catalog root directory.  indexes is a slice
	// containing indexes of the rows being modified.
	Fire(keyPath string, records []Record)
}

Trigger is an interface every trigger plugin has to implement.

func Load

func Load(loader SymbolLoader, config map[string]interface{}) (Trigger, error)

Load loads a function named NewTrigger with a parameter type map[string]interface{} and initialize the trigger.

Jump to

Keyboard shortcuts

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