utils

package
v2.3.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Day = 24 * time.Hour
View Source
const Week = 7 * Day
View Source
const Year = 365 * Day

Variables

View Source
var (
	Tag        string
	GitHash    string
	BuildStamp string
)
View Source
var Timeframes = []*Timeframe{
	{"1Min", time.Minute},
	{"5Min", 5 * time.Minute},
	{"15Min", 15 * time.Minute},
	{"1H", time.Hour},
	{"4H", 4 * time.Hour},
	{"1D", Day},
}

Functions

func BufferProcessOutput

func BufferProcessOutput(output chan interface{}, mq *MessageQueue)

func IsRunning

func IsRunning(pid uint32) bool

func NewPID

func NewPID() uint32

func NewProcess

func NewProcess(run func(chan interface{}, chan interface{}), parentContext context.Context) (pid uint32)

Types

type BgWorkerSetting

type BgWorkerSetting struct {
	Module string
	Name   string
	Config map[string]interface{}
}

type CandleDuration

type CandleDuration struct {
	String string
	// contains filtered or unexported fields
}

func CandleDurationFromString

func CandleDurationFromString(tf string) (cd *CandleDuration)

func (*CandleDuration) Ceil

func (cd *CandleDuration) Ceil(ts time.Time) time.Time

Ceil returns the upper boundary time of this candle window that ts belongs to.

func (*CandleDuration) Duration

func (cd *CandleDuration) Duration() time.Duration

func (*CandleDuration) IsWithin

func (cd *CandleDuration) IsWithin(ts, start time.Time) bool

func (*CandleDuration) QueryableNrecords

func (cd *CandleDuration) QueryableNrecords(tf string, nrecords int) int

func (*CandleDuration) QueryableTimeframe

func (cd *CandleDuration) QueryableTimeframe() string

func (*CandleDuration) Truncate

func (cd *CandleDuration) Truncate(ts time.Time) time.Time

Truncate returns the lower boundary time of this candle window that ts belongs to.

type MessageQueue

type MessageQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMessageQueue

func NewMessageQueue(length int) *MessageQueue

func (*MessageQueue) AddMessage

func (mq *MessageQueue) AddMessage(msg interface{})

func (*MessageQueue) GetMessages

func (mq *MessageQueue) GetMessages() (times []time.Time, messages []interface{})

func (*MessageQueue) Len

func (mq *MessageQueue) Len() int

func (*MessageQueue) Less

func (mq *MessageQueue) Less(i, j int) bool

func (*MessageQueue) Swap

func (mq *MessageQueue) Swap(i, j int)

type MktsConfig

type MktsConfig struct {
	RootDirectory     string
	ListenPort        string
	Timezone          *time.Location
	Queryable         bool
	StopGracePeriod   time.Duration
	WALRotateInterval int
	EnableAdd         bool
	EnableRemove      bool
	EnableLastKnown   bool
	StartTime         time.Time
	Triggers          []*TriggerSetting
	BgWorkers         []*BgWorkerSetting
}
var InstanceConfig MktsConfig

func (*MktsConfig) Parse

func (m *MktsConfig) Parse(data []byte) error

type Process

type Process struct {
	PID     uint32
	Context context.Context

	Messages *MessageQueue
	// contains filtered or unexported fields
}

func GetProcFromPID

func GetProcFromPID(pid uint32) *Process

func (*Process) GetOutput

func (pr *Process) GetOutput() (timestamps []time.Time, messages []interface{}, err error)

func (*Process) Kill

func (pr *Process) Kill()

func (*Process) PutInput

func (pr *Process) PutInput(msg interface{}) (err error)

type Timeframe

type Timeframe struct {
	String   string
	Duration time.Duration
}

func NewTimeframe

func NewTimeframe(arg interface{}) (tf *Timeframe)

func TimeframeFromDuration

func TimeframeFromDuration(tf time.Duration) *Timeframe

func TimeframeFromString

func TimeframeFromString(tf string) *Timeframe

func (*Timeframe) PeriodsPerDay

func (tf *Timeframe) PeriodsPerDay() int

type TriggerSetting

type TriggerSetting struct {
	Module string
	On     string
	Config map[string]interface{}
}

Directories

Path Synopsis
rpc

Jump to

Keyboard shortcuts

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