dummer 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -0
- data/README.md +7 -8
- data/example/countup.conf +4 -0
- data/example/fluent.conf +8 -0
- data/lib/dummer.rb +6 -0
- data/lib/dummer/generator.rb +6 -219
- data/lib/dummer/generator/abstract_mode.rb +20 -0
- data/lib/dummer/generator/factory.rb +43 -0
- data/lib/dummer/generator/field_mode.rb +74 -0
- data/lib/dummer/generator/input_mode.rb +28 -0
- data/lib/dummer/generator/message_mode.rb +16 -0
- data/lib/dummer/random.rb +107 -0
- data/lib/dummer/version.rb +1 -1
- metadata +33 -49
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36f913a41901d9441ff565d14ef17c5c122d8a3f
|
4
|
+
data.tar.gz: 50a3dc5517b2c40095f5e36da51ef1ad8ae83530
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 052bc0589e628b86cd5dbf00a895948a39c9b9cb1dce20c2e9957dec65ceb9d6825c9d01d12573162cf9a8697fc7d0e312ceaa39ed1594bd24006a4082bc3e90
|
7
|
+
data.tar.gz: 0164d36f4d12507bf955248dc63941ce518446d4dd19239494cf206159186c6174836aa2ef4b24ddf1a3eb0099a95b96332d59b044fac110d2fce51c0f6c6072
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -75,14 +75,14 @@ id:0424 time:[2013-11-19 02:34:58] level:WARN method:POST uri:/api/v1/textdat
|
|
75
75
|
|
76
76
|
(experimental)
|
77
77
|
|
78
|
-
Create a configuration file. Assume that a fluentd process is running on localhost:
|
78
|
+
Create a configuration file. Assume that a fluentd process is running on localhost:24224.
|
79
79
|
A sample configuration is as follows:
|
80
80
|
|
81
81
|
```ruby
|
82
82
|
# dummer.conf
|
83
83
|
configure 'sample' do
|
84
84
|
host "localhost" # define `host` and `port` instead of `output`
|
85
|
-
port
|
85
|
+
port 24224
|
86
86
|
rate 500
|
87
87
|
tag type: string, any: %w[raw.syslog raw.message raw.nginx] # configure tag
|
88
88
|
field :id, type: :integer, countup: true, format: "%04d"
|
@@ -175,15 +175,15 @@ Following parameters in the configuration file are available:
|
|
175
175
|
|
176
176
|
* field
|
177
177
|
|
178
|
-
Define data fields to generate. `message` and `input` options are ignored.
|
178
|
+
Random field generator mode. Define data fields to generate. `message` and `input` options are ignored. See also `Field Data Types` section below.
|
179
179
|
|
180
|
-
*
|
180
|
+
* message
|
181
181
|
|
182
|
-
|
182
|
+
Specific message generation mode. See [message.conf](./example/message.conf) as an example. This mode works pretty fast because it does not require to generate values randomly.
|
183
183
|
|
184
|
-
*
|
184
|
+
* input
|
185
185
|
|
186
|
-
Use this if you want to write
|
186
|
+
Messages taken from an input file mode. Use this if you want to write messages by reading lines of an input file in rotation. `message` option is ignored. See [input.conf](./example/input.conf) as an example. This mode also works fast.
|
187
187
|
|
188
188
|
### Field Data Types
|
189
189
|
|
@@ -322,7 +322,6 @@ and I wanted a standalone separated tool to do benchmark.
|
|
322
322
|
## ToDO
|
323
323
|
|
324
324
|
1. write tests
|
325
|
-
2. Add an option to send data to fluentd directly
|
326
325
|
|
327
326
|
## Contributing
|
328
327
|
|
data/example/fluent.conf
ADDED
data/lib/dummer.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require "dummer/version"
|
2
2
|
require "dummer/error"
|
3
3
|
require "dummer/setting"
|
4
|
+
require 'dummer/random'
|
4
5
|
require "dummer/generator"
|
6
|
+
require 'dummer/generator/abstract_mode'
|
7
|
+
require 'dummer/generator/message_mode'
|
8
|
+
require 'dummer/generator/input_mode'
|
9
|
+
require 'dummer/generator/field_mode'
|
10
|
+
require 'dummer/generator/factory'
|
5
11
|
require "dummer/worker"
|
6
12
|
require "dummer/dsl"
|
data/lib/dummer/generator.rb
CHANGED
@@ -1,23 +1,12 @@
|
|
1
1
|
module Dummer
|
2
2
|
class Generator
|
3
3
|
def initialize(setting)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Message.message_proc(setting.message)
|
11
|
-
end
|
12
|
-
@record_proc =
|
13
|
-
if fields = setting.fields
|
14
|
-
Field.record_proc(fields)
|
15
|
-
elsif input = setting.input
|
16
|
-
Input.record_proc(input)
|
17
|
-
else
|
18
|
-
Message.record_proc(setting.message)
|
19
|
-
end
|
20
|
-
@tag_proc = Field.tag_proc(setting.tag)
|
4
|
+
factory = Factory.new(setting)
|
5
|
+
# fluent-logger
|
6
|
+
@tag_proc = factory.create_tag_proc
|
7
|
+
@record_proc = factory.create_record_proc
|
8
|
+
# file
|
9
|
+
@message_proc = factory.create_message_proc
|
21
10
|
end
|
22
11
|
|
23
12
|
# @return [String] message
|
@@ -34,207 +23,5 @@ module Dummer
|
|
34
23
|
def record
|
35
24
|
@record_proc.call
|
36
25
|
end
|
37
|
-
|
38
|
-
class Message
|
39
|
-
def self.message_proc(message)
|
40
|
-
message = "#{message.chomp}\n"
|
41
|
-
Proc.new { message }
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.record_proc(message)
|
45
|
-
# ToDo: implement parser
|
46
|
-
message_proc = message_proc(message)
|
47
|
-
Proc.new { { "message" => message_proc.call } }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class Input
|
52
|
-
def self.message_proc(input)
|
53
|
-
messages = nil
|
54
|
-
begin
|
55
|
-
open(input) do |in_file|
|
56
|
-
messages = in_file.readlines
|
57
|
-
end
|
58
|
-
rescue Errno::ENOENT
|
59
|
-
raise ConfigError.new("Input file `#{input}` is not readable")
|
60
|
-
end
|
61
|
-
idx = -1
|
62
|
-
size = messages.size
|
63
|
-
Proc.new {
|
64
|
-
idx = (idx + 1) % size
|
65
|
-
messages[idx]
|
66
|
-
}
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.record_proc(input)
|
70
|
-
# ToDo: implement parser
|
71
|
-
message_proc = message_proc(input)
|
72
|
-
Proc.new { { "message" => message_proc.call } }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class Field
|
77
|
-
def self.message_proc(fields, labeled, delimiter, label_delimiter)
|
78
|
-
format_proc = format_proc(labeled, delimiter, label_delimiter)
|
79
|
-
record_proc = record_proc(fields)
|
80
|
-
|
81
|
-
Proc.new {
|
82
|
-
hash = record_proc.call
|
83
|
-
format_proc.call(hash)
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.record_proc(fields)
|
88
|
-
field_procs = field_procs(fields)
|
89
|
-
|
90
|
-
prev_data = {}
|
91
|
-
Proc.new {
|
92
|
-
data = {}
|
93
|
-
field_procs.each do |key, proc|
|
94
|
-
prev = prev_data[key] || -1
|
95
|
-
data[key] = proc.call(prev)
|
96
|
-
end
|
97
|
-
prev_data = data
|
98
|
-
}
|
99
|
-
end
|
100
|
-
|
101
|
-
def self.tag_proc(tag_opts)
|
102
|
-
field_procs({"tag" => tag_opts})["tag"]
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.format_proc(labeled, delimiter, label_delimiter)
|
106
|
-
if labeled
|
107
|
-
Proc.new {|fields| "#{fields.map {|key, val| "#{key}#{label_delimiter}#{val}" }.join(delimiter)}\n" }
|
108
|
-
else
|
109
|
-
Proc.new {|fields| "#{fields.values.join(delimiter)}\n" }
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.field_procs(fields)
|
114
|
-
rand = ::Dummer::Random.new
|
115
|
-
field_procs = {}
|
116
|
-
fields.each do |key, opts|
|
117
|
-
opts = opts.dup
|
118
|
-
type = opts.delete(:type)
|
119
|
-
field_procs[key] =
|
120
|
-
case type
|
121
|
-
when :string
|
122
|
-
rand.string(opts)
|
123
|
-
when :integer
|
124
|
-
rand.integer(opts)
|
125
|
-
when :float
|
126
|
-
rand.float(opts)
|
127
|
-
when :datetime
|
128
|
-
rand.datetime(opts)
|
129
|
-
else
|
130
|
-
raise ConfigError.new("type: `#{type}` is not defined.")
|
131
|
-
end
|
132
|
-
end
|
133
|
-
field_procs
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
class Random
|
139
|
-
def initialize
|
140
|
-
@rand = ::Random.new(0)
|
141
|
-
@chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a # no symbols and multi-bytes for now
|
142
|
-
end
|
143
|
-
|
144
|
-
def range(range)
|
145
|
-
rand(range)
|
146
|
-
end
|
147
|
-
|
148
|
-
def any(any)
|
149
|
-
any[rand(any.size)]
|
150
|
-
end
|
151
|
-
|
152
|
-
def rand(arg = nil)
|
153
|
-
@rand.rand(arg)
|
154
|
-
end
|
155
|
-
|
156
|
-
# belows are data types
|
157
|
-
|
158
|
-
def string(opts = {})
|
159
|
-
length, any, value = (opts[:length] || 8), opts[:any], opts[:value]
|
160
|
-
if value
|
161
|
-
string = value.to_s
|
162
|
-
Proc.new { string }
|
163
|
-
elsif any
|
164
|
-
Proc.new { self.any(any) }
|
165
|
-
else
|
166
|
-
Proc.new { Array.new(length){@chars[rand(@chars.size-1)]}.join }
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def integer(opts = {})
|
171
|
-
format, range, countup, value = opts[:format], opts[:range], opts[:countup], opts[:value]
|
172
|
-
if format
|
173
|
-
if value
|
174
|
-
integer = sprintf(format, value.to_i)
|
175
|
-
Proc.new { integer }
|
176
|
-
elsif range
|
177
|
-
Proc.new { sprintf(format, self.range(range)) }
|
178
|
-
elsif countup
|
179
|
-
Proc.new {|prev| sprintf(format, prev.to_i + 1) }
|
180
|
-
else
|
181
|
-
Proc.new { sprintf(format, rand(0..2,147,483,647)) }
|
182
|
-
end
|
183
|
-
else
|
184
|
-
if value
|
185
|
-
integer = value.to_i
|
186
|
-
Proc.new { integer }
|
187
|
-
elsif range
|
188
|
-
Proc.new { self.range(range) }
|
189
|
-
elsif countup
|
190
|
-
Proc.new {|prev| prev + 1 }
|
191
|
-
else
|
192
|
-
Proc.new { rand(0..2,147,483,647) }
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def float(opts = {})
|
198
|
-
format, range, value = opts[:format], opts[:range], opts[:value]
|
199
|
-
if format
|
200
|
-
if value
|
201
|
-
float = value.to_f
|
202
|
-
Proc.new { sprintf(format, float) }
|
203
|
-
elsif range
|
204
|
-
Proc.new { sprintf(format, self.range(range)) }
|
205
|
-
else
|
206
|
-
Proc.new { r = rand(1..358); sprintf(format, r * Math.cos(r)) }
|
207
|
-
end
|
208
|
-
else
|
209
|
-
if value
|
210
|
-
float = value.to_f
|
211
|
-
Proc.new { float }
|
212
|
-
elsif range
|
213
|
-
Proc.new { self.range(range) }
|
214
|
-
else
|
215
|
-
Proc.new { r = rand(1..358); r * Math.cos(r) }
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def datetime(opts = {})
|
221
|
-
format, random, value = (opts[:format] || "%Y-%m-%d %H:%M:%S.%3N"), (opts[:random] || false), opts[:value]
|
222
|
-
if value
|
223
|
-
Proc.new { value.strftime(format) }
|
224
|
-
elsif random
|
225
|
-
Proc.new {
|
226
|
-
y = rand(1970..2037);
|
227
|
-
m = rand(1..12);
|
228
|
-
d = rand(1..27);
|
229
|
-
h = rand(0..23);
|
230
|
-
min = rand(0..59);
|
231
|
-
s = rand(0..59);
|
232
|
-
usec = rand(0..999999);
|
233
|
-
Time.local(y, m, d, h, min, s, usec).strftime(format)
|
234
|
-
}
|
235
|
-
else
|
236
|
-
Proc.new { Time.now.strftime(format) }
|
237
|
-
end
|
238
|
-
end
|
239
26
|
end
|
240
27
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Dummer
|
2
|
+
class Generator
|
3
|
+
class AbstractMode
|
4
|
+
# file
|
5
|
+
def self.message_proc(message)
|
6
|
+
raise NotImplementedError
|
7
|
+
end
|
8
|
+
|
9
|
+
# fluent-logger
|
10
|
+
def self.record_proc(message)
|
11
|
+
raise NotImplementedError
|
12
|
+
end
|
13
|
+
|
14
|
+
# fluent-logger
|
15
|
+
def self.tag_proc(tag_opts)
|
16
|
+
FieldMode.field_procs({"tag" => tag_opts})["tag"]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Dummer
|
2
|
+
class Generator
|
3
|
+
class Factory
|
4
|
+
attr_reader :setting
|
5
|
+
|
6
|
+
def initialize(setting)
|
7
|
+
@setting = setting
|
8
|
+
end
|
9
|
+
|
10
|
+
# file
|
11
|
+
def create_message_proc
|
12
|
+
if fields = setting.fields
|
13
|
+
FieldMode.message_proc(
|
14
|
+
fields,
|
15
|
+
setting.labeled,
|
16
|
+
setting.delimiter,
|
17
|
+
setting.label_delimiter
|
18
|
+
)
|
19
|
+
elsif input = setting.input
|
20
|
+
InputMode.message_proc(input)
|
21
|
+
else
|
22
|
+
MessageMode.message_proc(setting.message)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# fluent-logger
|
27
|
+
def create_record_proc
|
28
|
+
if fields = setting.fields
|
29
|
+
FieldMode.record_proc(fields)
|
30
|
+
elsif input = setting.input
|
31
|
+
InputMode.record_proc(input)
|
32
|
+
else
|
33
|
+
MessageMode.record_proc(setting.message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# fluent-logger
|
38
|
+
def create_tag_proc
|
39
|
+
FieldMode.tag_proc(setting.tag)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Dummer
|
2
|
+
class Generator
|
3
|
+
class FieldMode < AbstractMode
|
4
|
+
def self.message_proc(fields, labeled, delimiter, label_delimiter)
|
5
|
+
format_proc = format_proc(labeled, delimiter, label_delimiter)
|
6
|
+
record_proc = record_proc(fields)
|
7
|
+
|
8
|
+
Proc.new {
|
9
|
+
hash = record_proc.call
|
10
|
+
format_proc.call(hash)
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.record_proc(fields)
|
15
|
+
field_procs = field_procs(fields)
|
16
|
+
|
17
|
+
prev_data = {}
|
18
|
+
Proc.new {
|
19
|
+
data = {}
|
20
|
+
field_procs.each do |key, proc|
|
21
|
+
prev = prev_data[key] || -1
|
22
|
+
value, raw = proc.call(prev)
|
23
|
+
data[key] = value
|
24
|
+
prev_data[key] = raw || value
|
25
|
+
end
|
26
|
+
data
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.tag_proc(tag_opts)
|
31
|
+
proc = field_procs({"tag" => tag_opts})["tag"]
|
32
|
+
prev = -1
|
33
|
+
Proc.new {
|
34
|
+
value, raw = proc.call(prev)
|
35
|
+
prev = raw || value
|
36
|
+
value
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# private
|
41
|
+
|
42
|
+
def self.format_proc(labeled, delimiter, label_delimiter)
|
43
|
+
if labeled
|
44
|
+
Proc.new {|fields| "#{fields.map {|key, val| "#{key}#{label_delimiter}#{val}" }.join(delimiter)}\n" }
|
45
|
+
else
|
46
|
+
Proc.new {|fields| "#{fields.values.join(delimiter)}\n" }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.field_procs(fields)
|
51
|
+
rand = ::Dummer::Random.new
|
52
|
+
field_procs = {}
|
53
|
+
fields.each do |key, opts|
|
54
|
+
opts = opts.dup
|
55
|
+
type = opts.delete(:type)
|
56
|
+
field_procs[key] =
|
57
|
+
case type
|
58
|
+
when :string
|
59
|
+
rand.string(opts)
|
60
|
+
when :integer
|
61
|
+
rand.integer(opts)
|
62
|
+
when :float
|
63
|
+
rand.float(opts)
|
64
|
+
when :datetime
|
65
|
+
rand.datetime(opts)
|
66
|
+
else
|
67
|
+
raise ConfigError.new("type: `#{type}` is not defined.")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
field_procs
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Dummer
|
2
|
+
class Generator
|
3
|
+
class InputMode < AbstractMode
|
4
|
+
def self.message_proc(input)
|
5
|
+
messages = nil
|
6
|
+
begin
|
7
|
+
open(input) do |in_file|
|
8
|
+
messages = in_file.readlines
|
9
|
+
end
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
raise ConfigError.new("Input file `#{input}` is not readable")
|
12
|
+
end
|
13
|
+
idx = -1
|
14
|
+
size = messages.size
|
15
|
+
Proc.new {
|
16
|
+
idx = (idx + 1) % size
|
17
|
+
messages[idx]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.record_proc(input)
|
22
|
+
# ToDo: implement parser
|
23
|
+
message_proc = message_proc(input)
|
24
|
+
Proc.new { { "message" => message_proc.call } }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Dummer
|
2
|
+
class Generator
|
3
|
+
class MessageMode < AbstractMode
|
4
|
+
def self.message_proc(message)
|
5
|
+
message = "#{message.chomp}\n"
|
6
|
+
Proc.new { message }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.record_proc(message)
|
10
|
+
# ToDo: implement parser
|
11
|
+
message_proc = message_proc(message)
|
12
|
+
Proc.new { { "message" => message_proc.call } }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Dummer
|
2
|
+
class Random
|
3
|
+
def initialize
|
4
|
+
@rand = ::Random.new(0)
|
5
|
+
@chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a # no symbols and multi-bytes for now
|
6
|
+
end
|
7
|
+
|
8
|
+
# belows are data types
|
9
|
+
# @return Proc object which returns a random generated value, or [formatted_value, raw_value]
|
10
|
+
|
11
|
+
def string(opts = {})
|
12
|
+
length, any, value = (opts[:length] || 8), opts[:any], opts[:value]
|
13
|
+
if value
|
14
|
+
string = value.to_s
|
15
|
+
Proc.new { string }
|
16
|
+
elsif any
|
17
|
+
Proc.new { self.any(any) }
|
18
|
+
else
|
19
|
+
Proc.new { Array.new(length){@chars[rand(@chars.size-1)]}.join }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def integer(opts = {})
|
24
|
+
format, range, countup, value = opts[:format], opts[:range], opts[:countup], opts[:value]
|
25
|
+
if format
|
26
|
+
if value
|
27
|
+
integer = sprintf(format, value.to_i)
|
28
|
+
Proc.new { integer }
|
29
|
+
elsif range
|
30
|
+
Proc.new { sprintf(format, self.range(range)) }
|
31
|
+
elsif countup
|
32
|
+
Proc.new {|prev| v = prev + 1; [sprintf(format, v), v] }
|
33
|
+
else
|
34
|
+
Proc.new { sprintf(format, rand(0..2,147,483,647)) }
|
35
|
+
end
|
36
|
+
else
|
37
|
+
if value
|
38
|
+
integer = value.to_i
|
39
|
+
Proc.new { integer }
|
40
|
+
elsif range
|
41
|
+
Proc.new { self.range(range) }
|
42
|
+
elsif countup
|
43
|
+
Proc.new {|prev| prev + 1 }
|
44
|
+
else
|
45
|
+
Proc.new { rand(0..2,147,483,647) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def float(opts = {})
|
51
|
+
format, range, value = opts[:format], opts[:range], opts[:value]
|
52
|
+
if format
|
53
|
+
if value
|
54
|
+
float = value.to_f
|
55
|
+
Proc.new { sprintf(format, float) }
|
56
|
+
elsif range
|
57
|
+
Proc.new { sprintf(format, self.range(range)) }
|
58
|
+
else
|
59
|
+
Proc.new { r = rand(1..358); sprintf(format, r * Math.cos(r)) }
|
60
|
+
end
|
61
|
+
else
|
62
|
+
if value
|
63
|
+
float = value.to_f
|
64
|
+
Proc.new { float }
|
65
|
+
elsif range
|
66
|
+
Proc.new { self.range(range) }
|
67
|
+
else
|
68
|
+
Proc.new { r = rand(1..358); r * Math.cos(r) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def datetime(opts = {})
|
74
|
+
format, random, value = (opts[:format] || "%Y-%m-%d %H:%M:%S.%3N"), (opts[:random] || false), opts[:value]
|
75
|
+
if value
|
76
|
+
Proc.new { value.strftime(format) }
|
77
|
+
elsif random
|
78
|
+
Proc.new {
|
79
|
+
y = rand(1970..2037);
|
80
|
+
m = rand(1..12);
|
81
|
+
d = rand(1..27);
|
82
|
+
h = rand(0..23);
|
83
|
+
min = rand(0..59);
|
84
|
+
s = rand(0..59);
|
85
|
+
usec = rand(0..999999);
|
86
|
+
Time.local(y, m, d, h, min, s, usec).strftime(format)
|
87
|
+
}
|
88
|
+
else
|
89
|
+
Proc.new { Time.now.strftime(format) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# private
|
94
|
+
|
95
|
+
def range(range)
|
96
|
+
rand(range)
|
97
|
+
end
|
98
|
+
|
99
|
+
def any(any)
|
100
|
+
any[rand(any.size)]
|
101
|
+
end
|
102
|
+
|
103
|
+
def rand(arg = nil)
|
104
|
+
@rand.rand(arg)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/dummer/version.rb
CHANGED
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dummer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- sonots
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: thor
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: serverengine
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: fluent-logger
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '1.3'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '1.3'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: pry
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: pry-nav
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
description: Generates dummy log data for Fluentd benchmark
|
@@ -149,8 +132,8 @@ executables:
|
|
149
132
|
extensions: []
|
150
133
|
extra_rdoc_files: []
|
151
134
|
files:
|
152
|
-
- .gitignore
|
153
|
-
- .travis.yml
|
135
|
+
- ".gitignore"
|
136
|
+
- ".travis.yml"
|
154
137
|
- CHANGELOG.md
|
155
138
|
- Gemfile
|
156
139
|
- LICENSE.txt
|
@@ -160,6 +143,8 @@ files:
|
|
160
143
|
- bin/dummer_simple
|
161
144
|
- bin/dummer_yes
|
162
145
|
- dummer.gemspec
|
146
|
+
- example/countup.conf
|
147
|
+
- example/fluent.conf
|
163
148
|
- example/fluent_logger.conf
|
164
149
|
- example/input.conf
|
165
150
|
- example/input.txt
|
@@ -170,6 +155,12 @@ files:
|
|
170
155
|
- lib/dummer/dsl.rb
|
171
156
|
- lib/dummer/error.rb
|
172
157
|
- lib/dummer/generator.rb
|
158
|
+
- lib/dummer/generator/abstract_mode.rb
|
159
|
+
- lib/dummer/generator/factory.rb
|
160
|
+
- lib/dummer/generator/field_mode.rb
|
161
|
+
- lib/dummer/generator/input_mode.rb
|
162
|
+
- lib/dummer/generator/message_mode.rb
|
163
|
+
- lib/dummer/random.rb
|
173
164
|
- lib/dummer/setting.rb
|
174
165
|
- lib/dummer/version.rb
|
175
166
|
- lib/dummer/worker.rb
|
@@ -179,32 +170,25 @@ files:
|
|
179
170
|
homepage: https://github.com/sonots/dummer
|
180
171
|
licenses:
|
181
172
|
- MIT
|
173
|
+
metadata: {}
|
182
174
|
post_install_message:
|
183
175
|
rdoc_options: []
|
184
176
|
require_paths:
|
185
177
|
- lib
|
186
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
-
none: false
|
188
179
|
requirements:
|
189
|
-
- -
|
180
|
+
- - ">="
|
190
181
|
- !ruby/object:Gem::Version
|
191
182
|
version: '0'
|
192
|
-
segments:
|
193
|
-
- 0
|
194
|
-
hash: -916554641
|
195
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
-
none: false
|
197
184
|
requirements:
|
198
|
-
- -
|
185
|
+
- - ">="
|
199
186
|
- !ruby/object:Gem::Version
|
200
187
|
version: '0'
|
201
|
-
segments:
|
202
|
-
- 0
|
203
|
-
hash: -916554641
|
204
188
|
requirements: []
|
205
189
|
rubyforge_project:
|
206
|
-
rubygems_version:
|
190
|
+
rubygems_version: 2.2.2
|
207
191
|
signing_key:
|
208
|
-
specification_version:
|
192
|
+
specification_version: 4
|
209
193
|
summary: Generates dummy log data for Fluentd benchmark
|
210
194
|
test_files: []
|