rhoconnect 3.1.0.beta1 → 3.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +17 -0
- data/Gemfile +4 -1
- data/Gemfile.lock +28 -22
- data/Rakefile +6 -5
- data/bench/bench_runner.rb +2 -2
- data/bench/benchapp/Gemfile +1 -2
- data/bench/benchapp/Gemfile.lock +19 -42
- data/bench/benchapp/spec/spec_helper.rb +1 -1
- data/bench/blobapp/Gemfile +0 -1
- data/bench/blobapp/Gemfile.lock +52 -47
- data/bench/blobapp/spec/spec_helper.rb +1 -1
- data/bench/lib/bench/logging.rb +0 -2
- data/bench/lib/bench/utils.rb +3 -3
- data/bench/run_bench.sh +4 -3
- data/bench/spec/bench_spec_helper.rb +6 -0
- data/doc/benchmarks-running.txt +2 -0
- data/doc/client.txt +1 -1
- data/doc/cud-conflicts.txt +23 -23
- data/doc/java-plugin.txt +23 -23
- data/doc/net-plugin.txt +21 -10
- data/doc/rhoconnect-redis-stack.txt +4 -4
- data/doc/supported-platforms.txt +77 -0
- data/doc/tutorial.txt +11 -13
- data/generators/rhoconnect.rb +1 -1
- data/generators/templates/application/Gemfile +4 -4
- data/generators/templates/application/spec/spec_helper.rb +10 -8
- data/installer/unix-like/rho_connect_install_constants.rb +2 -2
- data/installer/utils/package_upload/repos.rake +22 -7
- data/installer/utils/package_upload/s3_upload.rb +50 -22
- data/installer/windows/rhosync.nsi +5 -5
- data/lib/rhoconnect/body_content_type_parser.rb +4 -1
- data/lib/rhoconnect/jobs/bulk_data_job.rb +3 -3
- data/lib/rhoconnect/tasks.rb +17 -21
- data/lib/rhoconnect/version.rb +1 -1
- data/rhoconnect.gemspec +2 -1
- data/spec/spec_helper.rb +15 -7
- data/spec/stats/middleware_spec.rb +0 -1
- data/spec/store_spec.rb +0 -1
- data/tasks/redis.rake +2 -2
- metadata +64 -47
data/doc/cud-conflicts.txt
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
Resolving
|
1
|
+
Resolving Conflicts
|
2
2
|
===
|
3
3
|
|
4
|
-
|
4
|
+
Create,Update,Delete Queue and Potential Conflicts
|
5
5
|
---
|
6
6
|
|
7
|
-
By design, your
|
8
|
-
To handle this situation
|
7
|
+
By design, your RhoConnect application supports parallel dispatching of the multiple client's requests via the asynchronous Resque jobs. This scenario can lead to a situation where two or more clients will try to perform create,update, and delete operations at the same time, potentially creating the race condition. For example, this can happen when two users will try to insert or delete the same record simultaneously.
|
8
|
+
To handle this situation, RhoConnect uses the create,update,delete (or CUD) queue, which is being dispatched continuously. You can inspect this queue before the CUD operation is called and mark the conflicting records for special processing. To do this, you need to override the Source Adapter `validate` method that is called before the CUD queue is dispatched. This method has the following parameters:
|
9
9
|
|
10
10
|
<table border="1">
|
11
11
|
<tr>
|
@@ -16,12 +16,12 @@ To handle this situation , Rhoconnect uses the CUD queue, which is being dispatc
|
|
16
16
|
<tr>
|
17
17
|
<td>Array Of Record Hashes</td>
|
18
18
|
<td><code>cud_queue</code></td>
|
19
|
-
<td>CUD queue consisting of CUD request hashes, ordered from oldest to newest. Each entry in the queue contains a hash of CUD records to process. (Each CUD client request can contain more than one record</td>
|
19
|
+
<td>CUD queue consisting of CUD request hashes, ordered from oldest to newest. Each entry in the queue contains a hash of CUD records to process. (Each CUD client request can contain more than one record)</td>
|
20
20
|
</tr>
|
21
21
|
<tr>
|
22
22
|
<td>Array Of Client Ids</td>
|
23
23
|
<td><code>client_queue</code></td>
|
24
|
-
<td>This array is used to map the CUD request in the above queue to a corresponding client ID. i.e.
|
24
|
+
<td>This array is used to map the CUD request in the above queue to a corresponding client ID. i.e. cud_queue[n] request was issued by client_queue[n] client. Please note that there may be several entries from the same client - if they came separately in time</td>
|
25
25
|
</tr>
|
26
26
|
</table>
|
27
27
|
|
@@ -37,32 +37,32 @@ Below you can see the example of the `validate` method parameters indicating two
|
|
37
37
|
cud_queue = [ cud_request_1, cud_request_2 ]
|
38
38
|
client_ids = [ client_1, client_2 ]
|
39
39
|
|
40
|
-
Detecting the
|
40
|
+
Detecting the Conflict and Forcing an Error
|
41
41
|
---
|
42
42
|
|
43
43
|
Using the above `validate` method you can iterate through the queue and detect CUD conflicts based on the desired application logic. Once the conflicting record is found (for example, duplicate create request), you need to mark it by inserting the conflicting record parameters into the special hash structure that is returned by the `validate` method:
|
44
44
|
|
45
45
|
:::ruby
|
46
46
|
def validate(operation, cud_queue, client_ids)
|
47
|
-
|
47
|
+
resulting_meta_hash = {}
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
# iterating through the queue
|
50
|
+
cud_queue.each_with_index do |cud_request, index|
|
51
|
+
cud_request_client = client_ids[index]
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
# iterating through the request records
|
54
|
+
cud_request.each do |record_id, record_hash|
|
55
|
+
# ... detecting the conflict here ....
|
56
|
+
|
57
|
+
# !!! found a conflict - force an error
|
58
|
+
error_record_id = record_id
|
59
|
+
record_meta_data = { error_record_id => { :error => 'my_error_string: conflict is detected!!!' }}
|
60
|
+
resulting_meta_hash[index] ||= {}
|
61
|
+
resulting_meta_hash[index].merge!(record_meta_data)
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
end
|
64
|
+
resulting_meta_hash
|
65
65
|
end
|
66
66
|
|
67
|
-
Once the `validate` method returns non-empty validation metadata hash structure, it will be used in processing the CUD queue. All marked records will not be processed, but instead an error will be sent back to the originating client with the user-provided error message.
|
67
|
+
Once the `validate` method returns a non-empty validation metadata hash structure, it will be used in processing the CUD queue. All marked records will not be processed, but instead an error will be sent back to the originating client with the user-provided error message.
|
68
68
|
|
data/doc/java-plugin.txt
CHANGED
@@ -10,17 +10,17 @@ Using the RhoConnect-Java plugin, your [Spring 3 MVC](http://www.springsource.or
|
|
10
10
|
* Java (1.6)
|
11
11
|
* Maven2 (2.2.1)
|
12
12
|
* Git
|
13
|
-
* [Rhoconncect-java](https://github.com/downloads/rhomobile/rhoconnect-java/rhoconnect-java-1.0
|
13
|
+
* [Rhoconncect-java](https://github.com/downloads/rhomobile/rhoconnect-java/rhoconnect-java-1.0.1.jar) plugin jar file
|
14
14
|
|
15
15
|
## Getting started
|
16
16
|
|
17
17
|
We assume that you have a complete java end-to-end application using Spring 3.0 MVC as the front end technology and Hibernate as backend ORM. For this application we will also use Maven2 for build and dependency management and some database to persist the data. The database is accessed by a Data Access (DAO) layer.
|
18
18
|
|
19
|
-
Copy [Rhoconncect-java](https://github.com/downloads/rhomobile/rhoconnect-java/rhoconnect-java-1.0
|
19
|
+
Copy [Rhoconncect-java](https://github.com/downloads/rhomobile/rhoconnect-java/rhoconnect-java-1.0.1.jar) plugin jar file to your PC.
|
20
20
|
You can also create target rhoconnect-java plugin jar from sources by cloning rhoconnect-java repository
|
21
21
|
|
22
22
|
:::term
|
23
|
-
$ git clone
|
23
|
+
$ git clone https://github.com/rhomobile/rhoconnect-java.git
|
24
24
|
|
25
25
|
and executing in cloned project directory the following commands:
|
26
26
|
|
@@ -64,7 +64,7 @@ You must also add the rhoconnect-java jar to your Maven 2 project. At this momen
|
|
64
64
|
Download the `rhoconnect-java-1.0-SNAPSHOT.jar` jar file and put it into your hard drive, and issue the following Maven's command:
|
65
65
|
|
66
66
|
:::term
|
67
|
-
$ mvn install:install-file -Dfile=/path-to-jar/rhoconnect-java-1.0
|
67
|
+
$ mvn install:install-file -Dfile=/path-to-jar/rhoconnect-java-1.0.1.jar -DgroupId=com.rhomobile.rhoconnect -DartifactId=rhoconnect-java -Dversion=1.0.1 -Dpackaging=jar
|
68
68
|
|
69
69
|
Now, the `rhoconnect-java` jar library is included into your Maven local repository.
|
70
70
|
In the RhoconnectJavaSample application, you would add this code to the pom.xml file.
|
@@ -74,7 +74,7 @@ In the RhoconnectJavaSample application, you would add this code to the pom.xml
|
|
74
74
|
<dependency>
|
75
75
|
<groupId>com.rhomobile.rhoconnect</groupId>
|
76
76
|
<artifactId>rhoconnect-java</artifactId>
|
77
|
-
<version>1.0
|
77
|
+
<version>1.0.1</version>
|
78
78
|
<type>jar</type>
|
79
79
|
</dependency>
|
80
80
|
|
@@ -147,7 +147,7 @@ The `authenticate` bean will be called by rhoconnect server to authenticate user
|
|
147
147
|
import java.util.Map;
|
148
148
|
|
149
149
|
public interface Rhoconnect {
|
150
|
-
|
150
|
+
String authenticate(String userName, String password, Map<String, Object> attributes);
|
151
151
|
}
|
152
152
|
|
153
153
|
For example:
|
@@ -163,10 +163,17 @@ For example:
|
|
163
163
|
private static final Logger logger = Logger.getLogger(ContactAuthenticate.class);
|
164
164
|
|
165
165
|
@Override
|
166
|
-
public
|
167
|
-
logger.
|
168
|
-
// TODO: your authentication code goes here ...
|
169
|
-
|
166
|
+
public String authenticate(String login, String password, Map<String, Object> attributes) {
|
167
|
+
logger.debug("ContactAuthenticate#authenticate: implement your authentication code!");
|
168
|
+
// TODO: your authentication code goes here ...
|
169
|
+
// Return null value if authentication fails.
|
170
|
+
|
171
|
+
// Otherwise, returned value is data partitioning: i.e. user name for filtering data on per user basis
|
172
|
+
//return login;
|
173
|
+
|
174
|
+
// But if you want your data to be partitioned by 'app' (i.e. the data will be shared among all users),
|
175
|
+
// you should return string "app": it will instruct Rhoconnect to partition the data accordingly.
|
176
|
+
return "app";
|
170
177
|
}
|
171
178
|
}
|
172
179
|
|
@@ -184,7 +191,6 @@ You need to establish communication from the RhoConnect instance to your java ba
|
|
184
191
|
Integer rhoconnectCreate(String partition, Map<String, Object> attributes);
|
185
192
|
Integer rhoconnectUpdate(String partition, Map<String, Object> attributes);
|
186
193
|
Integer rhoconnetDelete(String partition, Map<String, Object> attributes);
|
187
|
-
String getPartition();
|
188
194
|
}
|
189
195
|
|
190
196
|
To help rhoconnect-java plugin correctly do mapping of model name to service bean you should take into account the following conventions:
|
@@ -200,9 +206,9 @@ For more information about RhoConnect partitions, please refer to the [RhoConnec
|
|
200
206
|
You also must to establish the communication from your java back-end application to the RhoConnect instance by auto-wiring `RhoconnectClient` bean into your DAO service class and inserting notifications hooks into data access (create/update/delete) methods.
|
201
207
|
`RhoconnectClient` bean is provided by rhoconnect-java plugin and responds to the following methods you have to call:
|
202
208
|
|
203
|
-
* boolean notifyOnCreate(String sourceName,
|
204
|
-
* boolean notifyOnUpdate(String sourceName,
|
205
|
-
* boolean notifyOnDelete(String sourceName,
|
209
|
+
* boolean notifyOnCreate(String sourceName, Object objId, Object object)
|
210
|
+
* boolean notifyOnUpdate(String sourceName, Object objId, Object object)
|
211
|
+
* boolean notifyOnDelete(String sourceName, Object objId)
|
206
212
|
|
207
213
|
Example for `RhoconnectJavaSample` application:
|
208
214
|
|
@@ -238,20 +244,20 @@ Example for `RhoconnectJavaSample` application:
|
|
238
244
|
@Transactional
|
239
245
|
public int addContact(Contact contact) {
|
240
246
|
int id = contactDAO.addContact(contact);
|
241
|
-
client.notifyOnCreate(sourceName,
|
247
|
+
client.notifyOnCreate(sourceName, Integer.toString(id), contact);
|
242
248
|
return id;
|
243
249
|
}
|
244
250
|
|
245
251
|
@Transactional
|
246
252
|
public void updateContact(Contact contact) {
|
247
253
|
contactDAO.updateContact(contact);
|
248
|
-
client.notifyOnUpdate(sourceName,
|
254
|
+
client.notifyOnUpdate(sourceName, Integer.toString(contact.getId()), contact);
|
249
255
|
}
|
250
256
|
|
251
257
|
@Transactional
|
252
258
|
public void removeContact(Integer id) {
|
253
259
|
contactDAO.removeContact(id);
|
254
|
-
client.notifyOnDelete(sourceName,
|
260
|
+
client.notifyOnDelete(sourceName, Integer.toString(id));
|
255
261
|
}
|
256
262
|
|
257
263
|
@Transactional
|
@@ -315,12 +321,6 @@ Example for `RhoconnectJavaSample` application:
|
|
315
321
|
removeContact(id);
|
316
322
|
return id;
|
317
323
|
}
|
318
|
-
|
319
|
-
@Override
|
320
|
-
public String getPartition() {
|
321
|
-
// Data partitioning: i.e. your user name for filtering data on per user basis
|
322
|
-
return "alexb";
|
323
|
-
}
|
324
324
|
}
|
325
325
|
|
326
326
|
Click [here](https://github.com/shurab/RhoconnectJavaPluginDemo) to download full source code of Contact manager application with rhoconnect-java plugin.
|
data/doc/net-plugin.txt
CHANGED
@@ -9,12 +9,12 @@ Using rhoconnect.NET, your [ASP.NET MVC](http://www.asp.net/mvc/mvc4) applicatio
|
|
9
9
|
|
10
10
|
Copy the [`rhoconnect.NET`](https://github.com/rhomobile/rhoconnect.NET) github repository to your PC:
|
11
11
|
|
12
|
-
$ git clone
|
12
|
+
$ git clone https://github.com/rhomobile/rhoconnect.NET.git
|
13
13
|
|
14
14
|
By default, the `rhoconnect.NET` repository contains the pre-built `RhoconnectNET.dll` library in the `bin/Release` subdirectory.
|
15
15
|
However, you can build your own library using the provided Microsoft Visual Studio .NET solution file and the source code files.
|
16
16
|
|
17
|
-
You can download and use the sample [`ASP.NET MVC4`](https://github.com/rhomobile/RhoconnectNET_MVC4_App) application to repeat the steps described below.
|
17
|
+
You can download and use the sample [`ASP.NET MVC4`](https://github.com/rhomobile/RhoconnectNET_MVC4_App) application to repeat the steps described below. In addition, the above sample also contains the final code in `ContactsApp_final` subdirrectory. You can just use it (you will still need to modify the `set_app_point` with your app endpoints and add the RhoconnectNET library reference to your project.)
|
18
18
|
|
19
19
|
In order to use `Rhoconnect.NET` functionality in your `ASP.NET MVC` application, first you need to include the `Rhoconnect.NET` library
|
20
20
|
as a dependency to your application. Click `Project => Add Reference` menu item in the Visual Studio and navigate to the `RhoconnectNET.dll` library.
|
@@ -58,10 +58,12 @@ and call them from the `Application_Start` method:
|
|
58
58
|
rhoconnect_authenticate);
|
59
59
|
}
|
60
60
|
|
61
|
-
private bool rhoconnect_authenticate(String username, String password, Hashtable auth_attrs)
|
61
|
+
private bool rhoconnect_authenticate(ref String username, String password, Hashtable auth_attrs)
|
62
62
|
{
|
63
|
-
//
|
64
|
-
|
63
|
+
// uncomment the following line, if you want to replace the default partitioning to 'app'
|
64
|
+
// username = "app";
|
65
|
+
// perform your authentication here
|
66
|
+
return true;
|
65
67
|
}
|
66
68
|
|
67
69
|
`RhoconnectNET.Client.set_app_point` method is a main point
|
@@ -85,7 +87,7 @@ and it has the following parameters:
|
|
85
87
|
<td>rhoconnect server's api_token, for example <code>secrettoken</code>.</td>
|
86
88
|
</tr>
|
87
89
|
<tr>
|
88
|
-
<td>
|
90
|
+
<td>delegate rhoAuthHandler(ref String, String, Hashtable, bool)</td>
|
89
91
|
<td><code>Authenticating_Routine</code></td>
|
90
92
|
<td>handle to the application's authenticating routine (if null, <code>true</code> is returned by default).</td>
|
91
93
|
</tr>
|
@@ -95,11 +97,17 @@ and it has the following parameters:
|
|
95
97
|
By providing the `rhoconnect_authenticate` method and registering it with the `Rhoconnect.NET` in the `set_app_endpoint`
|
96
98
|
method, you map your application specific authentication to the Rhoconnect `authenticate` requests:
|
97
99
|
|
98
|
-
|
100
|
+
private bool rhoconnect_authenticate(ref String username, String password, Hashtable auth_attrs)
|
99
101
|
{
|
100
|
-
//
|
101
|
-
|
102
|
+
// uncomment the following line, if you want to replace the default partitioning to 'app'
|
103
|
+
// username = "app";
|
104
|
+
// perform your authentication here
|
105
|
+
return true;
|
102
106
|
}
|
107
|
+
|
108
|
+
If you want your data to be partitioned by 'app' (i.e. the data will be shared among all users), you can replace
|
109
|
+
the provided `username` parameter (which is passed by reference) to `app` - which will instruct Rhoconnect to partition
|
110
|
+
the data accordingly.
|
103
111
|
|
104
112
|
## Implementing CRUD functionality
|
105
113
|
`Rhoconnect.NET` lib installs `/rhoconnect/<CRUD>` routes in your application which the Rhoconnect instance
|
@@ -211,9 +219,12 @@ For this reason, `RhoconnectNET` library provides three callback routines for CU
|
|
211
219
|
The above example will look like this after inserting the corresponding callback routine:
|
212
220
|
|
213
221
|
// This method is used to access current partition
|
214
|
-
// in Rhoconnect notification
|
222
|
+
// in Rhoconnect notification callback
|
215
223
|
private String partition()
|
216
224
|
{
|
225
|
+
// If you're using 'app' partition
|
226
|
+
// uncomment the following line
|
227
|
+
// return "app";
|
217
228
|
return "testuser";
|
218
229
|
}
|
219
230
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Deploying RhoConnect with High Availability on Amazon Web Services
|
2
2
|
|
3
3
|
This tutorial will guide you through setting up a Redis stack and a RhoConnect application stack in the Amazon Web Service (AWS) cloud.
|
4
4
|
|
@@ -45,7 +45,7 @@ Click the Launch Classic Wizard radio button. Click Continue.
|
|
45
45
|
|
46
46
|
### Requesting the Instance
|
47
47
|
|
48
|
-
In the Choose an AMI section click the Community AMIs tab.
|
48
|
+
In the Choose an AMI section, click the Community AMIs tab.
|
49
49
|
Then paste in the AMI `ami-65e4bb20`. When the preconfigured RhoConnect AMI appears, click Select.
|
50
50
|
|
51
51
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/request-instances-wizard-community-AMIs.png" alt="request instances - choose AMI" />
|
@@ -70,7 +70,7 @@ In the Create Key Pair section, select your existing key pair or create a new ke
|
|
70
70
|
|
71
71
|
In the Configure Firewall section, click the Create New Security Group radio button.
|
72
72
|
|
73
|
-
|
73
|
+
Click the Add Rule button to add each port.
|
74
74
|
|
75
75
|
* Add port 22 for SSH.
|
76
76
|
* Add port 80 for HTTP.
|
@@ -90,7 +90,7 @@ In the window titled "Launch Instance Wizard", click Close and wait for your ins
|
|
90
90
|
|
91
91
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-redis-aws/instances-instances.png" alt="instances - instances" />
|
92
92
|
|
93
|
-
In the EC2 tab,
|
93
|
+
In the EC2 tab, click on Instances.
|
94
94
|
|
95
95
|
For Viewing, select Running Instances. Select your newly created RhoConnect instance and scroll down to see Private DNS in the lower section of the My Instances screen.
|
96
96
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Supported Platforms
|
2
|
+
===
|
3
|
+
## Support Matrix
|
4
|
+
|
5
|
+
<table class="device-caps">
|
6
|
+
<tr>
|
7
|
+
<th>OS</th>
|
8
|
+
<th>Distribution</th>
|
9
|
+
<th>Ruby 1.8.7</th>
|
10
|
+
<th>Ruby Enterprise</th>
|
11
|
+
<th>Ruby 1.9.2</th>
|
12
|
+
<th>Ruby 1.9.3</th>
|
13
|
+
<th>JRuby</th>
|
14
|
+
<th>Environment</th>
|
15
|
+
</tr>
|
16
|
+
<tr>
|
17
|
+
<td class='cap'>Linux</td>
|
18
|
+
<td> CentOS 5 & 6,<br/>Ubuntu 11,<br/>Amazon Linux</td>
|
19
|
+
<td> ruby-1.8.7-p352 </td>
|
20
|
+
<td> ree-1.8.7-2011.03 </td>
|
21
|
+
<td> ruby-1.9.2-p290 </td>
|
22
|
+
<td> ruby-1.9.3-p0 </td>
|
23
|
+
<td> jruby-1.6.4 </td>
|
24
|
+
<td>Development &<br/>Production</td>
|
25
|
+
</tr>
|
26
|
+
<tr>
|
27
|
+
<td class='cap'>Mac OS </td>
|
28
|
+
<td> Mac OS X 10.6/10.7 </td>
|
29
|
+
<td> ruby-1.8.7-p352 </td>
|
30
|
+
<td> ree-1.8.7-2011.03 </td>
|
31
|
+
<td> ruby-1.9.2-p290 </td>
|
32
|
+
<td> ruby-1.9.3-p0 </td>
|
33
|
+
<td> jruby-1.6.4 </td>
|
34
|
+
<td>Development &<br/>Production</td>
|
35
|
+
</tr>
|
36
|
+
<tr>
|
37
|
+
<td class='cap'>Windows</td>
|
38
|
+
<td> Windows 7 </td>
|
39
|
+
<td> ruby-1.8.7-p352 </td>
|
40
|
+
<td class='tbd'> TBD </td>
|
41
|
+
<td class='tbd'> TBD </td>
|
42
|
+
<td> ruby-1.9.3-p0 </td>
|
43
|
+
<td class='tbd'> TBD </td>
|
44
|
+
<td>Development</td>
|
45
|
+
</tr>
|
46
|
+
</table>
|
47
|
+
|
48
|
+
Other Ruby versions and releases might work with RhoConnect gem, but there are no guarantees.
|
49
|
+
|
50
|
+
## Release Notes
|
51
|
+
|
52
|
+
RhoConnect for Windows is supported only in development environment as a part of RhoStudio bundle:
|
53
|
+
|
54
|
+
* Ruby 1.8.7
|
55
|
+
* Redis 2.4.x
|
56
|
+
* Latest RhoConnect and Rhodes gems
|
57
|
+
* Eclipse 3.6 with latest rhostudio plugin
|
58
|
+
* Make 3.18
|
59
|
+
* DevKit for Windows
|
60
|
+
|
61
|
+
RhoConnect for Linux and Mac OS X is supported for both development and production environments.
|
62
|
+
|
63
|
+
Production environment for Linux servers is provided as pre-packaged software bundle and includes the following components:
|
64
|
+
|
65
|
+
* Ruby 1.8.7 (ree)
|
66
|
+
* Nginx HTTP server (1.0.x)
|
67
|
+
* Redis data store (2.4.x)
|
68
|
+
* Phusion Passenger
|
69
|
+
* RhoConnect gem with all required dependencies
|
70
|
+
|
71
|
+
|
72
|
+
## Known Issues
|
73
|
+
|
74
|
+
* Latest gem <b>rack</b> ver. 1.4.0 is buggy, rhoconnect gemset locked to <b>rack</b> ver. 1.3.6
|
75
|
+
* Windows platform: only pre-release (~> 1.0.0.beta) of <b>eventmachine</b> is working on Windows
|
76
|
+
* Examples for <b>RSpec</b> (~> 2.8.0) fail for Ruby 1.8.7, gemset locked to ver. >= 2.6.0
|
77
|
+
* Release <b>JRuby-1.6.5</b> is broken, use <b>JRuby-1.6.4</b> instead
|
data/doc/tutorial.txt
CHANGED
@@ -60,17 +60,17 @@ Once RhoConnect is installed we're ready to build a RhoConnect source to integra
|
|
60
60
|
|
61
61
|
### Generating the Source Adapter from RhoStudio
|
62
62
|
|
63
|
-
To generate a RhoConnect source adapter and create the associated Controller templates, right-click on the application project in the Project Explorer and select New->
|
63
|
+
To generate a RhoConnect source adapter and create the associated Controller templates, right-click on the application project in the Project Explorer and select New->Rhoconnect Source Adapter.
|
64
64
|
|
65
65
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/menu-new-rhoconnect_source-adapter.png"/>
|
66
66
|
|
67
|
-
In the
|
67
|
+
In the Source Adapter Information window, enter the name for your source adapter: in this case, "product".
|
68
68
|
|
69
69
|
Click the Finish button to create the source adapter.
|
70
70
|
|
71
71
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/source-adapter-information.png"/>
|
72
72
|
|
73
|
-
After pressing the Finish button, you'll see the RhoConnect source adapter generator script output in the output console (
|
73
|
+
After pressing the Finish button, you'll see the RhoConnect source adapter generator script output in the output console (Rhomobile build console).
|
74
74
|
|
75
75
|
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhoconnect-source-generator-output.png"/>
|
76
76
|
|
@@ -79,11 +79,13 @@ You should now have files for the source adapter in your storeserver application
|
|
79
79
|
* product.rb -> This is the source adapter file which contains the login, query, create, update, delete and logoff methods to call a backend service. You will add code to implement these methods.
|
80
80
|
* product_spec.rb -> This file contains the spec with tests which relate to our source adapter.
|
81
81
|
|
82
|
+
You can open these files for editing by clicking on them in the Project Explorer.
|
83
|
+
|
82
84
|
### Generating the Source Adapter from the Command Line
|
83
85
|
|
84
86
|
From the command line, navigate to the main folder for your RhoConnect app: in this case, storeserver.
|
85
87
|
|
86
|
-
Then run the command to generate a source adapter for the product model. The product model is used as an example for a Rhodes storemanager in the [RhoStudio tutorial](rhostudio.tutorial) and the [documentation to generate a Rhodes application](rhodes/generator).
|
88
|
+
Then run the command to generate a source adapter for the product model. The product model is used as an example for a Rhodes storemanager in the [RhoStudio tutorial](/rhostudio.tutorial) and the [documentation to generate a Rhodes application](/rhodes/generator).
|
87
89
|
|
88
90
|
:::term
|
89
91
|
$ rhoconnect source product
|
@@ -94,13 +96,11 @@ which generates two files, the product adapter and the product spec:
|
|
94
96
|
[ADDED] sources/product.rb
|
95
97
|
[ADDED] spec/sources/product_spec.rb
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
-
<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-tutorial/rhostudio-rhoconnect-product-rb.png"/>
|
99
|
+
You can use the command line to navigate to the sources/product.rb file in your RhoConnect application folder.
|
100
100
|
|
101
|
-
|
101
|
+
### Understanding the Source Adapter File
|
102
102
|
|
103
|
-
|
103
|
+
The generated source adapter file (in this case, product.rb) is similar to the code listing below. It has code to raise an exception for any required method. Note that you don't need to use the source generator; you can create a Ruby file and place it into your lib directory. The class name (in this case, product) of the RhoConnect source adapter must match that of the Rhodes client model.
|
104
104
|
|
105
105
|
:::ruby
|
106
106
|
class Product < SourceAdapter
|
@@ -161,15 +161,13 @@ The generator will also edit settings/settings.yml and add the product adapter t
|
|
161
161
|
Product:
|
162
162
|
:poll_interval: 300
|
163
163
|
|
164
|
-
The next step is for you to fill in the login, query, create, update, delete and logoff methods with your own code to call a backend service.
|
165
|
-
|
166
|
-
The description below shows what such code might look like.
|
164
|
+
The next step is for you to fill in the login, query, create, update, delete and logoff methods with your own code to call a backend service.
|
167
165
|
|
168
166
|
## A RhoConnect Query
|
169
167
|
|
170
168
|
If you're doing a readonly non-authenticated source adapter, you can just write one method, query, to retrieve records as we describe here. The following is a sample query method to interact with a simple product catalog (available at http://rhostore.heroku.com) that exposes a REST interface. Note that RhoConnect can work with any protocol. This example shows JSON over HTTP with a REST interface, since that is common. The RhoConnect source adapter is Ruby code and there are ruby libraries (aka gems) that will make it easy to connect to and parse whatever you need -- the query code would just be slightly different.
|
171
169
|
|
172
|
-
For a more complete example of rewriting the source adapter methods (such as create, update, and delete), refer to the [source adapter example](rhoconnect/source-adapters#sample-adapter) in the RhoConnect Developer Reference.
|
170
|
+
For a more complete example of rewriting the source adapter methods (such as create, update, and delete), refer to the [source adapter example](/rhoconnect/source-adapters#sample-adapter) in the RhoConnect Developer Reference.
|
173
171
|
|
174
172
|
Our sample web service for returning all products in the catalog (http://rhostore.heroku.com/products.json) returns data like this:
|
175
173
|
|
data/generators/rhoconnect.rb
CHANGED
@@ -4,21 +4,22 @@ gem 'rhoconnect', '<%=gem_version%>'
|
|
4
4
|
|
5
5
|
# Helps with some of the limitations of green threads, not needed in ruby 1.9.x
|
6
6
|
gem 'SystemTimer', '~> 1.2.3', :platforms => :ruby_18
|
7
|
+
gem 'win32-process', :platforms => [:mswin, :mingw]
|
7
8
|
|
8
9
|
platforms :jruby do
|
9
10
|
gem 'jdbc-sqlite3', ">= 3.7.2"
|
10
11
|
gem 'dbi', ">= 0.4.5"
|
11
12
|
gem 'dbd-jdbc', ">= 0.1.4"
|
12
13
|
gem 'jruby-openssl', ">= 0.7.4"
|
14
|
+
gem 'trinidad'
|
13
15
|
gem 'warbler'
|
14
16
|
end
|
15
17
|
|
16
18
|
gem 'sqlite3', ">= 1.3.3", :platforms => [:ruby, :mswin, :mingw]
|
17
19
|
|
18
|
-
# For jruby trinidad JRuby web server is used
|
19
|
-
gem 'trinidad', :platforms => :jruby
|
20
|
-
|
21
20
|
group :development do
|
21
|
+
# FIXME: At this moment (01/10/2012) only pre release of 'eventmachine' is working on Windows
|
22
|
+
gem 'eventmachine', '~> 1.0.0.beta', :platforms => [:mswin, :mingw]
|
22
23
|
# By default to run application thin web server is used
|
23
24
|
gem 'thin', :platforms => [:ruby, :mswin, :mingw]
|
24
25
|
gem 'rhomobile-debug', ">= 1.0.2"
|
@@ -27,6 +28,5 @@ end
|
|
27
28
|
group :test do
|
28
29
|
gem 'rack-test', '>= 0.5.3', :require => "rack/test"
|
29
30
|
gem 'rspec', '~> 2.6.0'
|
30
|
-
gem 'rcov', '>= 0.9.8'
|
31
31
|
gem 'rhomobile-debug', ">= 1.0.2"
|
32
32
|
end
|
@@ -12,7 +12,7 @@ rescue LoadError
|
|
12
12
|
require 'rhoconnect'
|
13
13
|
end
|
14
14
|
|
15
|
-
$:.unshift File.join(File.dirname(__FILE__), "..")
|
15
|
+
$:.unshift File.join(File.dirname(__FILE__), "..")
|
16
16
|
# Load our rhoconnect application
|
17
17
|
require 'application'
|
18
18
|
include Rhoconnect
|
@@ -20,13 +20,15 @@ include Rhoconnect
|
|
20
20
|
require 'rhoconnect/test_methods'
|
21
21
|
|
22
22
|
# Monkey patch to fix the following issue:
|
23
|
-
# /
|
24
|
-
# in `ensure_shared_example_group_name_not_taken': Shared example group '
|
25
|
-
|
26
|
-
module
|
27
|
-
module
|
28
|
-
|
29
|
-
|
23
|
+
# /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rspec-core-2.6.4/lib/rspec/core/shared_example_group.rb:59:
|
24
|
+
# in `ensure_shared_example_group_name_not_taken': Shared example group 'SharedRhoconnectHelper' already exists (ArgumentError)
|
25
|
+
if RUBY_VERSION =~ /1.8/
|
26
|
+
module RSpec
|
27
|
+
module Core
|
28
|
+
module SharedExampleGroup
|
29
|
+
private
|
30
|
+
def ensure_shared_example_group_name_not_taken(name)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -8,10 +8,10 @@ module Constants
|
|
8
8
|
"libaprutil1-dev",
|
9
9
|
"dtach"]
|
10
10
|
|
11
|
-
REDIS = "redis-2.4.
|
11
|
+
REDIS = "redis-2.4.6"
|
12
12
|
SQLITE3 = "sqlite-autoconf-3070701"
|
13
13
|
RUBY = "ruby-enterprise-1.8.7-2011.03"
|
14
|
-
Nginx = "nginx-1.0.
|
14
|
+
Nginx = "nginx-1.0.11"
|
15
15
|
|
16
16
|
SOFTWARE = [ REDIS, SQLITE3, RUBY, Nginx ]
|
17
17
|
|
@@ -1,11 +1,12 @@
|
|
1
1
|
desc 'Creates and uploads apt and rpm repos.'
|
2
2
|
task "build:repos" => ['build:deb', 'build:rpm'] do
|
3
3
|
require 'find'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
# CONSTANTS
|
6
7
|
|
7
8
|
PKG_DIR = '/packages'
|
8
|
-
|
9
|
+
BETA_PKG_DIR = '/beta-packages'
|
9
10
|
BUCKET = 'rhoconnect'
|
10
11
|
|
11
12
|
def cmd(cmd)
|
@@ -40,7 +41,7 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
|
|
40
41
|
"Codename: rhoconnect\n" +
|
41
42
|
"Architectures: i386 amd64\n" +
|
42
43
|
"Components: main\n" +
|
43
|
-
"Description: Rhoconnect APT Repository"
|
44
|
+
"Description: Rhoconnect APT Repository\n"
|
44
45
|
cmd "sudo touch #{filename}/distributions"
|
45
46
|
cmd "sudo chmod 777 #{filename}/distributions"
|
46
47
|
|
@@ -57,16 +58,16 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
|
|
57
58
|
def copy_files
|
58
59
|
# Copy the packages to their respective directory
|
59
60
|
Find.find('./pkg') do |file|
|
61
|
+
puts "File: #{file}"
|
60
62
|
if !FileTest.directory?(file)
|
61
63
|
dest_dir = File.extname(file)
|
62
|
-
#get rid of '.' before extension name
|
63
|
-
dest_dir[0] = ''
|
64
|
+
dest_dir[0] = '' #get rid of '.' before extension name
|
64
65
|
if dest_dir == 'deb' || dest_dir == 'rpm'
|
65
66
|
if dest_dir == 'deb'
|
66
67
|
@deb_pkg = File.basename(file)
|
67
68
|
end #if
|
68
69
|
file_path = File.expand_path(file)
|
69
|
-
cmd "sudo cp -
|
70
|
+
cmd "sudo cp -r #{file_path} #{PKG_DIR}/#{dest_dir}"
|
70
71
|
end #if
|
71
72
|
end #if
|
72
73
|
end #do
|
@@ -83,6 +84,20 @@ task "build:repos" => ['build:deb', 'build:rpm'] do
|
|
83
84
|
cmd "sudo createrepo #{PKG_DIR}/rpm"
|
84
85
|
|
85
86
|
# Call S3 upload script
|
86
|
-
|
87
|
-
|
87
|
+
['deb', 'rpm'].each do |dir|
|
88
|
+
beta = 0
|
89
|
+
pkg_dir = PKG_DIR
|
90
|
+
Find.find("#{PKG_DIR}/#{dir}") do |file|
|
91
|
+
if File.extname(file) =~ /deb|rpm/
|
92
|
+
file =~ /.*beta.*/ ? beta += 1 : beta = beta
|
93
|
+
pkg_dir = BETA_PKG_DIR
|
94
|
+
cmd "sudo mkdir #{BETA_PKG_DIR}" unless File.directory? BETA_PKG_DIR
|
95
|
+
cmd "sudo chmod 777 #{BETA_PKG_DIR}"
|
96
|
+
# If one beta pkg is found, break.
|
97
|
+
break
|
98
|
+
end #if
|
99
|
+
end #do
|
100
|
+
cmd "sudo cp -rf #{PKG_DIR}/#{dir} #{BETA_PKG_DIR}/#{dir}"
|
101
|
+
cmd "sudo ruby ./installer/utils/package_upload/s3_upload.rb #{pkg_dir}/#{dir} #{BUCKET} #{@raked}"
|
102
|
+
end #do
|
88
103
|
end #build:repos
|