forked from compose/transporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.go
56 lines (45 loc) · 1.13 KB
/
file.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
45
46
47
48
49
50
51
52
53
54
55
56
package file
import (
"sync"
"github.com/compose/transporter/adaptor"
"github.com/compose/transporter/client"
)
const (
sampleConfig = `{
"uri": "stdout://"
}`
description = "an adaptor that reads / writes files"
)
// File is an adaptor that can be used as a
// source / sink for file's on disk, as well as a sink to stdout.
type File struct {
adaptor.BaseConfig
}
func init() {
adaptor.Add(
"file",
func() adaptor.Adaptor {
return &File{}
},
)
}
// Client creates an instance of Client to be used for reading/writing to a file.
func (f *File) Client() (client.Client, error) {
return NewClient(WithURI(f.URI))
}
// Reader instantiates a Reader for use with working with the file.
func (f *File) Reader() (client.Reader, error) {
return newReader(), nil
}
// Writer instantiates a Writer for use with working with the file.
func (f *File) Writer(done chan struct{}, wg *sync.WaitGroup) (client.Writer, error) {
return newWriter(), nil
}
// Description for file adaptor
func (f *File) Description() string {
return description
}
// SampleConfig for file adaptor
func (f *File) SampleConfig() string {
return sampleConfig
}