forked from hyeoncheon/goul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipe.go
44 lines (35 loc) · 1.09 KB
/
pipe.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
42
43
44
package goul
import "errors"
// constants.
const (
ModeConverter = true
ModeReverter = false
ErrPipeConvertNotImplemented = "convert method of pipe not implemented"
ErrPipeRevertNotImplemented = "revert method of pipe not implemented"
ErrPipeInputClosed = "input channel closed"
)
// Pipe is an interface for pipeline handlers.
type Pipe interface {
CommonMixin
Convert(in chan Item, message Message) (out chan Item, err error)
Revert(in chan Item, message Message) (out chan Item, err error)
IsConverter() bool
}
//** Base Implementation
// BasePipe is a base implementation for the Pipe interface
type BasePipe struct {
BaseCommon
Mode bool
}
// Convert implements interface Converter
func (p *BasePipe) Convert(in chan Item, message Message) (chan Item, error) {
return nil, errors.New(ErrPipeConvertNotImplemented)
}
// Revert implements interface Revert
func (p *BasePipe) Revert(in chan Item, message Message) (chan Item, error) {
return nil, errors.New(ErrPipeRevertNotImplemented)
}
// IsConverter implements Pipe
func (p *BasePipe) IsConverter() bool {
return p.Mode
}