trigger

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 3 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

This section is empty.

Types

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, indexes []int64)
}

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.

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.

Jump to

Keyboard shortcuts

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