homeq 1.1.4

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 (63) hide show
  1. data/CHANGELOG +103 -0
  2. data/COPYING +348 -0
  3. data/README.rdoc +64 -0
  4. data/Rakefile +131 -0
  5. data/bin/hq +6 -0
  6. data/config/boot.rb +224 -0
  7. data/config/databases/frontbase.yml +28 -0
  8. data/config/databases/mysql.yml +54 -0
  9. data/config/databases/oracle.yml +39 -0
  10. data/config/databases/postgresql.yml +48 -0
  11. data/config/databases/sqlite2.yml +16 -0
  12. data/config/databases/sqlite3.yml +19 -0
  13. data/config/environment.rb +20 -0
  14. data/config/environments/development.cfg +35 -0
  15. data/config/environments/production.cfg +35 -0
  16. data/config/environments/test.cfg +35 -0
  17. data/config/generators/job/templates/job.rb.erb +20 -0
  18. data/config/generators/message/templates/messages/MESSAGE.proto.erb +12 -0
  19. data/config/generators/model/templates/models/MODEL.rb.erb +3 -0
  20. data/config/generators/service/templates/services/SERVICE.rb.erb +43 -0
  21. data/config/homeq.cfg +35 -0
  22. data/extras/consumer.rb +85 -0
  23. data/extras/homeq.cfg +49 -0
  24. data/extras/hqd.rb +33 -0
  25. data/extras/producer.rb +79 -0
  26. data/extras/simple_consumer.rb +53 -0
  27. data/lib/homeq/base/base.rb +44 -0
  28. data/lib/homeq/base/commando.rb +81 -0
  29. data/lib/homeq/base/config.rb +99 -0
  30. data/lib/homeq/base/exception.rb +48 -0
  31. data/lib/homeq/base/histogram.rb +141 -0
  32. data/lib/homeq/base/logger.rb +185 -0
  33. data/lib/homeq/base/ohash.rb +297 -0
  34. data/lib/homeq/base/options.rb +171 -0
  35. data/lib/homeq/base/poolable.rb +100 -0
  36. data/lib/homeq/base/system.rb +446 -0
  37. data/lib/homeq/cli.rb +35 -0
  38. data/lib/homeq/cp/commands.rb +71 -0
  39. data/lib/homeq/cp/connection.rb +97 -0
  40. data/lib/homeq/cp/cp.rb +30 -0
  41. data/lib/homeq/cp/server.rb +105 -0
  42. data/lib/homeq/sobs/client.rb +119 -0
  43. data/lib/homeq/sobs/connection.rb +635 -0
  44. data/lib/homeq/sobs/foreman.rb +237 -0
  45. data/lib/homeq/sobs/job.rb +66 -0
  46. data/lib/homeq/sobs/message.rb +49 -0
  47. data/lib/homeq/sobs/queue.rb +224 -0
  48. data/lib/homeq/sobs/sender.rb +150 -0
  49. data/lib/homeq/sobs/server.rb +654 -0
  50. data/lib/homeq/sobs/sobs.rb +45 -0
  51. data/lib/homeq/sobs/topology.rb +111 -0
  52. data/lib/homeq.rb +106 -0
  53. data/lib/tasks/Rakefile +49 -0
  54. data/lib/tasks/database.rake +387 -0
  55. data/lib/tasks/gem.rake +9 -0
  56. data/lib/tasks/generate.rake +192 -0
  57. data/lib/tasks/hq.rake +171 -0
  58. data/lib/tasks/testing.rake +95 -0
  59. data/lib/tasks/utility.rb +17 -0
  60. data/script/console.rb +45 -0
  61. data/script/generate +7 -0
  62. data/test/unittest.rb +51 -0
  63. metadata +222 -0
@@ -0,0 +1,150 @@
1
+ #############################################################################
2
+ #
3
+ # $Id: job.rb 19 2008-08-29 01:11:57Z colin $
4
+ #
5
+ # Author:: Colin Steele (colin@colinsteele.org)
6
+ # Homepage::
7
+ #
8
+ # TODO: info
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2008 by Colin Steele. All Rights Reserved.
13
+ # colin@colinsteele.org
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #############################################################################
26
+
27
+ module HomeQ
28
+
29
+ module SOBS
30
+
31
+ module Sender
32
+
33
+ def book_it(msg_type)
34
+ @snd_stats[msg_type] ||= 0
35
+ @snd_stats[msg_type] += 1
36
+ end
37
+
38
+ def hello
39
+ book_it(:hello)
40
+ v = HomeQ::SOBS::PROTOCOL_VERSION
41
+ send_to_peer "hello #{v}\r\n"
42
+ end
43
+
44
+ def subscribe
45
+ book_it(:subscribe)
46
+ send_to_peer "subscribe\r\n"
47
+ end
48
+
49
+ def unsubscribe
50
+ book_it(:unsubscribe)
51
+ send_to_peer "unsubscribe\r\n"
52
+ end
53
+
54
+ def reserve(timeout = nil)
55
+ if timeout != nil
56
+ book_it(:reserve_with_timeout)
57
+ send_to_peer "reserve-with-timeout #{timeout}\r\n"
58
+ else
59
+ book_it(:reserve)
60
+ send_to_peer "reserve\r\n"
61
+ end
62
+ end
63
+
64
+ def put(args)
65
+ book_it(:put)
66
+ app_data = args[:app_data]
67
+ body = args[:body]
68
+ pri = args[:priority] || 0
69
+ delay = args[:delay] || 0
70
+ ttr = args[:ttr] || 30
71
+ raise ArgumentError.new('Body cannot be nil') unless body
72
+ raise ArgumentError.new('App data cannot be nil') unless app_data
73
+ send_to_peer "put #{pri} #{delay} #{ttr} #{app_data} #{body.length}\r\n#{body}\r\n"
74
+ end
75
+
76
+ def delete(job_id)
77
+ book_it(:delete)
78
+ send_to_peer "delete #{job_id}\r\n"
79
+ end
80
+
81
+ def bury(job_id, pri)
82
+ book_it(:bury)
83
+ send_to_peer "bury #{job_id} #{pri}\r\n"
84
+ end
85
+
86
+ def kick(bound)
87
+ book_it(:kick)
88
+ send_to_peer "kick #{bound}\r\n"
89
+ end
90
+
91
+ def stats_job(job_id)
92
+ book_it(:stats_job)
93
+ send_to_peer "stats-job #{job_id}\r\n"
94
+ end
95
+
96
+ def stats
97
+ book_it(:stats)
98
+ send_to_peer "stats\r\n"
99
+ end
100
+
101
+ def release(job_id, pri, delay)
102
+ book_it(:release)
103
+ send_to_peer "release #{job_id} #{pri} #{delay}\r\n"
104
+ end
105
+
106
+ def inserted(job_id, app_data=0)
107
+ book_it(:inserted)
108
+ send_to_peer "inserted #{job_id} #{app_data}\r\n"
109
+ end
110
+
111
+ def reserved(job_id, payload)
112
+ book_it(:reserved)
113
+ send_to_peer "reserved #{job_id} #{payload.length}\r\n#{payload}\r\n"
114
+ end
115
+
116
+ def deadline_soon(job_id)
117
+ book_it(:deadline_soon)
118
+ send_to_peer "deadline_soon #{job_id}\r\n"
119
+ end
120
+
121
+ def not_found(job_id)
122
+ book_it(:not_found)
123
+ send_to_peer "not_found #{job_id}\r\n"
124
+ end
125
+
126
+ def released(job_id)
127
+ book_it(:released)
128
+ send_to_peer "released #{job_id}\r\n"
129
+ end
130
+
131
+ def deleted(job_id)
132
+ book_it(:deleted)
133
+ send_to_peer "deleted #{job_id}\r\n"
134
+ end
135
+
136
+ def buried(job_id)
137
+ book_it(:buried)
138
+ send_to_peer "buried #{job_id}\r\n"
139
+ end
140
+
141
+ def kicked(jobs_kicked)
142
+ book_it(:kicked)
143
+ send_to_peer "kicked #{jobs_kicked}\r\n"
144
+ end
145
+
146
+ end # Sender
147
+
148
+ end # SOBS
149
+
150
+ end # HomeQ