marilyn-rpc 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/README.md +39 -4
  2. data/examples/async/client.rb +0 -5
  3. data/examples/authentication/client.rb +18 -0
  4. data/examples/authentication/server.rb +30 -0
  5. data/lib/marilyn-rpc.rb +1 -1
  6. data/lib/marilyn-rpc/client.rb +21 -3
  7. data/lib/marilyn-rpc/error.rb +13 -0
  8. data/lib/marilyn-rpc/mails.rb +3 -3
  9. data/lib/marilyn-rpc/server.rb +6 -11
  10. data/lib/marilyn-rpc/service.rb +86 -11
  11. data/lib/marilyn-rpc/service_cache.rb +44 -23
  12. data/lib/marilyn-rpc/version.rb +1 -1
  13. data/spec/mails_spec.rb +2 -1
  14. data/spec/server_spec.rb +1 -1
  15. data/spec/service_cache_spec.rb +140 -0
  16. data/spec/service_spec.rb +56 -5
  17. data/spec/spec_helper.rb +5 -0
  18. metadata +10 -34
  19. data/doc/MarilynRPC.html +0 -108
  20. data/doc/MarilynRPC/CallRequestMail.html +0 -578
  21. data/doc/MarilynRPC/CallResponseMail.html +0 -418
  22. data/doc/MarilynRPC/Envelope.html +0 -705
  23. data/doc/MarilynRPC/ExceptionMail.html +0 -338
  24. data/doc/MarilynRPC/Gentleman.html +0 -658
  25. data/doc/MarilynRPC/MailFactory.html +0 -284
  26. data/doc/MarilynRPC/MailHelper.html +0 -489
  27. data/doc/MarilynRPC/NativeClient.html +0 -579
  28. data/doc/MarilynRPC/NativeClientProxy.html +0 -303
  29. data/doc/MarilynRPC/Server.html +0 -406
  30. data/doc/MarilynRPC/Service.html +0 -599
  31. data/doc/MarilynRPC/ServiceCache.html +0 -481
  32. data/doc/_index.html +0 -219
  33. data/doc/class_list.html +0 -36
  34. data/doc/css/common.css +0 -1
  35. data/doc/css/full_list.css +0 -53
  36. data/doc/css/style.css +0 -318
  37. data/doc/file.README.html +0 -154
  38. data/doc/file_list.html +0 -38
  39. data/doc/frames.html +0 -13
  40. data/doc/index.html +0 -154
  41. data/doc/js/app.js +0 -203
  42. data/doc/js/full_list.js +0 -149
  43. data/doc/js/jquery.js +0 -16
  44. data/doc/method_list.html +0 -467
  45. data/doc/top-level-namespace.html +0 -88
  46. data/spec/service_cache.rb +0 -45
@@ -1,481 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <title>Class: MarilynRPC::ServiceCache</title>
7
- <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
8
- <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
9
-
10
- <script type="text/javascript" charset="utf-8">
11
- relpath = '..';
12
- if (relpath != '') relpath += '/';
13
- </script>
14
- <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
15
- <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
16
-
17
- </head>
18
- <body>
19
- <script type="text/javascript" charset="utf-8">
20
- if (window.top.frames.main) document.body.className = 'frames';
21
- </script>
22
-
23
- <div id="header">
24
- <div id="menu">
25
-
26
- <a href="../_index.html">Index (S)</a> &raquo;
27
- <span class='title'><span class='object_link'><a href="../MarilynRPC.html" title="MarilynRPC (module)">MarilynRPC</a></span></span>
28
- &raquo;
29
- <span class="title">ServiceCache</span>
30
-
31
-
32
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
- </div>
34
-
35
- <div id="search">
36
- <a id="class_list_link" href="#">Class List</a>
37
- <a id="method_list_link" href="#">Method List</a>
38
- <a id ="file_list_link" href="#">File List</a>
39
- </div>
40
-
41
- <div class="clear"></div>
42
- </div>
43
-
44
- <iframe id="search_frame"></iframe>
45
-
46
- <div id="content"><h1>Class: MarilynRPC::ServiceCache
47
-
48
-
49
-
50
- </h1>
51
-
52
- <dl class="box">
53
-
54
- <dt class="r1">Inherits:</dt>
55
- <dd class="r1">
56
- <span class="inheritName">Object</span>
57
-
58
- <ul class="fullTree">
59
- <li>Object</li>
60
-
61
- <li class="next">MarilynRPC::ServiceCache</li>
62
-
63
- </ul>
64
- <a href="#" class="inheritanceTree">show all</a>
65
-
66
- </dd>
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
- <dt class="r2 last">Defined in:</dt>
77
- <dd class="r2 last">lib/marilyn-rpc/service_cache.rb</dd>
78
-
79
- </dl>
80
- <div class="clear"></div>
81
-
82
-
83
-
84
-
85
-
86
- <h2>
87
- Instance Method Summary
88
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
89
- </h2>
90
-
91
- <ul class="summary">
92
-
93
- <li class="public ">
94
- <span class="summary_signature">
95
-
96
- <a href="#call-instance_method" title="#call (instance method)">- (MarilynRPC::CallResponseMail, MarilynRPC::Gentleman) <strong>call</strong>(mail) </a>
97
-
98
-
99
-
100
- </span>
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
- <span class="summary_desc"><div class='inline'><p>call a service in the service cache.</p></div></span>
110
-
111
- </li>
112
-
113
-
114
- <li class="public ">
115
- <span class="summary_signature">
116
-
117
- <a href="#call_after_disconnect_callbacks%21-instance_method" title="#call_after_disconnect_callbacks! (instance method)">- (Object) <strong>call_after_disconnect_callbacks!</strong> </a>
118
-
119
-
120
-
121
- </span>
122
-
123
-
124
-
125
-
126
-
127
- <span class="private note title">Private</span>
128
-
129
-
130
- <span class="summary_desc"><div class='inline'><p>issue the disconnect callbacks for all living services of this connection.</p></div></span>
131
-
132
- </li>
133
-
134
-
135
- <li class="public ">
136
- <span class="summary_signature">
137
-
138
- <a href="#initialize-instance_method" title="#initialize (instance method)">- (ServiceCache) <strong>initialize</strong> </a>
139
-
140
-
141
-
142
- </span>
143
-
144
- <span class="note title constructor">constructor</span>
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
- <span class="summary_desc"><div class='inline'><p>creates the service cache.</p></div></span>
154
-
155
- </li>
156
-
157
-
158
- <li class="public ">
159
- <span class="summary_signature">
160
-
161
- <a href="#lookup-instance_method" title="#lookup (instance method)">- (Object) <strong>lookup</strong>(path) </a>
162
-
163
-
164
-
165
- </span>
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
- <span class="summary_desc"><div class='inline'><p>get the service from the cache or the service registry.</p></div></span>
175
-
176
- </li>
177
-
178
-
179
- </ul>
180
-
181
-
182
- <div id="constructor_details" class="method_details_list">
183
- <h2>Constructor Details</h2>
184
-
185
- <div class="method_details first">
186
- <p class="signature first" id="initialize-instance_method">
187
-
188
- - (<tt><span class='object_link'><a href="" title="MarilynRPC::ServiceCache (class)">ServiceCache</a></span></tt>) <strong>initialize</strong>
189
-
190
-
191
-
192
- </p><div class="docstring">
193
- <div class="discussion">
194
- <p>creates the service cache</p>
195
-
196
- </div>
197
- </div>
198
- <div class="tags">
199
-
200
- </div><table class="source_code">
201
- <tr>
202
- <td>
203
- <pre class="lines">
204
-
205
-
206
- 3
207
- 4
208
- 5</pre>
209
- </td>
210
- <td>
211
- <pre class="code"><span class="info file"># File 'lib/marilyn-rpc/service_cache.rb', line 3</span>
212
-
213
- <span class='def def kw'>def</span> <span class='initialize identifier id'>initialize</span>
214
- <span class='@services ivar id'>@services</span> <span class='assign token'>=</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span>
215
- <span class='end end kw'>end</span>
216
- </pre>
217
- </td>
218
- </tr>
219
- </table>
220
- </div>
221
-
222
- </div>
223
-
224
-
225
- <div id="instance_method_details" class="method_details_list">
226
- <h2>Instance Method Details</h2>
227
-
228
-
229
- <div class="method_details first">
230
- <p class="signature first" id="call-instance_method">
231
-
232
- - (<tt><span class='object_link'><a href="CallResponseMail.html" title="MarilynRPC::CallResponseMail (class)">MarilynRPC::CallResponseMail</a></span></tt>, <tt><span class='object_link'><a href="Gentleman.html" title="MarilynRPC::Gentleman (class)">MarilynRPC::Gentleman</a></span></tt>) <strong>call</strong>(mail)
233
-
234
-
235
-
236
- </p><div class="docstring">
237
- <div class="discussion">
238
- <p>call a service in the service cache</p>
239
-
240
- </div>
241
- </div>
242
- <div class="tags">
243
- <h3>Parameters:</h3>
244
- <ul class="param">
245
-
246
- <li>
247
-
248
- <span class='type'>(<tt><span class='object_link'><a href="CallRequestMail.html" title="MarilynRPC::CallRequestMail (class)">MarilynRPC::CallRequestMail</a></span></tt>)</span>
249
-
250
-
251
- <span class='name'>mail</span>
252
-
253
-
254
-
255
- &mdash;
256
- <div class='inline'><p>the mail request object, that should be handled</p></div>
257
-
258
- </li>
259
-
260
- </ul>
261
- <h3>Returns:</h3>
262
- <ul class="return">
263
-
264
- <li>
265
-
266
- <span class='type'>(<tt><span class='object_link'><a href="CallResponseMail.html" title="MarilynRPC::CallResponseMail (class)">MarilynRPC::CallResponseMail</a></span></tt>, <tt><span class='object_link'><a href="Gentleman.html" title="MarilynRPC::Gentleman (class)">MarilynRPC::Gentleman</a></span></tt>)</span>
267
-
268
-
269
-
270
-
271
- &mdash;
272
- <div class='inline'><p>either a Gentleman if the response is async or an direct response.</p></div>
273
-
274
- </li>
275
-
276
- </ul>
277
-
278
- </div><table class="source_code">
279
- <tr>
280
- <td>
281
- <pre class="lines">
282
-
283
-
284
- 12
285
- 13
286
- 14
287
- 15
288
- 16
289
- 17
290
- 18
291
- 19
292
- 20
293
- 21
294
- 22
295
- 23
296
- 24
297
- 25
298
- 26
299
- 27
300
- 28
301
- 29
302
- 30
303
- 31</pre>
304
- </td>
305
- <td>
306
- <pre class="code"><span class="info file"># File 'lib/marilyn-rpc/service_cache.rb', line 12</span>
307
-
308
- <span class='def def kw'>def</span> <span class='call identifier id'>call</span><span class='lparen token'>(</span><span class='mail identifier id'>mail</span><span class='rparen token'>)</span>
309
- <span class='comment val'># check if the correct mail object was send</span>
310
- <span class='unless unless kw'>unless</span> <span class='mail identifier id'>mail</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='MarilynRPC constant id'>MarilynRPC</span><span class='colon2 op'>::</span><span class='CallRequestMail constant id'>CallRequestMail</span><span class='rparen token'>)</span>
311
- <span class='raise identifier id'>raise</span> <span class='ArgumentError constant id'>ArgumentError</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='string val'>&quot;Expected CallRequestMail Object!&quot;</span><span class='rparen token'>)</span>
312
- <span class='end end kw'>end</span>
313
-
314
- <span class='comment val'># call the service instance using the argument of the mail</span>
315
- <span class='comment val'># puts &quot;call #{mail.method}@#{mail.path} with #{mail.args.inspect}&quot;</span>
316
- <span class='result identifier id'>result</span> <span class='assign token'>=</span> <span class='lookup identifier id'>lookup</span><span class='lparen token'>(</span><span class='mail identifier id'>mail</span><span class='dot token'>.</span><span class='path identifier id'>path</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='send identifier id'>send</span><span class='lparen token'>(</span><span class='mail identifier id'>mail</span><span class='dot token'>.</span><span class='method identifier id'>method</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='mail identifier id'>mail</span><span class='dot token'>.</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
317
- <span class='comment val'># puts &quot;result =&gt; #{result.inspect}&quot;</span>
318
-
319
- <span class='comment val'># no direct result, register callback</span>
320
- <span class='if if kw'>if</span> <span class='result identifier id'>result</span><span class='dot token'>.</span><span class='is_a? fid id'>is_a?</span> <span class='MarilynRPC constant id'>MarilynRPC</span><span class='colon2 op'>::</span><span class='Gentleman constant id'>Gentleman</span>
321
- <span class='result identifier id'>result</span><span class='dot token'>.</span><span class='tag identifier id'>tag</span> <span class='assign token'>=</span> <span class='mail identifier id'>mail</span><span class='dot token'>.</span><span class='tag identifier id'>tag</span> <span class='comment val'># set the correct mail tag for the answer</span>
322
- <span class='result identifier id'>result</span>
323
- <span class='else else kw'>else</span>
324
- <span class='comment val'># make response</span>
325
- <span class='MarilynRPC constant id'>MarilynRPC</span><span class='colon2 op'>::</span><span class='CallResponseMail constant id'>CallResponseMail</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='mail identifier id'>mail</span><span class='dot token'>.</span><span class='tag identifier id'>tag</span><span class='comma token'>,</span> <span class='result identifier id'>result</span><span class='rparen token'>)</span>
326
- <span class='end end kw'>end</span>
327
- <span class='end end kw'>end</span>
328
- </pre>
329
- </td>
330
- </tr>
331
- </table>
332
- </div>
333
-
334
- <div class="method_details ">
335
- <p class="signature " id="call_after_disconnect_callbacks!-instance_method">
336
-
337
- - (<tt>Object</tt>) <strong>call_after_disconnect_callbacks!</strong>
338
-
339
-
340
-
341
- </p><div class="docstring">
342
- <div class="discussion">
343
- <p class="note private">
344
- <strong>This method is part of a private API.</strong>
345
- You should avoid using this method if possible, as it may be removed or be changed in the future.
346
- </p>
347
- <p>issue the disconnect callbacks for all living services of this connection</p>
348
-
349
- </div>
350
- </div>
351
- <div class="tags">
352
-
353
- </div><table class="source_code">
354
- <tr>
355
- <td>
356
- <pre class="lines">
357
-
358
-
359
- 53
360
- 54
361
- 55
362
- 56
363
- 57</pre>
364
- </td>
365
- <td>
366
- <pre class="code"><span class="info file"># File 'lib/marilyn-rpc/service_cache.rb', line 53</span>
367
-
368
- <span class='def def kw'>def</span> <span class='call_after_disconnect_callbacks! fid id'>call_after_disconnect_callbacks!</span>
369
- <span class='@services ivar id'>@services</span><span class='dot token'>.</span><span class='each identifier id'>each</span> <span class='do do kw'>do</span> <span class='bitor op'>|</span><span class='path identifier id'>path</span><span class='comma token'>,</span> <span class='service identifier id'>service</span><span class='bitor op'>|</span>
370
- <span class='service identifier id'>service</span><span class='dot token'>.</span><span class='execute_after_disconnect_callback! fid id'>execute_after_disconnect_callback!</span>
371
- <span class='end end kw'>end</span>
372
- <span class='end end kw'>end</span>
373
- </pre>
374
- </td>
375
- </tr>
376
- </table>
377
- </div>
378
-
379
- <div class="method_details ">
380
- <p class="signature " id="lookup-instance_method">
381
-
382
- - (<tt>Object</tt>) <strong>lookup</strong>(path)
383
-
384
-
385
-
386
- </p><div class="docstring">
387
- <div class="discussion">
388
- <p>get the service from the cache or the service registry</p>
389
-
390
- </div>
391
- </div>
392
- <div class="tags">
393
- <h3>Parameters:</h3>
394
- <ul class="param">
395
-
396
- <li>
397
-
398
- <span class='type'>(<tt>Object</tt>)</span>
399
-
400
-
401
- <span class='name'>path</span>
402
-
403
-
404
-
405
- &mdash;
406
- <div class='inline'><p>the path to the service (using the regestry)</p></div>
407
-
408
- </li>
409
-
410
- </ul>
411
- <h3>Returns:</h3>
412
- <ul class="return">
413
-
414
- <li>
415
-
416
- <span class='type'>(<tt>Object</tt>)</span>
417
-
418
-
419
-
420
-
421
- &mdash;
422
- <div class='inline'><p>the service object or raises an ArgumentError</p></div>
423
-
424
- </li>
425
-
426
- </ul>
427
-
428
- </div><table class="source_code">
429
- <tr>
430
- <td>
431
- <pre class="lines">
432
-
433
-
434
- 36
435
- 37
436
- 38
437
- 39
438
- 40
439
- 41
440
- 42
441
- 43
442
- 44
443
- 45
444
- 46
445
- 47
446
- 48</pre>
447
- </td>
448
- <td>
449
- <pre class="code"><span class="info file"># File 'lib/marilyn-rpc/service_cache.rb', line 36</span>
450
-
451
- <span class='def def kw'>def</span> <span class='lookup identifier id'>lookup</span><span class='lparen token'>(</span><span class='path identifier id'>path</span><span class='rparen token'>)</span>
452
- <span class='comment val'># lookup the service in the cache</span>
453
- <span class='if if kw'>if</span> <span class='service identifier id'>service</span> <span class='assign token'>=</span> <span class='@services ivar id'>@services</span><span class='lbrack token'>[</span><span class='path identifier id'>path</span><span class='rbrack token'>]</span>
454
- <span class='return return kw'>return</span> <span class='service identifier id'>service</span>
455
- <span class='comment val'># it's not in the cache, so try lookup in the service registry</span>
456
- <span class='elsif elsif kw'>elsif</span> <span class='service identifier id'>service</span> <span class='assign token'>=</span> <span class='MarilynRPC constant id'>MarilynRPC</span><span class='colon2 op'>::</span><span class='Service constant id'>Service</span><span class='dot token'>.</span><span class='registry identifier id'>registry</span><span class='lbrack token'>[</span><span class='path identifier id'>path</span><span class='rbrack token'>]</span>
457
- <span class='@services ivar id'>@services</span><span class='lbrack token'>[</span><span class='path identifier id'>path</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='service identifier id'>service</span><span class='dot token'>.</span><span class='new identifier id'>new</span>
458
- <span class='@services ivar id'>@services</span><span class='lbrack token'>[</span><span class='path identifier id'>path</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='execute_after_connect_callback! fid id'>execute_after_connect_callback!</span>
459
- <span class='return return kw'>return</span> <span class='@services ivar id'>@services</span><span class='lbrack token'>[</span><span class='path identifier id'>path</span><span class='rbrack token'>]</span>
460
- <span class='else else kw'>else</span>
461
- <span class='raise identifier id'>raise</span> <span class='ArgumentError constant id'>ArgumentError</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='dstring node'>&quot;Service #{path} unknown!&quot;</span><span class='rparen token'>)</span>
462
- <span class='end end kw'>end</span>
463
- <span class='end end kw'>end</span>
464
- </pre>
465
- </td>
466
- </tr>
467
- </table>
468
- </div>
469
-
470
- </div>
471
-
472
- </div>
473
-
474
- <div id="footer">
475
- Generated on Wed Jun 8 18:26:45 2011 by
476
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
477
- 0.6.8 (ruby-1.8.7).
478
- </div>
479
-
480
- </body>
481
- </html>