github.com/Jeffail/benthos/v3@v3.65.0/lib/input/files.go (about) 1 package input 2 3 import ( 4 "github.com/Jeffail/benthos/v3/internal/docs" 5 "github.com/Jeffail/benthos/v3/lib/input/reader" 6 "github.com/Jeffail/benthos/v3/lib/log" 7 "github.com/Jeffail/benthos/v3/lib/metrics" 8 "github.com/Jeffail/benthos/v3/lib/types" 9 ) 10 11 //------------------------------------------------------------------------------ 12 13 func init() { 14 Constructors[TypeFiles] = TypeSpec{ 15 constructor: fromSimpleConstructor(NewFiles), 16 Status: docs.StatusDeprecated, 17 Summary: ` 18 Reads files from a path, where each discrete file will be consumed as a single 19 message.`, 20 Description: ` 21 The path can either point to a single file (resulting in only a single message) 22 or a directory, in which case the directory will be walked and each file found 23 will become a message. 24 25 ## Alternatives 26 27 The behaviour of this input is now covered by the ` + "[`file` input](/docs/components/inputs/file)" + `. 28 29 ### Metadata 30 31 This input adds the following metadata fields to each message: 32 33 ` + "``` text" + ` 34 - path 35 ` + "```" + ` 36 37 You can access these metadata fields using 38 [function interpolation](/docs/configuration/interpolation#metadata).`, 39 Categories: []Category{ 40 CategoryLocal, 41 }, 42 FieldSpecs: docs.FieldSpecs{ 43 docs.FieldCommon("path", "A path to either a directory or a file."), 44 docs.FieldCommon("delete_files", "Whether to delete files once they are consumed."), 45 }, 46 } 47 } 48 49 //------------------------------------------------------------------------------ 50 51 // NewFiles creates a new Files input type. 52 func NewFiles(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error) { 53 var f reader.Async 54 var err error 55 if f, err = reader.NewFiles(conf.Files); err != nil { 56 return nil, err 57 } 58 f = reader.NewAsyncPreserver(f) 59 return NewAsyncReader(TypeFiles, true, f, log, stats) 60 } 61 62 //------------------------------------------------------------------------------