|
@@ -6,24 +6,29 @@ import (
|
|
|
"github.com/sirupsen/logrus"
|
|
|
)
|
|
|
|
|
|
-type ConsumeFunc func(xsql.Message, xsql.Metadata)
|
|
|
+//The function to call when data is emitted by the source.
|
|
|
+type ConsumeFunc func(message xsql.Message, metadata xsql.Metadata)
|
|
|
|
|
|
type Closable interface {
|
|
|
- Close(StreamContext) error
|
|
|
+ Close(ctx StreamContext) error
|
|
|
}
|
|
|
|
|
|
type Source interface {
|
|
|
//Should be sync function for normal case. The container will run it in go func
|
|
|
- Open(StreamContext, ConsumeFunc) error
|
|
|
- Configure(string, map[string]interface{}) error
|
|
|
+ Open(ctx StreamContext, consume ConsumeFunc) error
|
|
|
+ //Called during initialization. Configure the source with the data source(e.g. topic for mqtt) and the properties
|
|
|
+ //read from the yaml
|
|
|
+ Configure(datasource string, props map[string]interface{}) error
|
|
|
Closable
|
|
|
}
|
|
|
|
|
|
type Sink interface {
|
|
|
//Should be sync function for normal case. The container will run it in go func
|
|
|
- Open(StreamContext) error
|
|
|
- Configure(map[string]interface{}) error
|
|
|
- Collect(StreamContext, interface{}) error
|
|
|
+ Open(ctx StreamContext) error
|
|
|
+ //Called during initialization. Configure the sink with the properties from rule action definition
|
|
|
+ Configure(props map[string]interface{}) error
|
|
|
+ //Called when each row of data has transferred to this sink
|
|
|
+ Collect(ctx StreamContext, data interface{}) error
|
|
|
Closable
|
|
|
}
|
|
|
|