backgroundrb-rails3 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.
Files changed (126) hide show
  1. data/.autotest +17 -0
  2. data/ChangeLog +50 -0
  3. data/Gemfile +11 -0
  4. data/LICENSE +4 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README +22 -0
  7. data/Rakefile +128 -0
  8. data/TODO.org +5 -0
  9. data/app/controller/backgroundrb_status_controller.rb +6 -0
  10. data/backgroundrb-rails3.gemspec +219 -0
  11. data/config/backgroundrb.yml +11 -0
  12. data/doc/Rakefile +5 -0
  13. data/doc/config.yaml +2 -0
  14. data/doc/content/advanced/advanced.txt +76 -0
  15. data/doc/content/advanced/advanced.yaml +4 -0
  16. data/doc/content/bugs/bugs.txt +20 -0
  17. data/doc/content/bugs/bugs.yaml +5 -0
  18. data/doc/content/community/community.txt +36 -0
  19. data/doc/content/community/community.yaml +5 -0
  20. data/doc/content/content.txt +168 -0
  21. data/doc/content/content.yaml +5 -0
  22. data/doc/content/faq/faq.txt +41 -0
  23. data/doc/content/faq/faq.yaml +5 -0
  24. data/doc/content/rails/rails.txt +182 -0
  25. data/doc/content/rails/rails.yaml +5 -0
  26. data/doc/content/scheduling/scheduling.txt +166 -0
  27. data/doc/content/scheduling/scheduling.yaml +5 -0
  28. data/doc/content/workers/workers.txt +178 -0
  29. data/doc/content/workers/workers.yaml +5 -0
  30. data/doc/layouts/default/default.erb +56 -0
  31. data/doc/layouts/default/default.yaml +4 -0
  32. data/doc/lib/default.rb +7 -0
  33. data/doc/output/Assets/BG-Ad-Top.png +0 -0
  34. data/doc/output/Assets/BG-Body.png +0 -0
  35. data/doc/output/Assets/BG-Feed.png +0 -0
  36. data/doc/output/Assets/BG-Menu-Hover.png +0 -0
  37. data/doc/output/Assets/BG-Menu.png +0 -0
  38. data/doc/output/Assets/BG-Sidebar-Bottom.png +0 -0
  39. data/doc/output/Assets/Button-Feed.png +0 -0
  40. data/doc/output/images/bg-ad-top.png +0 -0
  41. data/doc/output/images/bg-body.png +0 -0
  42. data/doc/output/images/bg-feed.gif +0 -0
  43. data/doc/output/images/bg-footer.jpg +0 -0
  44. data/doc/output/images/bg-header.jpg +0 -0
  45. data/doc/output/images/bg-menu-hover.png +0 -0
  46. data/doc/output/images/bg-menu.png +0 -0
  47. data/doc/output/images/bg-sidebar-bottom.gif +0 -0
  48. data/doc/output/images/button-feed.png +0 -0
  49. data/doc/output/images/icon-comment.png +0 -0
  50. data/doc/output/images/more_icon.gif +0 -0
  51. data/doc/output/style.css +299 -0
  52. data/doc/page_defaults.yaml +13 -0
  53. data/doc/tasks/default.rake +3 -0
  54. data/doc/templates/default/default.txt +1 -0
  55. data/doc/templates/default/default.yaml +4 -0
  56. data/examples/backgroundrb.yml +25 -0
  57. data/examples/foo_controller.rb +48 -0
  58. data/examples/god_worker.rb +7 -0
  59. data/examples/worker_tests/god_worker_test.rb +8 -0
  60. data/examples/workers/error_worker.rb +17 -0
  61. data/examples/workers/foo_worker.rb +38 -0
  62. data/examples/workers/god_worker.rb +7 -0
  63. data/examples/workers/model_worker.rb +13 -0
  64. data/examples/workers/renewal_worker.rb +11 -0
  65. data/examples/workers/rss_worker.rb +26 -0
  66. data/examples/workers/server_worker.rb +31 -0
  67. data/examples/workers/world_worker.rb +12 -0
  68. data/examples/workers/xmpp_worker.rb +7 -0
  69. data/init.rb +7 -0
  70. data/install.rb +1 -0
  71. data/know_issues.org +5 -0
  72. data/lib/backgroundrb.rb +1 -0
  73. data/lib/backgroundrb/bdrb_client_helper.rb +8 -0
  74. data/lib/backgroundrb/bdrb_cluster_connection.rb +156 -0
  75. data/lib/backgroundrb/bdrb_config.rb +43 -0
  76. data/lib/backgroundrb/bdrb_conn_error.rb +29 -0
  77. data/lib/backgroundrb/bdrb_connection.rb +179 -0
  78. data/lib/backgroundrb/bdrb_job_queue.rb +79 -0
  79. data/lib/backgroundrb/bdrb_result.rb +19 -0
  80. data/lib/backgroundrb/bdrb_start_stop.rb +146 -0
  81. data/lib/backgroundrb/rails_worker_proxy.rb +181 -0
  82. data/lib/backgroundrb/railtie.rb +48 -0
  83. data/lib/generators/backgroundrb/bdrb_migration/USAGE +12 -0
  84. data/lib/generators/backgroundrb/bdrb_migration/bdrb_migration_generator.rb +15 -0
  85. data/lib/generators/backgroundrb/bdrb_migration/templates/migration.rb +27 -0
  86. data/lib/generators/backgroundrb/worker/USAGE +16 -0
  87. data/lib/generators/backgroundrb/worker/templates/unit_test.rb +12 -0
  88. data/lib/generators/backgroundrb/worker/templates/worker.rb +7 -0
  89. data/lib/generators/backgroundrb/worker/worker_generator.rb +14 -0
  90. data/lib/tasks/backgroundrb_tasks.rake +103 -0
  91. data/release_notes.org +48 -0
  92. data/release_points.org +46 -0
  93. data/script/backgroundrb +52 -0
  94. data/script/bdrb_test_helper.rb +99 -0
  95. data/script/load_worker_env.rb +31 -0
  96. data/script/monitrc +25 -0
  97. data/server/backgroundrb_server.rb +12 -0
  98. data/server/lib/bdrb_result_storage.rb +62 -0
  99. data/server/lib/bdrb_server_helper.rb +24 -0
  100. data/server/lib/bdrb_thread_pool.rb +127 -0
  101. data/server/lib/cron_trigger.rb +197 -0
  102. data/server/lib/invalid_dump_error.rb +4 -0
  103. data/server/lib/log_worker.rb +25 -0
  104. data/server/lib/master_proxy.rb +140 -0
  105. data/server/lib/master_worker.rb +187 -0
  106. data/server/lib/meta_worker.rb +432 -0
  107. data/server/lib/trigger.rb +34 -0
  108. data/test/bdrb_client_test_helper.rb +5 -0
  109. data/test/bdrb_test_helper.rb +35 -0
  110. data/test/client/backgroundrb.yml +17 -0
  111. data/test/client/test_bdrb_client_helper.rb +13 -0
  112. data/test/client/test_bdrb_cluster_connection.rb +162 -0
  113. data/test/client/test_bdrb_config.rb +20 -0
  114. data/test/client/test_bdrb_connection.rb +29 -0
  115. data/test/client/test_bdrb_job_queue.rb +63 -0
  116. data/test/client/test_worker_proxy.rb +130 -0
  117. data/test/server/test_cron_trigger.rb +281 -0
  118. data/test/server/test_master_proxy.rb +54 -0
  119. data/test/server/test_master_worker.rb +157 -0
  120. data/test/server/test_meta_worker.rb +281 -0
  121. data/test/server/test_result_storage.rb +14 -0
  122. data/test/socket_mocker.rb +34 -0
  123. data/test/workers/bar_worker.rb +10 -0
  124. data/test/workers/foo_worker.rb +10 -0
  125. data/uninstall.rb +1 -0
  126. metadata +345 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,299 @@
1
+ /*
2
+ Theme Name: Ginger Ninja! v2
3
+ Description: The new Ginger Ninja! theme.
4
+ Version: 1.0
5
+ Author: Donny Burnside
6
+ Author URI: http://www.ginger-ninja.net/
7
+ */
8
+
9
+ /* Generic Styling */
10
+
11
+ body {
12
+ background:url(images/bg-body.png) repeat-x top center #E8F7F9;
13
+ font-family:"Trebuchet MS" Arial, Helvetica, sans-serif;
14
+ font-size:62.5%; /* Sets default font size to 10px */
15
+ color:#222222;
16
+ }
17
+
18
+ * {
19
+ margin:0;
20
+ padding:0;
21
+ }
22
+
23
+ img {
24
+ border:0;
25
+ }
26
+
27
+ a {
28
+ text-decoration:none;
29
+ color:#B4C835;
30
+ }
31
+
32
+ p {
33
+ padding:5px 10px;
34
+ text-align:justify;
35
+ line-height:1.75em;
36
+ margin-bottom: 5px;
37
+ }
38
+
39
+ code {
40
+ font-size: 120%;
41
+ margin: 0;
42
+ padding: 0;
43
+ font-size: 120%;
44
+ background-color: #eceda4;
45
+ }
46
+
47
+ pre.inline {
48
+ margin: 0;
49
+ padding: 0;
50
+ font-size: 120%;
51
+ display: inline;
52
+ background-color: #eceda4;
53
+ }
54
+
55
+ pre.boxed {
56
+ margin: 7px 0 7px 20px;
57
+ padding: 0 0 0 10px;
58
+ font-size: 120%;
59
+ /* font-size: 10px; */
60
+ border: 1px solid #003b07;
61
+ color: #475348;
62
+ line-height: 1.6;
63
+ }
64
+
65
+ pre.multiline {
66
+ margin: 7px 0 7px 20px;
67
+ padding: 3px 0 3px 10px;
68
+ font-size: 120%;
69
+ border: 1px solid #003b07;
70
+ color: #475348;
71
+ line-height: 1.6;
72
+ }
73
+
74
+ span.inline {
75
+ margin: 0;
76
+ padding: 0;
77
+ font-size: 100%;
78
+ display: inline;
79
+ background-color: #eceda4;
80
+ }
81
+
82
+ p.boxed {
83
+ margin: 7px 0 7px 20px;
84
+ padding: 0 0 0 10px;
85
+ font-size: 100%;
86
+ /* font-size: 10px; */
87
+ border: 1px solid #003b07;
88
+ color: #475348;
89
+ line-height: 1.6;
90
+ }
91
+
92
+ p.multiline {
93
+ margin: 7px 0 7px 20px;
94
+ padding: 3px 0 3px 10px;
95
+ font-size: 100%;
96
+ border: 1px solid #003b07;
97
+ color: #475348;
98
+ line-height: 1.6;
99
+ }
100
+
101
+ a:hover {
102
+ text-decoration:none;
103
+ color:#6CC7DC;
104
+ }
105
+
106
+ /* Structure */
107
+
108
+ #wrapper {
109
+ margin:0 auto;
110
+ width:700px;
111
+ background:#ffffff;
112
+ font-size:1.20em;
113
+
114
+ }
115
+ #header {
116
+ height:140px;
117
+ background:url(images/bg-header.jpg) no-repeat;
118
+ }
119
+ #menu {
120
+ height:35px;
121
+ line-height:35px;
122
+ background:url(images/bg-menu.png) repeat-x;
123
+ padding:0 10px;
124
+ }
125
+ #sidebar {
126
+ float:right;
127
+ width:145px;
128
+ background:#efefef;
129
+ margin-right:10px;
130
+ }
131
+ #content {
132
+
133
+ width:545px;
134
+ min-height:400px;
135
+ font-family:"verdana" Arial, Helvetica, sans-serif;
136
+ color:#222222;
137
+ background-color: #FFF;
138
+ }
139
+ #footer {
140
+ clear:both;
141
+ height:100px;
142
+ background:url(images/bg-footer.jpg) no-repeat;
143
+ }
144
+
145
+ /* Entries */
146
+
147
+ .entry {
148
+ padding:5px 10px;
149
+ text-align:justify;
150
+ line-height:1.75em;
151
+ margin-bottom: 5px;
152
+ }
153
+
154
+ .entry-title {
155
+ /* font-family: "Trebuchet MS" sans-serif; */
156
+ font-size:1.2em;
157
+ font-variant: small-caps;
158
+ color: #197e25;
159
+ font-weight:bold;
160
+ margin-bottom: 10px;
161
+ /* letter-spacing:-1px; */
162
+ }
163
+
164
+ .sub-title {
165
+ font-weight:bold;
166
+ margin: 5px 0 5px 2px;
167
+ /* letter-spacing:-1px; */
168
+ }
169
+
170
+ .date {
171
+ font-size:0.9em;
172
+ color:#bbb;
173
+ cursor:default;
174
+ letter-spacing:1px;
175
+ }
176
+ .comments {
177
+ margin-top:-1em;
178
+ }
179
+ .comments a {
180
+ color:#6CC7DC;
181
+ background:url(images/icon-comment.png) no-repeat 0px 2px;
182
+ padding-left:20px;
183
+ padding-right:2px;
184
+ }
185
+ .comments a:hover {
186
+ color:#B4C835;
187
+ }
188
+
189
+ .content_list {
190
+ list-style-image: url(images/more_icon.gif);
191
+ padding: 2px 0 2px 20px;
192
+ margin: 2px 0 2px 20px;
193
+ line-height: 1.6;
194
+ }
195
+
196
+
197
+
198
+ /* Menu */
199
+
200
+ #menu ul {
201
+ list-style-type:none;
202
+ }
203
+ #menu li {
204
+ float:left;
205
+ }
206
+ #menu li a {
207
+ padding:0 15px;
208
+ display:block;
209
+ color:#ffffff;
210
+ margin-right:2px;
211
+ }
212
+ #menu li a:hover {
213
+ background:url(images/bg-menu-hover.png) no-repeat center center;
214
+ }
215
+
216
+ /* Sidebar */
217
+
218
+ #sidebar ul {
219
+ list-style-type:none;
220
+ margin-top:10px;
221
+ }
222
+ #sidebar li {
223
+
224
+ }
225
+ #sidebar li a {
226
+ display:block;
227
+ height:20px;
228
+ line-height:20px;
229
+ color:#222222;
230
+ padding-left:30px;
231
+ border-bottom:1px solid #dddddd;
232
+ }
233
+ #sidebar li a:hover {
234
+ background:#edebed;
235
+ color:#6CC4D8;
236
+ }
237
+ #sidebar-bottom {
238
+ height:20px;
239
+ background:url(images/bg-sidebar-bottom.gif) no-repeat top center;
240
+ }
241
+
242
+ /* Footer */
243
+
244
+ #footer-valid {
245
+ float:left;
246
+ padding-top:55px;
247
+ padding-left:20px;
248
+ cursor:default;
249
+ color:#ffffff;
250
+ }
251
+ #footer-valid a {
252
+ color:#ffffff;
253
+ text-decoration:none;
254
+ }
255
+ #footer-valid a:hover {
256
+ color:#ffffff;
257
+ text-decoration:underline;
258
+ }
259
+
260
+ /* Heading's */
261
+
262
+ h1 {
263
+ font-size:2.5em;
264
+ font-weight:normal;
265
+ cursor:default;
266
+ position:relative; top:50px; left:30px;
267
+ letter-spacing:1px;
268
+ color:#aaaaaa;
269
+ font-style:italic;
270
+ }
271
+
272
+ /* Feed */
273
+
274
+ #feed {
275
+ height:25px;
276
+ width:126px;
277
+ background:url(images/bg-feed.gif) no-repeat;
278
+ margin:0 auto;
279
+ padding-left:26px;
280
+ }
281
+ a.feed-button {
282
+ display:block;
283
+ width:100px;
284
+ height:25px;
285
+ background:url("images/button-feed.png") 0 0 no-repeat;
286
+ text-decoration: none;
287
+ }
288
+ a:hover.feed-button {
289
+ background-position:0 -25px;
290
+ }
291
+
292
+ /* Extra's */
293
+
294
+ #ad-top {
295
+ width:480px;
296
+ height:72px;
297
+ background:url(images/bg-ad-top.png) no-repeat;
298
+ padding:5px;
299
+ }
@@ -0,0 +1,13 @@
1
+ # This file contains the default values for all metafiles.
2
+ # Other metafiles can override the contents of this one.
3
+
4
+ # Built-in
5
+ custom_path: none
6
+ extension: "html"
7
+ filename: "index"
8
+ filters_post: []
9
+ filters_pre: []
10
+ is_draft: false
11
+ layout: "default"
12
+ skip_output: false
13
+ # Custom
@@ -0,0 +1,3 @@
1
+ task :example do
2
+ puts 'This is an example rake task in tasks/default.rake.'
3
+ end
@@ -0,0 +1 @@
1
+ Hi, I'm a new page!
@@ -0,0 +1,4 @@
1
+ # Built-in
2
+
3
+ # Custom
4
+ title: "A New Page"
@@ -0,0 +1,25 @@
1
+ # A Sample YAML configuration file
2
+ ---
3
+ :backgroundrb:
4
+ :ip: 0.0.0.0 #ip on which backgroundrb server is running
5
+ :port: 11006 #port on which backgroundrb server is running
6
+ :environment: production # rails environment loaded, defaults to development
7
+ :debug_log: true # whether to print debug logs to a seperate worker, defaults to true
8
+ :log: foreground # will print log messages to STDOUT, defaults to seperate log worker
9
+ :result_storage: memcache # store results in a mecache cluster, you also need to specify location of your memcache clusters in next section
10
+ :persistent_disabled: false # turn this off if your application doesn't use backgroundrb's persistent/enqueued tasks system
11
+ :persistent_delay: 10 # the time (seconds) between each time backgroundrb checks the database for enqueued tasks
12
+
13
+ :memcache: "10.0.0.1:11211,10.0.0.2:11211" #=> location of memcache clusters separated by comma
14
+
15
+ # following section is totally optional, and only useful if you are trying to cluster of backgroundrb server
16
+ # if you do not specify this section backgroundrb will assume that, from rails you are connecting to the
17
+ # backgroundrb server which has been specified in previous section
18
+ :client: "10.0.0.1:11006,10.0.0.2:11007"
19
+
20
+ # You specify your worker schedules here
21
+ :schedules:
22
+ :foo_worker: # worker name
23
+ :barbar: #worker method
24
+ :trigger_args: */5 * * * * * * #worker schedule
25
+
@@ -0,0 +1,48 @@
1
+ class FooController < ApplicationController
2
+ layout :choose_layout
3
+ def index
4
+ end
5
+
6
+ def mobile_action
7
+ #render :layout => "mobile"
8
+ end
9
+
10
+ def start_worker
11
+ MiddleMan.new_worker(:worker => :error_worker, :worker_key => :hello_world,:data => "wow_man")
12
+ render :text => "worker starterd"
13
+ end
14
+
15
+ def stop_worker
16
+ MiddleMan.worker(:error_worker,:hello_world).delete
17
+ render :text => "worker deleted"
18
+ end
19
+
20
+ def invoke_worker_method
21
+ worker_response = MiddleMan.worker(:hello_worker).say_hello(:arg => data)
22
+ render :text => worker_response
23
+ end
24
+
25
+ def renew
26
+ MiddleMan.worker(:hello_worker).async_load_policy(:arg => current_user.id)
27
+ render :text => "method invoked"
28
+ end
29
+
30
+ def query_all_workers
31
+ t_response = MiddleMan.query_all_workers
32
+ running_workers = t_response.map { |key,value| "#{key} = #{value}"}.join(',')
33
+ render :text => running_workers
34
+ end
35
+
36
+ def ask_result
37
+ t_result = MiddleMan.worker(:hello_worker).ask_result(cache_key)
38
+ end
39
+
40
+ private
41
+ def choose_layout
42
+ if action_name == 'mobile_action'
43
+ "mobile"
44
+ else
45
+ "foo"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ class GodWorker < BackgrounDRb::MetaWorker
2
+ set_worker_name :god_worker
3
+ def create(args = nil)
4
+ logger.info "hello world"
5
+ end
6
+ end
7
+
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__) + "/../bdrb_test_helper")
2
+ require "god_worker"
3
+
4
+ context "When god worker starts" do
5
+ setup do
6
+ god_worker = GodWorker.new
7
+ end
8
+ end