fluent-plugin-directory 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +31 -5
- data/fluent-plugin-directory.gemspec +1 -1
- data/lib/fluent/plugin/in_directory.rb +15 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb482c43b627800e8bb1ead02767e4d8d456f575a20d02c90b6cde2bfeb91e2f
|
4
|
+
data.tar.gz: 66444cc9b59e73f4ab92d54ba3d22a54b070aa7e80439760957e72773f1f1aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3295463622de8cca2f93bc6f87c3599b9a8a7ad98bffecb885b60ef37e058ed5ce84533b993981875d99ca0a7c60dc08a04f1db5094e71e278e299d61ead454a
|
7
|
+
data.tar.gz: 1b1cd0443e6a6431b1a373e831560d96c6181479da92585b8538f5895d252a60abcee5b53805f1c532c20a074819df0bf328b921b78978a52ac7201d1ea5ec05
|
data/README.md
CHANGED
@@ -26,13 +26,39 @@ $ bundle
|
|
26
26
|
|
27
27
|
## Configuration
|
28
28
|
|
29
|
-
|
29
|
+
### content_key (string) (optional)
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
The name of the key whose value is the content of the file.
|
32
|
+
|
33
|
+
Default value: `content`.
|
34
|
+
|
35
|
+
### extension (string) (optional)
|
36
|
+
|
37
|
+
The extension that will be added to the processed files.
|
38
|
+
|
39
|
+
Default value: `.done`.
|
40
|
+
|
41
|
+
### filename_key (string) (optional)
|
42
|
+
|
43
|
+
The name of the key whose value is the name of the file.
|
44
|
+
|
45
|
+
Default value: `filename`.
|
46
|
+
|
47
|
+
### path (string) (required)
|
48
|
+
|
49
|
+
The path of the folder to be scanned by the plugin.
|
50
|
+
|
51
|
+
### run_interval (integer) (optional)
|
52
|
+
|
53
|
+
The time interval (in seconds) to wait between scans.
|
54
|
+
|
55
|
+
Default value: `60`.
|
56
|
+
|
57
|
+
### tag (string) (required)
|
58
|
+
|
59
|
+
The tag added to the output event.
|
34
60
|
|
35
|
-
|
61
|
+
- See also: [Input Plugin Overview](https://docs.fluentd.org/v/1.0/input#overview)
|
36
62
|
|
37
63
|
## Copyright
|
38
64
|
|
@@ -20,19 +20,18 @@ module Fluent
|
|
20
20
|
class DirectoryInput < Fluent::Plugin::Input
|
21
21
|
Fluent::Plugin.register_input('directory', self)
|
22
22
|
|
23
|
-
|
24
|
-
config_param :content_key, :string, default: 'content'
|
23
|
+
helpers :timer
|
25
24
|
|
26
|
-
desc 'The
|
27
|
-
config_param :
|
25
|
+
desc 'The field where the content of the file is stored in the output event.'
|
26
|
+
config_param :content_key, :string, default: 'content'
|
28
27
|
|
29
|
-
desc 'The name of the
|
28
|
+
desc 'The field where the name of the file is stored in the output event.'
|
30
29
|
config_param :filename_key, :string, default: 'filename'
|
31
30
|
|
32
|
-
desc 'The path of the folder to
|
31
|
+
desc 'The path of the folder to scan.'
|
33
32
|
config_param :path, :string
|
34
33
|
|
35
|
-
desc 'The
|
34
|
+
desc 'The interval (in seconds) to wait between scans.'
|
36
35
|
config_param :run_interval, :integer, default: 60
|
37
36
|
|
38
37
|
desc 'The tag added to the output event.'
|
@@ -41,9 +40,9 @@ module Fluent
|
|
41
40
|
def start
|
42
41
|
super
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
# See: https://docs.fluentd.org/plugin-helper-overview/api-plugin-helper-timer
|
44
|
+
timer_execute(:directory_timer, @run_interval) do
|
45
|
+
begin
|
47
46
|
# Use a stream to submit multiple events at the same time
|
48
47
|
multiEventStream = MultiEventStream.new
|
49
48
|
|
@@ -52,28 +51,22 @@ module Fluent
|
|
52
51
|
|
53
52
|
# Read filenames in the directory
|
54
53
|
Dir.glob(@path + '/*') do |filename|
|
55
|
-
# Ignore already processed files
|
56
|
-
next if filename.end_with? @extension
|
57
|
-
|
58
54
|
# Add the record to the stream
|
59
55
|
multiEventStream.add(
|
60
56
|
time,
|
61
|
-
{ @content_key => File.read(filename), @file_key => filename }
|
57
|
+
{ @content_key => File.read(filename), @file_key => filename },
|
62
58
|
)
|
63
59
|
|
64
|
-
#
|
65
|
-
File.
|
60
|
+
# Remove the file
|
61
|
+
File.delete(filename)
|
66
62
|
end
|
67
63
|
|
68
64
|
# Send the events
|
69
65
|
router.emit_stream(tag, multiEventStream)
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
rescue Exception => e
|
67
|
+
$log.warn 'Directory input error: ', e
|
68
|
+
$log.debug_backtrace(e.backtrace)
|
73
69
|
end
|
74
|
-
rescue Exception => e
|
75
|
-
$log.warn 'Directory input error: ', e
|
76
|
-
$log.debug_backtrace(e.backtrace)
|
77
70
|
end
|
78
71
|
end
|
79
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- remyduthu@icloud.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|