forked from redpanda-data/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hdfs.go
61 lines (51 loc) · 1.65 KB
/
hdfs.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
57
58
59
60
61
package input
import (
"errors"
"github.com/dafanshu/benthos/v3/internal/docs"
"github.com/dafanshu/benthos/v3/lib/input/reader"
"github.com/dafanshu/benthos/v3/lib/log"
"github.com/dafanshu/benthos/v3/lib/metrics"
"github.com/dafanshu/benthos/v3/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeHDFS] = TypeSpec{
constructor: fromSimpleConstructor(NewHDFS),
Summary: `
Reads files from a HDFS directory, where each discrete file will be consumed as
a single message payload.`,
Description: `
### Metadata
This input adds the following metadata fields to each message:
` + "``` text" + `
- hdfs_name
- hdfs_path
` + "```" + `
You can access these metadata fields using
[function interpolation](/docs/configuration/interpolation#metadata).`,
Categories: []Category{
CategoryServices,
},
FieldSpecs: docs.FieldSpecs{
docs.FieldCommon("hosts", "A list of target host addresses to connect to.").Array(),
docs.FieldCommon("user", "A user ID to connect as."),
docs.FieldCommon("directory", "The directory to consume from."),
},
}
}
//------------------------------------------------------------------------------
// NewHDFS creates a new Files input type.
func NewHDFS(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) {
if conf.HDFS.Directory == "" {
return nil, errors.New("invalid directory (cannot be empty)")
}
return NewAsyncReader(
TypeHDFS,
true,
reader.NewAsyncPreserver(
reader.NewHDFS(conf.HDFS, log, stats),
),
log, stats,
)
}
//------------------------------------------------------------------------------