rservicebus 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/bin/rservicebus CHANGED
@@ -8,8 +8,7 @@ require 'rubygems'
8
8
  require 'rservicebus'
9
9
 
10
10
  def run_rservicebus()
11
- RServiceBus::Host.new()
12
- .run()
11
+ RServiceBus::Host.new().run()
13
12
  end
14
13
 
15
14
  run_rservicebus
data/lib/rservicebus.rb CHANGED
@@ -19,7 +19,6 @@ require "rservicebus/Message/Subscription"
19
19
 
20
20
  require "rservicebus/AppResource"
21
21
  require "rservicebus/AppResource/Redis"
22
- #require "rservicebus/AppResource/Mysql"
23
22
 
24
23
  require "rservicebus/SubscriptionManager"
25
24
  require "rservicebus/SubscriptionStorage"
@@ -0,0 +1,26 @@
1
+ module RServiceBus
2
+
3
+ require "FluidDb/Mysql"
4
+
5
+ #Implementation of an AppResource - Redis
6
+ class AppResource_FluidDbMysql<AppResource
7
+
8
+ @connection
9
+
10
+ def initialize( uri )
11
+ super(uri)
12
+ host = uri.host
13
+ database = uri.path.sub( "/", "" )
14
+
15
+
16
+ @connection = FluidDb::Mysql.new( uri )
17
+ puts "AppResource_Mysql. Connected to, " + uri.to_s
18
+ end
19
+
20
+ def getResource
21
+ return @connection
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,26 @@
1
+ module RServiceBus
2
+
3
+ require "FluidDb/Mysql2"
4
+
5
+ #Implementation ofF an AppResource - Redis
6
+ class AppResource_FluidDbMysql2<AppResource
7
+
8
+ @connection
9
+
10
+ def initialize( uri )
11
+ super(uri)
12
+ host = uri.host
13
+ database = uri.path.sub( "/", "" )
14
+
15
+
16
+ @connection = FluidDb::Mysql2.new( uri )
17
+ puts "AppResource_Mysql. Connected to, " + uri.to_s
18
+ end
19
+
20
+ def getResource
21
+ return @connection
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,26 @@
1
+ module RServiceBus
2
+
3
+ require "FluidDb/Pgsql"
4
+
5
+ #Implementation of an AppResource - Redis
6
+ class AppResource_FluidDbPgsql<AppResource
7
+
8
+ @connection
9
+
10
+ def initialize( uri )
11
+ super(uri)
12
+ host = uri.host
13
+ database = uri.path.sub( "/", "" )
14
+
15
+
16
+ @connection = FluidDb::Pgsql.new( uri )
17
+ puts "AppResource_Mysql. Connected to, " + uri.to_s
18
+ end
19
+
20
+ def getResource
21
+ return @connection
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -2,11 +2,12 @@ module RServiceBus
2
2
 
3
3
  #Marshals configuration information for an rservicebus host
4
4
  class Config
5
- attr_reader :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :verbose, :beanstalkHost, :queueTimeout, :statOutputCountdown
5
+ attr_reader :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :verbose, :beanstalkHost, :queueTimeout, :statOutputCountdown, :contractList, :libList
6
6
 
7
7
  @appName
8
8
  @messageEndpointMappings
9
9
  @handlerPathList
10
+ @contractList
10
11
 
11
12
  @localQueueName
12
13
  @errorQueueName
@@ -70,14 +71,12 @@ class Config
70
71
  # <path 1>;<path 2>
71
72
  def loadHandlerPathList()
72
73
  path = self.getValue( "MSGHANDLERPATH", "./MessageHandler" )
73
- handlerPathList = Array.new
74
+ @handlerPathList = Array.new
74
75
  path.split( ";" ).each do |path|
75
76
  path = path.strip.chomp( "/" )
76
- handlerPathList << path
77
+ @handlerPathList << path
77
78
  end
78
79
 
79
- @handlerPathList = handlerPathList
80
-
81
80
  return self
82
81
  end
83
82
 
@@ -93,10 +92,6 @@ class Config
93
92
  return self
94
93
  end
95
94
 
96
- def performRequire( path )
97
- require path
98
- end
99
-
100
95
  def ensureContractFileExists( path )
101
96
  if !( File.exists?( path ) ||
102
97
  File.exists?( "#{path}.rb" ) ) then
@@ -122,15 +117,44 @@ class Config
122
117
  if self.getValue( "CONTRACTS", "./Contract" ).nil? then
123
118
  return self
124
119
  end
120
+ @contractList = Array.new
125
121
 
126
122
  self.getValue( "CONTRACTS", "./Contract" ).split( ";" ).each do |path|
127
123
  log "Loading contracts from, #{path}"
128
124
  self.ensureContractFileExists( path )
129
- self.performRequire( path )
125
+ @contractList << path
130
126
  end
131
127
  return self
132
128
  end
133
129
 
130
+ #Marshals paths for lib
131
+ #
132
+ #Note. .rb extension is optional
133
+ #
134
+ #Expected format;
135
+ # /one/two/Contracts
136
+ def loadLibs()
137
+ @libList = Array.new
138
+
139
+ path = self.getValue( "LIB" )
140
+ path = "./lib" if path.nil? and File.exists?( "./lib" )
141
+ if path.nil? then
142
+ return self
143
+ end
144
+
145
+ path.split( ";" ).each do |path|
146
+ log "Loading libs from, #{path}"
147
+ if !File.exists?( path ) then
148
+ puts "Error while processing libs"
149
+ puts "*** path, #{path}, should point to a ruby file, with extention .rb, or"
150
+ puts "*** path, #{path}, should point to a directory than conatins ruby files, that have extention .rb"
151
+ abort()
152
+ end
153
+ @libList << path
154
+ end
155
+ return self
156
+ end
157
+
134
158
  def configureLogging()
135
159
  @verbose = !self.getValue( "VERBOSE", nil ).nil?
136
160
 
@@ -143,6 +167,34 @@ class Config
143
167
  return self
144
168
  end
145
169
 
170
+ #Marshals paths for working_dirs
171
+ #
172
+ #Note. trailing slashs will be stripped
173
+ #
174
+ #Expected format;
175
+ # <path 1>;<path 2>
176
+ def loadWorkingDirList()
177
+ pathList = self.getValue( "WORKING_DIR" )
178
+ return self if pathList.nil?
179
+
180
+ pathList.split( ";" ).each do |path|
181
+
182
+ path = path.strip.chomp( "/" )
183
+ if Dir.exists?( "#{path}/MessageHandler" ) then
184
+ @handlerPathList << "#{path}/MessageHandler"
185
+ end
186
+
187
+ if File.exists?( "#{path}/Contract.rb" ) then
188
+ @contractList << "#{path}/Contract.rb"
189
+ end
190
+
191
+ if File.exists?( "#{path}/lib" ) then
192
+ @libList << "#{path}/lib"
193
+ end
194
+ end
195
+
196
+ return self
197
+ end
146
198
 
147
199
  end
148
200
 
@@ -4,7 +4,7 @@ module RServiceBus
4
4
 
5
5
  #Configure AppResources for an rservicebus host
6
6
  class ConfigureAppResource
7
-
7
+
8
8
  def getResources( env )
9
9
  resources = Hash.new
10
10
 
@@ -17,7 +17,18 @@ module RServiceBus
17
17
  resources[k.sub( "RSB_", "" )] = AppResource_Redis.new( uri )
18
18
 
19
19
  when "mysql"
20
+ require "rservicebus/AppResource/Mysql"
20
21
  resources[k.sub( "RSB_", "" )] = AppResource_Mysql.new( uri )
22
+
23
+ when "fluiddbmysql"
24
+ require "rservicebus/AppResource/FluidDbMysql"
25
+ resources[k.sub( "RSB_", "" )] = AppResource_FluidDbMysql.new( uri )
26
+ when "fluiddbmysql2"
27
+ require "rservicebus/AppResource/FluidDbMysql2"
28
+ resources[k.sub( "RSB_", "" )] = AppResource_FluidDbMysql2.new( uri )
29
+ when "fluiddbpgsql"
30
+ require "rservicebus/AppResource/FluidDbPgsql"
31
+ resources[k.sub( "RSB_", "" )] = AppResource_FluidDbPgsql.new( uri )
21
32
  else
22
33
  abort("Scheme, #{uri.scheme}, not recognised when configuring app resource, #{k}=#{v}");
23
34
  end
@@ -80,6 +80,33 @@ class Host
80
80
  return self
81
81
  end
82
82
 
83
+
84
+ def loadContracts()
85
+ log "Load Contracts"
86
+
87
+ @config.contractList.each do |path|
88
+ require path
89
+ end
90
+
91
+ return self
92
+ end
93
+
94
+ def loadLibs()
95
+ log "Load Libs"
96
+
97
+ @config.libList.each do |path|
98
+ if Dir.exists?( path ) then
99
+ path = path.strip.chomp( "/" )
100
+ path = path + "/**/*.rb"
101
+ end
102
+ Dir.glob( path ).each do |path|
103
+ require path
104
+ end
105
+ end
106
+
107
+ return self
108
+ end
109
+
83
110
  def configureSubscriptions
84
111
  subscriptionStorage = SubscriptionStorage_Redis.new( @config.appName, "uri" )
85
112
  @subscriptionManager = SubscriptionManager.new( subscriptionStorage )
@@ -102,12 +129,16 @@ class Host
102
129
  .configureBeanstalk()
103
130
  .loadContracts()
104
131
  .loadMessageEndpointMappings()
105
- .loadHandlerPathList();
132
+ .loadHandlerPathList()
133
+ .loadLibs()
134
+ .loadWorkingDirList();
106
135
 
107
136
  self.configureStatistics()
108
137
  .configureAppResource()
109
138
  .connectToBeanstalk()
110
139
  .loadHandlers()
140
+ .loadContracts()
141
+ .loadLibs()
111
142
  .configureSubscriptions()
112
143
  .sendSubscriptions()
113
144
 
metadata CHANGED
@@ -1,34 +1,28 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rservicebus
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 12
9
- version: 0.0.12
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.13
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Guy Irvine
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-07-03 00:00:00 +12:00
18
- default_executable:
12
+ date: 2012-08-06 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: A Ruby interpretation of NServiceBus
22
15
  email: guy@guyirvine.com
23
- executables:
16
+ executables:
24
17
  - rservicebus
25
18
  - ReturnErroredMessagesToSourceQueue
26
19
  extensions: []
27
-
28
20
  extra_rdoc_files: []
29
-
30
- files:
21
+ files:
31
22
  - lib/rservicebus/Agent.rb
23
+ - lib/rservicebus/AppResource/FluidDbMysql.rb
24
+ - lib/rservicebus/AppResource/FluidDbMysql2.rb
25
+ - lib/rservicebus/AppResource/FluidDbPgsql.rb
32
26
  - lib/rservicebus/AppResource/Mysql.rb
33
27
  - lib/rservicebus/AppResource/Redis.rb
34
28
  - lib/rservicebus/AppResource.rb
@@ -52,35 +46,29 @@ files:
52
46
  - bin/rservicebus
53
47
  - LICENSE
54
48
  - README.md
55
- has_rdoc: true
56
49
  homepage: http://rubygems.org/gems/rservicebus
57
50
  licenses: []
58
-
59
51
  post_install_message:
60
52
  rdoc_options: []
61
-
62
- require_paths:
53
+ require_paths:
63
54
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- segments:
69
- - 0
70
- version: "0"
71
- required_rubygems_version: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
78
67
  requirements: []
79
-
80
68
  rubyforge_project:
81
- rubygems_version: 1.3.6
69
+ rubygems_version: 1.8.11
82
70
  signing_key:
83
71
  specification_version: 3
84
72
  summary: RServiceBus
85
73
  test_files: []
86
-
74
+ has_rdoc: