forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
response_channel_processor.go
41 lines (34 loc) · 1 KB
/
response_channel_processor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package cluster
import (
"code.google.com/p/log4go"
"github.com/influxdb/influxdb/engine"
"github.com/influxdb/influxdb/protocol"
)
// ResponseChannelProcessor converts Series to Responses. This is used
// to chain `engine.Processor` with a `ResponseChannel'
type ResponseChannelProcessor struct {
r ResponseChannel
}
func NewResponseChannelProcessor(r ResponseChannel) *ResponseChannelProcessor {
return &ResponseChannelProcessor{r}
}
func (p *ResponseChannelProcessor) Yield(s *protocol.Series) (bool, error) {
log4go.Debug("Yielding to %s %s", p.r.Name(), s)
ok := p.r.Yield(&protocol.Response{
Type: protocol.Response_QUERY.Enum(),
MultiSeries: []*protocol.Series{s},
})
return ok, nil
}
func (p *ResponseChannelProcessor) Close() error {
p.r.Yield(&protocol.Response{
Type: protocol.Response_END_STREAM.Enum(),
})
return nil
}
func (p *ResponseChannelProcessor) Name() string {
return "ResponseChannelProcessor"
}
func (p *ResponseChannelProcessor) Next() engine.Processor {
return nil
}