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, ca *io.CandleAttributes, tf time.Duration, year int16, records []Record) *io.ColumnSeries
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 Record ¶
type Record []byte
Record represents a serialized byte buffer for a record written to the DB
func ColumnSeriesToRecords ¶
func ColumnSeriesToRecords(tbk io.TimeBucketKey, cs io.ColumnSeries) ([]Record, error)
ColumnSeriesToRecords takes a TimeBucketKey and a ColumnSeries and converts them to a slice of trigger.Record
type SymbolLoader ¶
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.
type TriggerMatcher ¶
type TriggerMatcher 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 }
TriggerMatcher checks if the trigger should be fired or not.
func NewMatcher ¶
func NewMatcher(trigger Trigger, on string) *TriggerMatcher
NewMatcher creates a new TriggerMatcher.
func (*TriggerMatcher) Match ¶
func (tm *TriggerMatcher) Match(keyPath string) bool
Match returns true if keyPath matches the On condition.