observed 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +204 -0
  7. data/Rakefile +4 -0
  8. data/examples/00readme/Gemfile +5 -0
  9. data/examples/00readme/clockwork.rb +16 -0
  10. data/examples/00readme/observed.rb +17 -0
  11. data/examples/observed.rb +10 -0
  12. data/exe/observed-oneshot +11 -0
  13. data/features/oneshot.feature +24 -0
  14. data/features/support/env.rb +8 -0
  15. data/features/test_in_single_ruby_source.feature +32 -0
  16. data/integrations/observed-clockwork/.gitignore +17 -0
  17. data/integrations/observed-clockwork/Gemfile +4 -0
  18. data/integrations/observed-clockwork/LICENSE.txt +22 -0
  19. data/integrations/observed-clockwork/README.md +53 -0
  20. data/integrations/observed-clockwork/Rakefile +1 -0
  21. data/integrations/observed-clockwork/bin/clockwork +16 -0
  22. data/integrations/observed-clockwork/bin/clockworkd +16 -0
  23. data/integrations/observed-clockwork/bin/observed-clockwork +16 -0
  24. data/integrations/observed-clockwork/bin/rake +16 -0
  25. data/integrations/observed-clockwork/examples/clockwork/clockwork.rb +9 -0
  26. data/integrations/observed-clockwork/examples/clockwork/foo_plugin.rb +19 -0
  27. data/integrations/observed-clockwork/examples/clockwork/observed.conf +6 -0
  28. data/integrations/observed-clockwork/features/run_observed_inside_clockwork.feature +59 -0
  29. data/integrations/observed-clockwork/features/support/env.rb +8 -0
  30. data/integrations/observed-clockwork/lib/observed/clockwork/version.rb +5 -0
  31. data/integrations/observed-clockwork/lib/observed/clockwork.rb +20 -0
  32. data/integrations/observed-clockwork/observed-clockwork.gemspec +29 -0
  33. data/lib/observed/application/oneshot.rb +114 -0
  34. data/lib/observed/application.rb +1 -0
  35. data/lib/observed/builtin_plugins/file.rb +49 -0
  36. data/lib/observed/builtin_plugins/stdout.rb +35 -0
  37. data/lib/observed/builtin_plugins.rb +2 -0
  38. data/lib/observed/config.rb +27 -0
  39. data/lib/observed/config_builder.rb +167 -0
  40. data/lib/observed/config_dsl.rb +77 -0
  41. data/lib/observed/configurable.rb +56 -0
  42. data/lib/observed/default/observer.rb +16 -0
  43. data/lib/observed/default/reporter.rb +17 -0
  44. data/lib/observed/default.rb +2 -0
  45. data/lib/observed/hash/builder.rb +24 -0
  46. data/lib/observed/hash/fetcher.rb +19 -0
  47. data/lib/observed/hash/key_path_encoding.rb +62 -0
  48. data/lib/observed/hash.rb +3 -0
  49. data/lib/observed/observer.rb +18 -0
  50. data/lib/observed/observer_helpers/timer.rb +37 -0
  51. data/lib/observed/pluggable.rb +34 -0
  52. data/lib/observed/reader.rb +14 -0
  53. data/lib/observed/reporter/regexp_matching.rb +11 -0
  54. data/lib/observed/reporter.rb +25 -0
  55. data/lib/observed/system.rb +109 -0
  56. data/lib/observed/version.rb +3 -0
  57. data/lib/observed/writer.rb +14 -0
  58. data/lib/observed.rb +77 -0
  59. data/observed.gemspec +30 -0
  60. data/plugins/observed-fluentd/.gitignore +20 -0
  61. data/plugins/observed-fluentd/Gemfile +12 -0
  62. data/plugins/observed-fluentd/LICENSE.txt +22 -0
  63. data/plugins/observed-fluentd/README.md +99 -0
  64. data/plugins/observed-fluentd/Rakefile +1 -0
  65. data/plugins/observed-fluentd/features/plugin.feature +61 -0
  66. data/plugins/observed-fluentd/features/support/env.rb +32 -0
  67. data/plugins/observed-fluentd/fluent.d/fluent.conf +93 -0
  68. data/plugins/observed-fluentd/fluentd.pid +1 -0
  69. data/plugins/observed-fluentd/lib/observed/fluentd/version.rb +5 -0
  70. data/plugins/observed-fluentd/lib/observed/fluentd.rb +30 -0
  71. data/plugins/observed-fluentd/observe.d/clockwork.rb +9 -0
  72. data/plugins/observed-fluentd/observe.d/observed.conf +17 -0
  73. data/plugins/observed-fluentd/observed-fluentd.gemspec +26 -0
  74. data/plugins/observed-gauge/.gitignore +18 -0
  75. data/plugins/observed-gauge/Gemfile +4 -0
  76. data/plugins/observed-gauge/LICENSE.txt +22 -0
  77. data/plugins/observed-gauge/README.md +29 -0
  78. data/plugins/observed-gauge/Rakefile +1 -0
  79. data/plugins/observed-gauge/lib/observed/gauge/version.rb +5 -0
  80. data/plugins/observed-gauge/lib/observed/gauge.rb +117 -0
  81. data/plugins/observed-gauge/observed-gauge.gemspec +30 -0
  82. data/plugins/observed-gauge/spec/gauge_spec.rb +195 -0
  83. data/plugins/observed-gauge/spec/spec_helper.rb +25 -0
  84. data/plugins/observed-http/.gitignore +17 -0
  85. data/plugins/observed-http/Gemfile +4 -0
  86. data/plugins/observed-http/LICENSE.txt +22 -0
  87. data/plugins/observed-http/README.md +37 -0
  88. data/plugins/observed-http/Rakefile +1 -0
  89. data/plugins/observed-http/features/observe_web_services_via_http.feature +32 -0
  90. data/plugins/observed-http/features/support/env.rb +8 -0
  91. data/plugins/observed-http/lib/observed/http/version.rb +5 -0
  92. data/plugins/observed-http/lib/observed/http.rb +60 -0
  93. data/plugins/observed-http/observed-http.gemspec +31 -0
  94. data/plugins/observed-http/spec/fixtures/observed.conf +10 -0
  95. data/plugins/observed-http/spec/http_spec.rb +14 -0
  96. data/plugins/observed-http/spec/spec_helper.rb +25 -0
  97. data/spec/builtin_plugins/file_spec.rb +145 -0
  98. data/spec/builtin_plugins/stdout_spec.rb +56 -0
  99. data/spec/config_builder_spec.rb +146 -0
  100. data/spec/config_dsl_spec.rb +50 -0
  101. data/spec/configurable_spec.rb +65 -0
  102. data/spec/fixtures/configure_by_conf/foo_plugin.rb +12 -0
  103. data/spec/fixtures/configure_by_conf/observed.conf +6 -0
  104. data/spec/fixtures/configure_by_conf_dot_d/foo_plugin.rb +18 -0
  105. data/spec/fixtures/configure_by_conf_dot_d/observed.conf.d/check_foo_1.rb +1 -0
  106. data/spec/fixtures/configure_by_conf_dot_d/observed.conf.d/plugins.rb +1 -0
  107. data/spec/fixtures/configure_by_require/observed_conf.rb +6 -0
  108. data/spec/hash/builder_spec.rb +36 -0
  109. data/spec/hash/fetcher_spec.rb +29 -0
  110. data/spec/input_helpers/timer_spec.rb +54 -0
  111. data/spec/observed_spec.rb +79 -0
  112. data/spec/observer_spec.rb +123 -0
  113. data/spec/oneshot_spec.rb +58 -0
  114. data/spec/reader_spec.rb +15 -0
  115. data/spec/reporter_spec.rb +19 -0
  116. data/spec/spec_helper.rb +65 -0
  117. data/spec/system_spec.rb +75 -0
  118. data/spec/writer_spec.rb +16 -0
  119. metadata +299 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjY4MTNiYmFjYTdiNmQ3ODk3ZThkOGRjMjNkNWI1MDg2MmZhYTUxNw==
5
+ data.tar.gz: !binary |-
6
+ YzYwZWI3NGE3ZmI4MmQ4NDRkZWZkMTBiNzU2NDM5NmUzMzg3ZWZiYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NGM5N2Q4ODQzMTRlZDMzNzdiN2UwODVjNmE0NzUwMjdkZTU2MzdkOThjNjc3
10
+ NmQwMjRkZGIzYzM0ZDA3N2FkMWVkZmY0YjAyNDE3MWNjMjMxMDUwYmY5ZmMw
11
+ MWNkMjFmN2RiMTY2Mzg1MjRmMzVlOWEwMGM0MDAxZjE5N2UyOTg=
12
+ data.tar.gz: !binary |-
13
+ MTYxNDc0NGRlZjE2NDkwMzNmOGY5ZTM4MDQ1NmNkZWJkNTY0NDk0MWY4MDkz
14
+ OWQ2ZjQ1MzVhYTQyNDE2MGU4YjExZDEyNTg3ZDg1ZDBmM2NlMWViMjBlZjdi
15
+ YzQ0MWE5OThlMDc1ZmVmMGZkMTQ5YTAxM2QxNTg4NWU4ZGIyYzQ=
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *~
19
+ .idea/
20
+ *.iml
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode
5
+ jdk:
6
+ - openjdk7
7
+ - oraclejdk7
8
+ matrix:
9
+ exclude:
10
+ - rvm: 1.9.3
11
+ jdk: openjdk7
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in observed.gemspec
4
+ gemspec
5
+
6
+ gem 'coveralls', require: false, group: :test
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 GREE, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # [Observed](https://github.com/gree/observed)
2
+
3
+ A polling framework
4
+
5
+ [Observed](https://github.com/gree/observed) is a framework for polling various applications/middlewares/services running locally or on remote servers like
6
+ ones in your production environment.
7
+ It is designed with extensibility in mind.
8
+
9
+ -----
10
+
11
+ Observed polls services, optionally transforms the results, and then redirects the results to another services.
12
+ Observed is open for extension which means that it is extensible via plugins to support add more services and transformations.
13
+
14
+ To be clear, you can use Observed to:
15
+
16
+ 1. poll something,
17
+ 2. optionally transform the result,
18
+ 3. pass the result to another services or trigger something
19
+
20
+ All the three things mentioned above can be extended via plugins and configured via configuration files.
21
+
22
+ There are known plugins for:
23
+
24
+ - Polling HTTP-based services to detect failures and performance degradation
25
+ - Sending observed data to Fluentd
26
+ - (More to come)
27
+
28
+ Observed has has a very small code-base (only a few hundreds of lines) and it should not be too hard to understand the
29
+ code and develop plugins.
30
+
31
+ Observed's extensible design through plugins is inspired by other Ruby products like Fluentd,
32
+ and having knowledge of other Ruby products may help understanding Observed.
33
+ (But remember that Observed is yet a highly ambitioned and experimental framework. Observed's code has more space to
34
+ improve than other great Ruby products.)
35
+
36
+ Observed is (and its plugins should be) stateless.
37
+ Specially for Observed, this means that it should work similarly when it is ran as a daemon or a _oneshot_ application like
38
+ a regular cron job as states are stored somewhere outside of the application instance.
39
+
40
+ Observed is intended to work on Ruby 1.9.3 but should work on Ruby 2.0+ too.
41
+
42
+ ## What it is not
43
+
44
+ Observed is:
45
+
46
+ - Not a framework for creating Web-based polls which are voted. It's all about [polling (computer science)](http://en.wikipedia.org/wiki/Polling_\(computer_science\))
47
+ - Not a monitoring and reporting tool like Ganglia, New Relic, or etc.
48
+ But Observed can be used to gather simple metrics via its plugins, and it can pass those metrics to an another tool to
49
+ achieve any serious monitoring or reporting.
50
+ - Not a log collector like Fluentd.
51
+ Observed can be used to emit event logs to the log collector of your choice, but it does not replace or act like that.
52
+ - Not a [job scheduler](http://en.wikipedia.org/wiki/Job_scheduler) like cron, though it can be integrated to those schedulers to make them trigger Observed to do the
53
+ job.
54
+
55
+ ## Similar products
56
+
57
+ - [vacuumetrix](https://github.com/99designs/vacuumetrix) gets metrics from various sources and puts those to various
58
+ outputs like Graphite, Ganglia, etc.
59
+ On the other hand, Observed scope itself to be used just for `polling` and also it outputs to not only monitoring
60
+ systems but any system.
61
+ - [metrics-sampler](https://github.com/dimovelev/metrics-sampler) is a java program which queries metrics from various
62
+ sources and sends them to outputs like the console or Graphite. It supports inputs such as JMX, JDBC, apache-status,
63
+ Oracle NoSQL, Redis, webmethods, or regular process which is runnable via the command-line and is able to communiate
64
+ via standard input/output.
65
+
66
+ ## Installation
67
+
68
+ Add this line to your application's Gemfile:
69
+
70
+ gem 'observed'
71
+
72
+ And then execute:
73
+
74
+ $ bundle
75
+
76
+ Or install it yourself as:
77
+
78
+ $ gem install observed
79
+
80
+ Or `git clone` the sources and install by using rake:
81
+
82
+ $ rake install
83
+
84
+ ## Usage
85
+
86
+ Just for the purpose of illustration, _let Observed observe and report the healthiness of Google_.
87
+
88
+ Observed itself is just a framework and doesn't support any service by default.
89
+ Now, just for example, let's assume that we want Observed to poll our HTTP-based webs service and report the result and
90
+ show average response time.
91
+ We start with installing some observed plugins:
92
+
93
+ $ gem install observed
94
+ $ gem install observed-clockwork
95
+ $ gem install observed-http
96
+
97
+ In this case, we use observed-clockwork to trigger polls through [Clockwork](https://github.com/tomykaira/clockwork).
98
+ observed-clockwork is a library intended to use in Clockwork's configuration
99
+ file. Clockwork is a scheduler process made with Ruby, which is intended to replace cron.
100
+ Note that we can just use cron which is supported via observed-cron plugin(or even without the plugin, it is breeze to use
101
+ Observed with cron) but we proceed with Clockwork just for example.
102
+
103
+ With `clockwork.rb` like:
104
+
105
+ ```ruby
106
+ require 'pathname'
107
+
108
+ require 'clockwork'
109
+ require 'observed/clockwork'
110
+
111
+ include Clockwork
112
+
113
+ # Below two lines are specific to Observed's Clockwork support.
114
+ # Others lines are just standard `clockwork.rb`
115
+ include Observed::Clockwork
116
+
117
+ the_dir = Pathname.new(File.dirname(__FILE__))
118
+
119
+ register_observed_handler :config_file => the_dir + 'observed.rb'
120
+
121
+ every(10.seconds, 'google.health')
122
+ ```
123
+
124
+ With `observed.rb` like:
125
+
126
+ ```ruby
127
+ require 'observed/http'
128
+
129
+ observe 'google.health', via: 'http', with: {
130
+ method: 'get',
131
+ url: 'http://www.google.co.jp/'
132
+ }
133
+
134
+ report /google.health/, via: 'stdout', with: {
135
+ format: -> tag, time, data {
136
+ case data[:status]
137
+ when :success
138
+ 'Google is healthy! (^o^)'
139
+ else
140
+ 'Google is unhealthy! (;_;)'
141
+ end
142
+ }
143
+ }
144
+ ```
145
+
146
+ As you see, `observed.conf` is just a Ruby source to describe Observed's configuration.
147
+ You can rely on Ruby's language features, gems, or etc.
148
+
149
+ We have finished configuring Observed.
150
+
151
+ Now, run:
152
+
153
+ ```
154
+ $ clockwork clockwork.rb
155
+
156
+ I, [2013-11-08T23:39:53.999484 #44285] INFO -- : Starting clock for 1 events: [ google.health ]
157
+ I, [2013-11-08T23:39:53.999555 #44285] INFO -- : Triggering 'google.health'
158
+ Google is healthy! (^o^)
159
+ Google is healthy! (^o^)
160
+ Google is healthy! (^o^)
161
+ ...
162
+ ```
163
+
164
+ You did it!
165
+ You just saw that Google's healthiness is printed to the standard output every 10 seconds.
166
+ In other words, you did observed Google's healthiness with easily with Observed.
167
+
168
+ The example described here is fairly simple and would look useless at a glance, but remember that Observed is just a
169
+ framework.
170
+ If you want to monitor performances or get statistics on performance on your service, you can redirect the results to
171
+ Fluentd, Ganglia or else and take advantages of their rich features and plugins.
172
+ We like not reinventing the wheel and it is encouraged to use Observed for just to poll something and then emit the
173
+ result to other services. Things like monitoring, watching, alerting can be done there.
174
+
175
+ ## Documentation
176
+
177
+ Observed is documented with [YARD](https://github.com/lsegal/yard).
178
+ The documentation is not currently hosted on any server and we have to build the document before reading it.
179
+
180
+ To generate the document, install YARD:
181
+
182
+ ```
183
+ $ gem install yard
184
+ ```
185
+
186
+ And then run `yardoc` like:
187
+
188
+ ```
189
+ $ yardoc 'lib/**/*.rb'
190
+ ```
191
+
192
+ Open the document:
193
+
194
+ ```
195
+ $ open doc/index.html
196
+ ```
197
+
198
+ ## Contributing
199
+
200
+ 1. [Fork it](https://github.com/gree/observed)
201
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
202
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
203
+ 4. Push to the branch (`git push origin my-new-feature`)
204
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ task :default => :spec
4
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'observed'
4
+ gem 'observed-clockwork'
5
+ gem 'observed-http'
@@ -0,0 +1,16 @@
1
+ require 'pathname'
2
+
3
+ require 'clockwork'
4
+ require 'observed/clockwork'
5
+
6
+ include Clockwork
7
+
8
+ # Below two lines are specific to Observed's Clockwork support.
9
+ # Others lines are just standard `clockwork.rb`
10
+ include Observed::Clockwork
11
+
12
+ the_dir = Pathname.new(File.dirname(__FILE__))
13
+
14
+ register_observed_handler :config_file => the_dir + 'observed.rb'
15
+
16
+ every(10.seconds, 'google.health')
@@ -0,0 +1,17 @@
1
+ require 'observed/http'
2
+
3
+ observe 'google.health', via: 'http', with: {
4
+ method: 'get',
5
+ url: 'http://www.google.co.jp/'
6
+ }
7
+
8
+ report /google.health/, via: 'stdout', with: {
9
+ format: -> tag, time, data {
10
+ case data[:status]
11
+ when :success
12
+ 'Google is healthy! (^o^)'
13
+ else
14
+ 'Google is unhealthy! (;_;)'
15
+ end
16
+ }
17
+ }
@@ -0,0 +1,10 @@
1
+ class Test < Observed::Observer
2
+ plugin_name 'test'
3
+ def observe
4
+ system.report(tag, {foo:1})
5
+ end
6
+ end
7
+
8
+ observe 'foo', via: 'test'
9
+
10
+ report /foo/, via: 'stdout'
@@ -0,0 +1,11 @@
1
+ #!/bin/env/ruby
2
+
3
+ require 'observed'
4
+ require 'observed/application/oneshot'
5
+
6
+ begin
7
+ Observed::Application::Oneshot.from_argv(ARGV).run
8
+ rescue Observed::Application::Oneshot::InvalidArgumentError => e
9
+ $stderr.puts 'Missing the path to a Observed config file'
10
+ $stderr.puts 'Usage: observed-oneshot [-d|--debug] [-l LOG_FILE|--log_file LOG_FILE] <observed.rb>'
11
+ end
@@ -0,0 +1,24 @@
1
+ Feature: Be testable in a single command
2
+
3
+ In order to try Observed to see the basic usage usage of it,
4
+ I want to write a config file and test it by running Observed in a single command
5
+
6
+ Scenario: Create a .rb file containing Observed configuration and run it with the observed-oneshot command
7
+ Given a file named "test.rb" with:
8
+ """
9
+ class Test < Observed::Observer
10
+ plugin_name 'test'
11
+ def observe
12
+ system.report(tag, {foo:1})
13
+ end
14
+ end
15
+
16
+ observe 'foo', via: 'test'
17
+
18
+ report /foo/, via: 'stdout'
19
+ """
20
+ When I run `observed-oneshot -d test.rb`
21
+ Then the output should contain:
22
+ """
23
+ foo {:foo=>1}
24
+ """
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'aruba/cucumber'
3
+
4
+ World(Aruba::Api)
5
+
6
+ Before do
7
+ @aruba_timeout_seconds = 120
8
+ end
@@ -0,0 +1,32 @@
1
+ Feature: Be testable in a single Ruby source
2
+
3
+ In order to try Observed to see the basic usage usage of it,
4
+ I want to configure and run Observed in just a single Ruby source file
5
+
6
+ Scenario: Create a .rb file containing Observed code and run it with the ruby command
7
+ Given a file named "test.rb" with:
8
+ """
9
+ require 'observed'
10
+
11
+ include Observed
12
+
13
+ class Test < Observed::Observer
14
+ plugin_name 'test'
15
+ def observe
16
+ system.report(tag, {foo:1})
17
+ end
18
+ end
19
+
20
+ observe 'foo', via: 'test'
21
+
22
+ run 'foo'
23
+
24
+ report /foo/, via: 'stdout'
25
+
26
+ run 'foo'
27
+ """
28
+ When I run `ruby test.rb`
29
+ Then the output should contain:
30
+ """
31
+ foo {:foo=>1}
32
+ """
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in observed-clockwork.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 GREE, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # observed-clockwork
2
+
3
+ observed-clockwork is an integration of Observed and Clockwork.
4
+ In the integration, we can define jobs in Observed and schedule those to run by Clockwork.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'observed-clockwork'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install observed-clockwork
19
+
20
+ ## Usage
21
+
22
+ ### With Bundler
23
+
24
+ $ bundle install
25
+ $ bundle exec clockwork examples/clockwork/clockwork.rb
26
+
27
+ Or with daemonizing:
28
+
29
+ $ bundle install (Note that we need to add the dependency to 'daemons' gem in our Gemfile or gemspec)
30
+ $ bundle exec clockworkd -c examples/clockwork/clockwork.rb -l start
31
+ $ tail -f tmp/clockworkd.clockwork.output
32
+ $ bundle exec clockworkd -c examples/clockwork/clockwork.rb -l stop
33
+
34
+ ### Without Bundler
35
+
36
+ $ gem install observed-clockwork
37
+ $ clockwork clockwork.rb
38
+
39
+ Or with daemonizing:
40
+
41
+ $ gem install observed-clockwork
42
+ $ gem install daemons
43
+ $ clockworkd -c examples/clockwork/clockwork.rb -l start
44
+ $ tail -f tmp/clockworkd.clockwork.output
45
+ $ clockworkd -c examples/clockwork/clockwork.rb -l stop
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'clockwork' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('clockwork', 'clockwork')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'clockworkd' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('clockwork', 'clockworkd')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'observed-clockwork' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('observed-clockwork', 'observed-clockwork')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,9 @@
1
+ require 'clockwork'
2
+ require 'observed/clockwork'
3
+
4
+ include Clockwork
5
+ include Observed::Clockwork
6
+
7
+ register_observed_handler :config_file => File.dirname(__FILE__) + '/observed.conf'
8
+
9
+ every(10.seconds, 'foo_1')
@@ -0,0 +1,19 @@
1
+ module OneshotSpec
2
+ class FooPlugin < Observed::Observer
3
+
4
+ plugin_name 'foo'
5
+
6
+ default timeout_in_milliseconds: 5000
7
+ default number_of_trials: 10
8
+
9
+ def observe
10
+ sleep_duration = rand / 20
11
+ sleep sleep_duration
12
+ system.report(tag, "Foo #{sleep_duration}")
13
+ end
14
+
15
+ def logger
16
+ @logger ||= Logger.new(STDOUT)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ require 'observed/builtin_plugins'
2
+ require_relative 'foo_plugin'
3
+
4
+ observe 'foo_1', via: 'foo'
5
+
6
+ report /foo_1/, via: 'stdout'