rhoconnect 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +16 -18
- data/Rakefile +4 -4
- data/bench/benchapp/Rakefile +10 -16
- data/bench/blobapp/Rakefile +9 -18
- data/bench/distr_bench/distr_bench_main +1 -1
- data/bench/distr_bench/run_distr_client.sh +2 -1
- data/bench/lib/bench.rb +1 -1
- data/bench/lib/bench/cli.rb +2 -0
- data/bench/lib/bench/distr_runner.rb +5 -5
- data/bench/lib/bench/test_data.rb +2 -2
- data/bench/scripts/test_query_script.rb +7 -6
- data/bin/rhoconnect +2 -0
- data/bin/rhoconnect-benchmark +13 -1
- data/commands/redis/redis_download.rb +1 -1
- data/commands/rhoconnect/routes.rb +12 -0
- data/doc/authentication.txt +1 -1
- data/doc/command-line.txt +1 -1
- data/doc/deploying.txt +2 -2
- data/doc/migration.txt +21 -12
- data/doc/push-client-setup-android.txt +1 -1
- data/doc/push-client-setup-rps.txt +3 -1
- data/doc/supported-platforms.txt +14 -7
- data/examples/simple/Rakefile +0 -1
- data/generators/rhoconnect.rb +15 -3
- data/generators/templates/application/Rakefile +1 -2
- data/js-adapters/ballroom.js +36 -9
- data/js-adapters/node.rb +8 -2
- data/js-adapters/node_channel.rb +10 -6
- data/js-adapters/rhoconnect_helpers.js +4 -0
- data/js-adapters/router.js +5 -3
- data/js-adapters/server.js +1 -1
- data/lib/rhoconnect.rb +9 -5
- data/lib/rhoconnect/api_token.rb +1 -2
- data/lib/rhoconnect/client.rb +1 -1
- data/lib/rhoconnect/controller/js_base.rb +7 -2
- data/lib/rhoconnect/model/base.rb +1 -1
- data/lib/rhoconnect/predefined_adapters/controllers/js/rho_internal_js_bench_adapter_controller.js +12 -0
- data/lib/rhoconnect/predefined_adapters/models/js/rho_internal_js_bench_adapter.js +107 -0
- data/lib/rhoconnect/source.rb +5 -0
- data/lib/rhoconnect/store.rb +3 -0
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/server.rb +1 -2
- data/rhoconnect.gemspec +0 -1
- data/spec/apps/jstestapp/Rakefile +1 -0
- data/spec/apps/jstestapp/config.ru +16 -0
- data/spec/apps/jstestapp/controllers/js/application_controller.js +18 -0
- data/spec/apps/jstestapp/settings/license.key +1 -0
- data/spec/apps/jstestapp/settings/settings.yml +13 -0
- data/spec/controllers/js_base_spec.rb +129 -97
- data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +111 -0
- data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +44 -0
- data/spec/spec_helper.rb +4 -0
- data/tasks/redis.rake +9 -127
- metadata +19 -20
- data/lib/rhoconnect/tasks.rb +0 -315
data/doc/authentication.txt
CHANGED
data/doc/command-line.txt
CHANGED
@@ -78,7 +78,7 @@ rhoconnect, type `rhoconnect` or `rhoconnect help`.
|
|
78
78
|
rhoconnect redis-about # About redis
|
79
79
|
rhoconnect redis-attach # Attach to redis dtach socket
|
80
80
|
rhoconnect redis-download # Download redis release 2.6.11
|
81
|
-
rhoconnect redis-install # Install the latest
|
81
|
+
rhoconnect redis-install # Install the latest version of Redis from Github (requires git, duh)
|
82
82
|
rhoconnect redis-restart # Restart redis on localhost
|
83
83
|
rhoconnect redis-start # Start redis on localhost
|
84
84
|
rhoconnect redis-status # Show status of redis servers
|
data/doc/deploying.txt
CHANGED
@@ -10,9 +10,9 @@ for Ubuntu and CentOS respectively. At this moment supported formats are Debian
|
|
10
10
|
|
11
11
|
Every package provides the following components:
|
12
12
|
|
13
|
-
* Ruby 1.9.3
|
13
|
+
* Ruby, version 1.9.3
|
14
14
|
|
15
|
-
* Node.js, version v0.10.
|
15
|
+
* Node.js, version v0.10.x
|
16
16
|
|
17
17
|
* Nginx HTTP server, release 1.3.x
|
18
18
|
|
data/doc/migration.txt
CHANGED
@@ -10,7 +10,7 @@ However, if you prefer to migrate your RhoConnect app manually, perform the step
|
|
10
10
|
Open the `Gemfile` of your application and find the `rhoconnect` line, it should look something like:
|
11
11
|
|
12
12
|
:::ruby
|
13
|
-
gem 'rhoconnect', '3.
|
13
|
+
gem 'rhoconnect', '3.4.4'
|
14
14
|
|
15
15
|
Change this to the latest release version, which you can find on [rubygems.org](http://rubygems.org/gems/rhoconnect), for example if it is 4.0.1:
|
16
16
|
|
@@ -56,17 +56,17 @@ The `rhoconnect update` command will generate a reference `Gemfile.new` which yo
|
|
56
56
|
|
57
57
|
You must update `config.ru`, `Rakefile`, 'application.rb' and your source adapter files to match RhoConnect 4.0+ gem requirements.
|
58
58
|
|
59
|
-
Replace your existing `config.ru` with the listing below. Save your old `config.ru` since you will use values within it in the new `config.ru`.
|
59
|
+
Replace your existing `config.ru` with the listing below. Save your old `config.ru` since you will use values within it in the new `config.ru`.
|
60
60
|
|
61
61
|
:::ruby
|
62
62
|
# config.ru file
|
63
|
-
|
63
|
+
|
64
64
|
#!/usr/bin/env ruby
|
65
65
|
require 'rhoconnect/application/init'
|
66
66
|
|
67
67
|
# secret is generated along with the app
|
68
68
|
# NOTE:
|
69
|
-
# Substitute 'REPLACE_ME' string by the Rhoconnect::Server.set :secret value from your old config.ru
|
69
|
+
# Substitute 'REPLACE_ME' string by the Rhoconnect::Server.set :secret value from your old config.ru
|
70
70
|
Rhoconnect::Server.set :secret, 'REPLACE_ME'
|
71
71
|
|
72
72
|
# !!! Add your custom initializers and overrides here !!!
|
@@ -78,14 +78,13 @@ Replace your existing `config.ru` with the listing below. Save your old `config.
|
|
78
78
|
#Rhoconnect.disable_rc_console = true
|
79
79
|
|
80
80
|
# run RhoConnect Application
|
81
|
-
run Rhoconnect.app
|
81
|
+
run Rhoconnect.app
|
82
82
|
|
83
83
|
And replace your existing `Rakefile` with the following:
|
84
84
|
|
85
85
|
:::ruby
|
86
86
|
require 'rubygems'
|
87
87
|
require 'bundler/setup'
|
88
|
-
require 'rhoconnect/tasks'
|
89
88
|
require 'rhoconnect'
|
90
89
|
require 'resque/tasks'
|
91
90
|
|
@@ -114,7 +113,7 @@ Move your existing `application.rb` file into `controllers/ruby/application_cont
|
|
114
113
|
<INSERT YOUR AUTHENTICATION CODE HERE>
|
115
114
|
end
|
116
115
|
|
117
|
-
get "/rps_login", :rc_handler => :rps_authenticate,
|
116
|
+
get "/rps_login", :rc_handler => :rps_authenticate,
|
118
117
|
:login_required => true do
|
119
118
|
login = params[:login]
|
120
119
|
password = params[:password]
|
@@ -124,13 +123,13 @@ Move your existing `application.rb` file into `controllers/ruby/application_cont
|
|
124
123
|
# <.... PLACE HERE ALL OF YOUR EXISTING APPLICATION CODE ...>
|
125
124
|
end
|
126
125
|
|
127
|
-
NOTE: You must remove `initializer` method from the ApplicationController class. It is no longer supported.
|
126
|
+
NOTE: You must remove `initializer` method from the ApplicationController class. It is no longer supported.
|
128
127
|
|
129
|
-
NOTE: If you had `store_blob` method
|
128
|
+
NOTE: If you had `store_blob` method overridden in the `application.rb` file - you will need to move it into the corresponding model class. Global `store_blob` method is no longer supported.
|
130
129
|
See below for details.
|
131
130
|
|
132
131
|
Re-generate your sources by running 'rhoconnect source YOUR_SOURCE' command for all of your application sources. This will create source's controller files in the `controllers/ruby` directory
|
133
|
-
and source's model files in the `models/ruby` directory. After that, move your existing files from the `sources` directory into the `models/ruby` directory, replacing the generated model files.
|
132
|
+
and source's model files in the `models/ruby` directory. After that, move your existing files from the `sources` directory into the `models/ruby` directory, replacing the generated model files.
|
134
133
|
Then, modify every file to make sure that your SourceAdapter classes now derive from the `Rhoconnect::Model::Base` class - SourceAdapters now became Models:
|
135
134
|
|
136
135
|
:::ruby
|
@@ -146,10 +145,10 @@ If you had global `store_blob` method in the `application.rb` file - you need to
|
|
146
145
|
def store_blob(object, field, blob)
|
147
146
|
<YOUR_STORE_BLOB_IMPLEMENTATION>
|
148
147
|
end
|
149
|
-
end
|
148
|
+
end
|
150
149
|
|
151
150
|
If you had source spec files in the `spec/sources` directory - you will need to move them into `spec/models/ruby` directory and adjust the top line of each spec file:
|
152
|
-
|
151
|
+
|
153
152
|
:::ruby
|
154
153
|
require File.join(File.dirname(__FILE__),'..','..','spec_helper')
|
155
154
|
|
@@ -158,3 +157,13 @@ Finally, run `bundle install` to install any missing dependencies in your RhoCon
|
|
158
157
|
|
159
158
|
:::term
|
160
159
|
$ bundle install
|
160
|
+
|
161
|
+
### Updating client application
|
162
|
+
RhoConnect's HTTP routes have changed starting with 4.0, so you'll want to update your client application's `rhoconfig.txt` to drop the trailing `/application`, for example:
|
163
|
+
|
164
|
+
|
165
|
+
# sync server url, typically this will look like 'http://<hostname>:<port>'
|
166
|
+
# for example: 'http://localhost:9292'
|
167
|
+
syncserver = 'http://192.168.1.108:9292'
|
168
|
+
|
169
|
+
Next, modify your client application according to the new [client API docs](/api/RhoConnectClient). Be sure to check out the [guides](/guide/using_rhoconnect) periodically as new content is added all the time.
|
@@ -65,7 +65,7 @@ Register the Google API project number for your client application. Modify your
|
|
65
65
|
On the Android client, it is possible to set up status bar notifications for PUSH messages. In this case, push notification can be shown on the Android status bar after ruby callback. The user can activate application by touching this notification.
|
66
66
|
There are two modes available for push notifications:
|
67
67
|
- <i>always</i> - push notification is shown always
|
68
|
-
- <i>background</i> - push notification is shown only if application
|
68
|
+
- <i>background</i> - push notification is shown only if application put into the background (not started)
|
69
69
|
If no push notification mode is specified in build.yml then no notifications are shown at all.
|
70
70
|
|
71
71
|
:::yaml
|
@@ -159,12 +159,14 @@ Then navigate to the directory containing the runtime file and run `adb install`
|
|
159
159
|
|
160
160
|
### Installing Runtime Apps for Windows Mobile/CE Devices
|
161
161
|
|
162
|
-
If you are using a Windows Mobile or CE device, install the following runtime apps on your device.
|
162
|
+
If you are using a Windows Mobile or CE device, install the following runtime apps on your device. If you already have the .NET Compact Framework on your device, make sure it is v3.5 or higher.
|
163
163
|
|
164
164
|
* `rhoconnect-push-service.CAB`
|
165
165
|
* `NETCFv35.Messages.EN.wm.cab`
|
166
166
|
* `NETCFv35.Messages.EN.cab`
|
167
167
|
|
168
|
+
**NOTE: On Windows CE 7.0, you may see the following warning: "The program is not compatible with the current operating system and, therefore, may not run on this device." You can safely ignore this warning and click the "Yes" button.**
|
169
|
+
|
168
170
|
Connect your device to your Windows computer. You can use USB-cable, bluetooth or any other method. Start ActiveSync or Windows Mobile Device Center.
|
169
171
|
|
170
172
|
Manually copy the .cab files to the device. For example, you can use the device File Explorer to display the .cab files that are on the computer. Click on each .cab file and the installation process will be started; after it is finished, you should see the app icon on your device in Programs.
|
data/doc/supported-platforms.txt
CHANGED
@@ -2,7 +2,7 @@ Supported Platforms
|
|
2
2
|
===
|
3
3
|
## Support Matrix
|
4
4
|
|
5
|
-
RhoConnect gem is available on the following platforms:
|
5
|
+
RhoConnect gem is available on the following platforms:
|
6
6
|
|
7
7
|
<table class="device-caps">
|
8
8
|
<tr>
|
@@ -11,7 +11,7 @@ RhoConnect gem is available on the following platforms:
|
|
11
11
|
<th>Ruby 1.9.3</th>
|
12
12
|
<th>Ruby 2.0.0</th>
|
13
13
|
<th>JRuby</th>
|
14
|
-
<th>Environment</th>
|
14
|
+
<th>Environment</th>
|
15
15
|
</tr>
|
16
16
|
<tr>
|
17
17
|
<td class='cap'>Linux</td>
|
@@ -26,7 +26,7 @@ RhoConnect gem is available on the following platforms:
|
|
26
26
|
<td> Mac OS X 10.7/10.8 </td>
|
27
27
|
<td> ruby-1.9.3-p448 </td>
|
28
28
|
<td class='tbd'> TBD </td>
|
29
|
-
<td class='tbd'> jruby-1.7.
|
29
|
+
<td class='tbd'> jruby-1.7.4 </td>
|
30
30
|
<td> Development </td>
|
31
31
|
</tr>
|
32
32
|
<tr>
|
@@ -39,8 +39,8 @@ RhoConnect gem is available on the following platforms:
|
|
39
39
|
</tr>
|
40
40
|
</table>
|
41
41
|
|
42
|
-
Other Ruby versions and releases might work with RhoConnect gem, but there are no guarantees.
|
43
|
-
|
42
|
+
Other Ruby versions and releases might work with RhoConnect gem, but there are no guarantees.
|
43
|
+
|
44
44
|
## Release Notes
|
45
45
|
|
46
46
|
RhoConnect for Windows is supported only in development environments. The components you should have for this environment are:
|
@@ -52,9 +52,9 @@ RhoConnect for Windows is supported only in development environments. The compon
|
|
52
52
|
* Make 3.81
|
53
53
|
* DevKit for Windows (or other Windows development environment)
|
54
54
|
|
55
|
-
RhoConnect for Linux is supported for both development and production environments.
|
55
|
+
RhoConnect for Linux is supported for both development and production environments.
|
56
56
|
On Linux servers RhoConnect is available in the format of [Debian (deb) and Red Hat (rpm) packages](http://edgedocs.rhomobile.com/rhoconnect/deploying) for Ubuntu and CentOS respectively.
|
57
|
-
RhoConnect Mac OS X is supported in development environment.
|
57
|
+
RhoConnect Mac OS X is supported in development environment.
|
58
58
|
The components you should have for this environment are:
|
59
59
|
|
60
60
|
* Ruby 1.9.3
|
@@ -62,3 +62,10 @@ The components you should have for this environment are:
|
|
62
62
|
* Redis data store (2.6.x)
|
63
63
|
* Thin application server
|
64
64
|
* RhoConnect gem with all required dependencies
|
65
|
+
|
66
|
+
## Known issues for JRuby:
|
67
|
+
|
68
|
+
* Usually JDK is shipped with only weak encryption, and that simply will not allow the proper key sizes being created by openssl. RhoConnect uses strong encryption for license keys and to function properly in JRuby environment installation of Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction policy files might be required.
|
69
|
+
* Path to user’s gems, warbler data should not include white spaces (i.e. in user's account name).
|
70
|
+
|
71
|
+
|
data/examples/simple/Rakefile
CHANGED
data/generators/rhoconnect.rb
CHANGED
@@ -124,9 +124,21 @@ Executing 'bundle install' for the first time in your freshly baked application!
|
|
124
124
|
|
125
125
|
_RUN_BUNDLER
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
puts
|
127
|
+
gem_name, gem_ver_reqs = 'rhoconnect', gem_version
|
128
|
+
found_gspec = Gem::Specification.find_by_name(gem_name, gem_ver_reqs)
|
129
|
+
puts found_gspec
|
130
|
+
if found_gspec
|
131
|
+
puts running_bundler_first_time
|
132
|
+
system("bundle install --gemfile=#{destination_root}/#{name}/Gemfile")
|
133
|
+
puts install_gems_note
|
134
|
+
end
|
135
|
+
rescue Exception => e
|
136
|
+
warning_msg = "\n" +
|
137
|
+
"*** Warning: Generatior failed to run bundler. ***\n" +
|
138
|
+
"*** Install required version of rhoconnect gem, or explicitly ***\n" +
|
139
|
+
"*** define in Gemfile the source to the gem using :path option. ***\n" +
|
140
|
+
"\n"
|
141
|
+
puts warning_msg
|
130
142
|
end
|
131
143
|
end
|
132
144
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
require 'rhoconnect/tasks'
|
4
3
|
require 'rhoconnect'
|
5
4
|
require 'resque/tasks'
|
6
5
|
|
@@ -10,7 +9,7 @@ task 'resque:setup' do
|
|
10
9
|
# The number of redis connections you want a job to have
|
11
10
|
Rhoconnect.connection_pool_size = 1
|
12
11
|
require 'rhoconnect/application/init'
|
13
|
-
|
12
|
+
|
14
13
|
Resque.after_fork do
|
15
14
|
Store.reconnect
|
16
15
|
end
|
data/js-adapters/ballroom.js
CHANGED
@@ -4,11 +4,17 @@ var redis = require('redis'),
|
|
4
4
|
EventEmitter = require('events').EventEmitter,
|
5
5
|
registerEE = new EventEmitter(),
|
6
6
|
routes = require('./router'),
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
redis_url = require('url').parse(process.env.REDIS_URL),
|
8
|
+
client_sub = redis.createClient(redis_url.port, redis_url.hostname),
|
9
|
+
client_pub = redis.createClient(redis_url.port, redis_url.hostname),
|
10
|
+
pub_channel = process.argv[2] + "-RedisPUB",
|
10
11
|
rcHelpers = require('./rhoconnect_helpers');
|
11
12
|
|
13
|
+
if(redis_url.auth) {
|
14
|
+
client_sub.auth(redis_url.auth.split(":")[1]);
|
15
|
+
client_pub.auth(redis_url.auth.split(":")[1]);
|
16
|
+
}
|
17
|
+
|
12
18
|
//define global hash functions to store callbacks, routes
|
13
19
|
rhoconnectCallbacks = {};
|
14
20
|
registeredRoutes = {};
|
@@ -16,8 +22,6 @@ registeredControllers = {};
|
|
16
22
|
registeredModels = {};
|
17
23
|
var _c_name = null;
|
18
24
|
var _m_name = null;
|
19
|
-
//TODO: Don't have test-specific code here
|
20
|
-
var prefixDir = '/spec/apps/rhotestapp';
|
21
25
|
|
22
26
|
//TODO: This has to be changed in the future
|
23
27
|
// The only reason for this - on Windows Node.js
|
@@ -112,15 +116,19 @@ var registerHandler = function(name) {
|
|
112
116
|
var register = function(){
|
113
117
|
var controller_dir = "";
|
114
118
|
var model_dir = "";
|
119
|
+
var predefined_model_dir = "";
|
120
|
+
var predefined_controller_dir = "";
|
115
121
|
try{
|
116
122
|
if(process.argv[3] == 'test' ){
|
117
|
-
controller_dir = process.
|
118
|
-
model_dir = process.
|
123
|
+
controller_dir = process.argv[4] + "/controllers/js/";
|
124
|
+
model_dir = process.argv[4] + "/models/js/";
|
119
125
|
}
|
120
126
|
else{
|
121
127
|
controller_dir = process.cwd() + "/controllers/js/";
|
122
128
|
model_dir = process.cwd() + "/models/js/";
|
123
129
|
}
|
130
|
+
predefined_controller_dir = __dirname + "/../lib/rhoconnect/predefined_adapters/controllers/js/";
|
131
|
+
predefined_model_dir = __dirname + "/../lib/rhoconnect/predefined_adapters/models/js/";
|
124
132
|
if(fs.existsSync(model_dir)){
|
125
133
|
var modelFiles = fs.readdirSync(model_dir);
|
126
134
|
modelFiles.forEach(function(file){
|
@@ -138,6 +146,23 @@ var register = function(){
|
|
138
146
|
_c_name = null;
|
139
147
|
});
|
140
148
|
}
|
149
|
+
if(fs.existsSync(predefined_model_dir)){
|
150
|
+
var modelFiles = fs.readdirSync(predefined_model_dir);
|
151
|
+
modelFiles.forEach(function(file){
|
152
|
+
//console.log("requiring model file: " + predefined_model_dir + file);
|
153
|
+
var model = require(predefined_model_dir + file);
|
154
|
+
var functions = Object.keys(model);
|
155
|
+
mapModelFunctions(file.split(".")[0],functions);
|
156
|
+
});
|
157
|
+
}
|
158
|
+
if(fs.existsSync(predefined_controller_dir)){
|
159
|
+
var controllerFiles = fs.readdirSync(predefined_controller_dir);
|
160
|
+
controllerFiles.forEach(function(file){
|
161
|
+
//console.log("requiring controller file: " + predefined_controller_dir + file);
|
162
|
+
require(predefined_controller_dir + file);
|
163
|
+
_c_name = null;
|
164
|
+
});
|
165
|
+
}
|
141
166
|
}
|
142
167
|
catch(e){
|
143
168
|
console.error("Error loading JavaScript files.");
|
@@ -201,8 +226,10 @@ function mapModelFunctions(model,functions){
|
|
201
226
|
|
202
227
|
function loadModel(name) {
|
203
228
|
var prefix = process.cwd();
|
204
|
-
if(
|
205
|
-
prefix =
|
229
|
+
if(name.match(/rho_internal/g) !== null){
|
230
|
+
prefix = __dirname + "/../lib/rhoconnect/predefined_adapters";
|
231
|
+
} else if(process.argv[3] === 'test') {
|
232
|
+
prefix = process.argv[4];
|
206
233
|
}
|
207
234
|
return require(prefix + "/models/js/" + name);
|
208
235
|
}
|
data/js-adapters/node.rb
CHANGED
@@ -24,9 +24,15 @@ module Rhoconnect
|
|
24
24
|
dir = File.expand_path(File.dirname(__FILE__))
|
25
25
|
pwd = Dir.pwd
|
26
26
|
node_modules = File.join(pwd,'node_modules')
|
27
|
-
sub_env = {
|
27
|
+
sub_env = {
|
28
|
+
"NODE_PATH" => "#{node_modules}#{File::PATH_SEPARATOR}#{pwd}#{File::PATH_SEPARATOR}#{dir}",
|
29
|
+
"REDIS_URL" => Rhoconnect.redis_url
|
30
|
+
}
|
28
31
|
file = File.join(dir,"server.js")
|
29
|
-
args = [
|
32
|
+
args = [
|
33
|
+
sub_env, "node", file, Rhoconnect::NodeChannel::PUBSUB_IDENTIFIER,
|
34
|
+
Rhoconnect.environment.to_s, Rhoconnect.base_directory
|
35
|
+
]
|
30
36
|
@pipe = IO.popen(args, "w")
|
31
37
|
log "Starting Node.js process: #{@pipe.pid}"
|
32
38
|
@pipe
|
data/js-adapters/node_channel.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
require 'open-uri'
|
3
|
+
require 'securerandom'
|
4
|
+
|
3
5
|
module Rhoconnect
|
4
6
|
class NodeChannel
|
5
7
|
class << self
|
@@ -9,8 +11,9 @@ module Rhoconnect
|
|
9
11
|
|
10
12
|
RESULT_HASH = {}
|
11
13
|
TIMEOUT = 30 # seconds
|
12
|
-
|
13
|
-
|
14
|
+
PUBSUB_IDENTIFIER = "#{$$}-#{SecureRandom.hex}"
|
15
|
+
PUB_CHANNEL = "#{PUBSUB_IDENTIFIER}-RedisSUB" # pub channel must link to redis sub channel
|
16
|
+
SUB_CHANNEL = "#{PUBSUB_IDENTIFIER}-RedisPUB" # sub channel must link to redis pub channel
|
14
17
|
@message_thread,@redis_subscriber,@redis_publisher = nil
|
15
18
|
|
16
19
|
class << self
|
@@ -54,7 +57,7 @@ module Rhoconnect
|
|
54
57
|
end
|
55
58
|
|
56
59
|
def publish_channel_and_wait(msg,curr_model)
|
57
|
-
unique_id =
|
60
|
+
unique_id = get_random_identifier
|
58
61
|
msg.merge!(:request_id => unique_id)
|
59
62
|
RESULT_HASH[unique_id] = {}
|
60
63
|
RESULT_HASH[unique_id][:status] = 'waiting'
|
@@ -77,7 +80,7 @@ module Rhoconnect
|
|
77
80
|
result = {}
|
78
81
|
num_clients = NodeChannel.redis_publisher.publish(channel,msg.to_json)
|
79
82
|
if num_clients >= 1
|
80
|
-
result = NodeChannel.wait_for_result(unique_id,curr_model) if unique_id
|
83
|
+
result = NodeChannel.wait_for_result(unique_id,curr_model) if unique_id
|
81
84
|
else
|
82
85
|
log "ERROR: Cannot communicate with Node.js process."
|
83
86
|
if Rhoconnect.restart_node_on_error
|
@@ -142,7 +145,7 @@ module Rhoconnect
|
|
142
145
|
def route_message(msg)
|
143
146
|
case msg['route']
|
144
147
|
when 'request'
|
145
|
-
result_id =
|
148
|
+
result_id = get_random_identifier
|
146
149
|
RESULT_HASH[msg['request_id']][:pending_js_requests] ||= []
|
147
150
|
RESULT_HASH[msg['request_id']][:pending_js_requests] << result_id
|
148
151
|
RESULT_HASH[msg['request_id']][result_id] = {}
|
@@ -156,7 +159,7 @@ module Rhoconnect
|
|
156
159
|
else
|
157
160
|
RESULT_HASH[msg['request_id']][:result] = msg["result"]
|
158
161
|
pending_js_requests = RESULT_HASH[msg['request_id']][:pending_js_requests]
|
159
|
-
if not pending_js_requests or pending_js_requests.length == 0
|
162
|
+
if not pending_js_requests or pending_js_requests.length == 0
|
160
163
|
RESULT_HASH[msg['request_id']][:status] = 'done'
|
161
164
|
end
|
162
165
|
end
|
@@ -188,6 +191,7 @@ module Rhoconnect
|
|
188
191
|
end
|
189
192
|
else
|
190
193
|
res = klass.send(data['function'])
|
194
|
+
res
|
191
195
|
end
|
192
196
|
else
|
193
197
|
raise Exception.new("Method #{data['function']} not found in model #{curr_model.class.name.to_s}.")
|
@@ -43,6 +43,10 @@ var Store = function(){
|
|
43
43
|
var json = this.formatJson('get_data',resp.params,callback);
|
44
44
|
resp.send(json);
|
45
45
|
};
|
46
|
+
this.deleteData = function(resp,callback){
|
47
|
+
var json = this.formatJson('delete_data',resp.params,callback);
|
48
|
+
resp.send(json);
|
49
|
+
};
|
46
50
|
|
47
51
|
this.formatJson = function(method,args,callback){
|
48
52
|
var json = {};
|
data/js-adapters/router.js
CHANGED
@@ -7,7 +7,6 @@ var router = function(json,send){
|
|
7
7
|
try {
|
8
8
|
var request = new Request();
|
9
9
|
var resp1 = new Response();
|
10
|
-
|
11
10
|
request.params = json['args'];
|
12
11
|
request.header = {'request_id':json['request_id'],'route':json['route']};
|
13
12
|
request.model = json['model'];
|
@@ -17,8 +16,11 @@ var router = function(json,send){
|
|
17
16
|
//if calling model function directly load file first
|
18
17
|
if(json['klss'] !== undefined){
|
19
18
|
var model_dir = '';
|
20
|
-
if(
|
21
|
-
model_dir =
|
19
|
+
if(json['klss'].match(/rho_internal/g) !== null){
|
20
|
+
model_dir = __dirname + "/../lib/rhoconnect/predefined_adapters/models/js/";
|
21
|
+
}
|
22
|
+
else if(process.argv[3] == 'test' ){
|
23
|
+
model_dir = process.argv[4] + "/models/js/";
|
22
24
|
}
|
23
25
|
else{
|
24
26
|
model_dir = process.cwd() + "/models/js/";
|