first draft of the storage engine interface.

pull/17/head
John Shahid 2013-09-30 15:10:43 -04:00
parent 5a17cf519f
commit f3a177ff23
1 changed files with 90 additions and 0 deletions

90
src/interfaces/se.go Normal file
View File

@ -0,0 +1,90 @@
package interfaces
import (
"time"
)
type FieldType int
const (
StringType FieldType = iota
IntType
FloatType
)
type Field struct {
Name string
Value interface{}
Type FieldType
}
type Point struct {
Fields []*Field
}
type Timeseries struct {
Name string
Points []*Point
}
type WriteRequest struct {
Timeseries []*Timeseries
}
type Operation int
const (
EqualOperation Operation = iota
NotEqualOperation
GreaterThanOperation
GreaterThanOrEqualOperation
LessThanOperation
LessThanOrEqualOperation
)
type Condition interface {
IsCondition()
}
type CombineOperation int
// definition of combining operators with order of precedence
const (
NotOperation CombineOperation = iota // First has to be nil
AndOperation
OrOperation
)
type CombiningCondition struct {
First *Condition
CombineOp CombineOperation
Second *Condition
}
type ComparisonCondition struct {
FieldName string
Op Operation
Value interface{}
}
// TODO: applying functions and joining time series
type ReadRequest struct {
Timeseries string
IsRegex bool // is the timeseries name a regex?
StartTime time.Time
EndTime time.Time
IsContinuous bool
Conditions []*Condition
}
type StorageEngineProcessingI interface {
WritePoints(request *WriteRequest) error
ReadPoints(request *ReadRequest, yield func(pts []*Point) error) error
}
type StorageEngineConsensusI interface {
// TODO: figure out the requirements of this interface. Probably the following
// 1. Transfer part(s) of the ring to other node(s)
// 2. Give up ownership of part(s) of the ring
// 3. Take ownership of part(s) of the ring
}