-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
adapter.go
38 lines (30 loc) · 938 Bytes
/
adapter.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
package goul
import "errors"
// constants.
const (
ErrAdapterReadNotImplemented = "AdapterReadNotImplemented"
ErrAdapterWriteNotImplemented = "AdapterWriteNotImplemented"
)
// Adapter is an interface for in/out adapters for pipeline.
type Adapter interface {
CommonMixin
Write(in chan Item, message Message) (done chan Item, err error)
Read(ctrl chan Item, message Message) (out chan Item, err error)
Close() error
}
//** Base Implementation
// BaseAdapter is a base implementation for the Adapter interface
type BaseAdapter struct {
BaseCommon
ID string
}
func (a *BaseAdapter) Read(ctrl chan Item, message Message) (chan Item, error) {
return nil, errors.New(ErrAdapterReadNotImplemented)
}
func (a *BaseAdapter) Write(in chan Item, message Message) (chan Item, error) {
return nil, errors.New(ErrAdapterWriteNotImplemented)
}
// Close implements Adapter interface
func (a *BaseAdapter) Close() error {
return nil
}