Documentation ¶
Overview ¶
Package gopeat provides functionality to replay time stamped data with BESRTA(best effort soft real time accuracy). Playback preserves time between consecutive time stamped data values so any time drifts will be accumulated over the total run time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CsvToTs ¶
type CsvToTs func([]string) (TimeStamper, error)
CsvToTs converts a csv line slice to a TimeStamper value
type CsvTsSource ¶
type CsvTsSource struct { Symbol string CsvStream io.Reader CsvTsConv CsvToTs MaxRecs int64 // contains filtered or unexported fields }
CsvTsSource implement a time stamped data source for csv data(with header). Client must provide CsvToTs to convert csv data to timestamper value
func (*CsvTsSource) Next ¶
func (st *CsvTsSource) Next() (TimeStamper, bool)
Next implements an iterator for the contents of the csv data
func (*CsvTsSource) SetEndTime ¶
func (st *CsvTsSource) SetEndTime(endTime time.Time)
SetEndTime sets max timpstamp for data provided
func (*CsvTsSource) SetStartTime ¶
func (st *CsvTsSource) SetStartTime(startTime time.Time)
SetStartTime sets min timpstamp for data provided
type OnTsDataReady ¶
type OnTsDataReady func(TimeStamper) error
OnTsDataReady is the function the Playback client should provide to the playback to receive the time stamped data at simulation time. The client implementation should return as soon as the time sensitive part of it's processing is complete in order to keep Playback's internal backpressure calculation accurate. OnTsDataReady runs on Playback's send thread, not the clients thread
type PlayBack ¶
type PlayBack struct { Symbol string StartTime time.Time EndTime time.Time SendTs OnTsDataReady TsDataSource TimeStampSource WallRunDur time.Duration WallStartTime time.Time // contains filtered or unexported fields }
PlayBack implements a simulation run. Playback clients need to provide a data source that implement both TimeBracket and TimeStampSource interfaces. Clients can stop the playback by closing StopChan.
func New ¶
func New(symbol string, startTime time.Time, endTime time.Time, tsSource TimeStampSource, pbRate uint16, cb OnTsDataReady) (*PlayBack, error)
New allocates a new Playback struct
func (*PlayBack) Quit ¶
func (pb *PlayBack) Quit()
Quit stops the running PlayBack and eventually unblocks callers blocked on Wait()
type TimeBracket ¶
TimeBracket is implemented by any value that has SetStartTime and a SetEndTime methods, which defines the time bracket the value falls in. Playback uses the interface to notify its time series data source to limit data to the given time bracket
type TimeStampSource ¶
type TimeStampSource interface {
Next() (tsData TimeStamper, ok bool)
}
TimeStampSource is implemented by any value that has a Next iterator method which returns TimeStamper values. When ok is false iterator is past the last value and the previous Next call returned the last value. The way playback is currently designed, a implementor of TimeStampSource should have a complete stream of data available so next can either return the next value or return EOF. If Next() blocks, the loader goroutine will block and it will never terminate on it's own. This design will be revisited.(TODO)
type TimeStamper ¶
TimeStamper is implemented by any value that has a GetTimeStamp method, which defines a time stamp for that value. The GetTimeStamp method is used by Playback as the point in time to provide the value to Playback clients
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
demo
A self contained simple demo for go-peat
|
A self contained simple demo for go-peat |
market_websocket
Package main creates a simple playback webserver.
|
Package main creates a simple playback webserver. |
simple
Very simple example of how create a gopeat Playback simulation run.
|
Very simple example of how create a gopeat Playback simulation run. |