celluloid 0.18.0.pre → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +258 -39
  3. data/CONDUCT.md +13 -0
  4. data/CONTRIBUTING.md +39 -0
  5. data/README.md +54 -165
  6. data/REFACTOR.md +1 -0
  7. data/architecture.md +120 -0
  8. data/examples/basic_usage.rb +1 -1
  9. data/examples/configurations.rb +78 -0
  10. data/examples/futures.rb +1 -1
  11. data/examples/ring.rb +5 -4
  12. data/examples/simple_pmap.rb +1 -1
  13. data/examples/stack.rb +2 -2
  14. data/examples/supervisors_and_registry.rb +82 -0
  15. data/examples/timers.rb +2 -2
  16. data/lib/celluloid.rb +72 -47
  17. data/lib/celluloid/actor.rb +27 -17
  18. data/lib/celluloid/actor/system.rb +13 -29
  19. data/lib/celluloid/autostart.rb +5 -5
  20. data/lib/celluloid/call/async.rb +2 -0
  21. data/lib/celluloid/call/sync.rb +10 -3
  22. data/lib/celluloid/calls.rb +5 -12
  23. data/lib/celluloid/cell.rb +5 -9
  24. data/lib/celluloid/condition.rb +3 -3
  25. data/lib/celluloid/core_ext.rb +0 -2
  26. data/lib/celluloid/debug.rb +3 -0
  27. data/lib/celluloid/exceptions.rb +2 -2
  28. data/lib/celluloid/future.rb +7 -9
  29. data/lib/celluloid/group.rb +12 -8
  30. data/lib/celluloid/group/pool.rb +1 -3
  31. data/lib/celluloid/group/spawner.rb +2 -6
  32. data/lib/celluloid/internals/call_chain.rb +15 -0
  33. data/lib/celluloid/internals/cpu_counter.rb +62 -0
  34. data/lib/celluloid/internals/handlers.rb +42 -0
  35. data/lib/celluloid/internals/links.rb +38 -0
  36. data/lib/celluloid/internals/logger.rb +104 -0
  37. data/lib/celluloid/internals/method.rb +34 -0
  38. data/lib/celluloid/internals/properties.rb +32 -0
  39. data/lib/celluloid/internals/receivers.rb +64 -0
  40. data/lib/celluloid/internals/registry.rb +102 -0
  41. data/lib/celluloid/internals/responses.rb +46 -0
  42. data/lib/celluloid/internals/signals.rb +24 -0
  43. data/lib/celluloid/internals/stack.rb +74 -0
  44. data/lib/celluloid/internals/stack/dump.rb +12 -0
  45. data/lib/celluloid/internals/stack/states.rb +72 -0
  46. data/lib/celluloid/internals/stack/summary.rb +12 -0
  47. data/lib/celluloid/internals/task_set.rb +51 -0
  48. data/lib/celluloid/internals/thread_handle.rb +52 -0
  49. data/lib/celluloid/internals/uuid.rb +40 -0
  50. data/lib/celluloid/logging/incident.rb +21 -0
  51. data/lib/celluloid/logging/incident_logger.rb +147 -0
  52. data/lib/celluloid/logging/incident_reporter.rb +49 -0
  53. data/lib/celluloid/logging/log_event.rb +20 -0
  54. data/lib/celluloid/logging/ring_buffer.rb +64 -0
  55. data/lib/celluloid/mailbox.rb +22 -9
  56. data/lib/celluloid/mailbox/evented.rb +13 -5
  57. data/lib/celluloid/notifications.rb +95 -0
  58. data/lib/celluloid/pool.rb +6 -0
  59. data/lib/celluloid/probe.rb +81 -0
  60. data/lib/celluloid/proxy/abstract.rb +9 -9
  61. data/lib/celluloid/proxy/async.rb +1 -1
  62. data/lib/celluloid/proxy/block.rb +2 -2
  63. data/lib/celluloid/proxy/cell.rb +1 -1
  64. data/lib/celluloid/proxy/future.rb +2 -4
  65. data/lib/celluloid/proxy/sync.rb +1 -3
  66. data/lib/celluloid/rspec.rb +22 -33
  67. data/lib/celluloid/supervision.rb +17 -0
  68. data/lib/celluloid/supervision/configuration.rb +169 -0
  69. data/lib/celluloid/supervision/configuration/injections.rb +8 -0
  70. data/lib/celluloid/supervision/configuration/instance.rb +113 -0
  71. data/lib/celluloid/supervision/constants.rb +123 -0
  72. data/lib/celluloid/supervision/container.rb +144 -0
  73. data/lib/celluloid/supervision/container/behavior.rb +89 -0
  74. data/lib/celluloid/supervision/container/behavior/pool.rb +71 -0
  75. data/lib/celluloid/supervision/container/behavior/tree.rb +23 -0
  76. data/lib/celluloid/supervision/container/injections.rb +8 -0
  77. data/lib/celluloid/supervision/container/instance.rb +116 -0
  78. data/lib/celluloid/supervision/container/pool.rb +210 -0
  79. data/lib/celluloid/supervision/service.rb +27 -0
  80. data/lib/celluloid/supervision/supervise.rb +34 -0
  81. data/lib/celluloid/supervision/validation.rb +40 -0
  82. data/lib/celluloid/supervision/version.rb +5 -0
  83. data/lib/celluloid/system_events.rb +11 -6
  84. data/lib/celluloid/task.rb +25 -12
  85. data/lib/celluloid/task/fibered.rb +2 -0
  86. data/lib/celluloid/task/threaded.rb +3 -3
  87. data/lib/celluloid/test.rb +5 -2
  88. data/lib/celluloid/thread.rb +0 -2
  89. data/lib/celluloid/version.rb +1 -1
  90. data/spec/celluloid/block_spec.rb +29 -32
  91. data/spec/celluloid/calls_spec.rb +5 -15
  92. data/spec/celluloid/future_spec.rb +2 -2
  93. data/spec/celluloid/internals/cpu_counter_spec.rb +129 -0
  94. data/spec/celluloid/internals/links_spec.rb +43 -0
  95. data/spec/celluloid/internals/properties_spec.rb +40 -0
  96. data/spec/celluloid/internals/registry_spec.rb +62 -0
  97. data/spec/celluloid/internals/stack/dump_spec.rb +4 -0
  98. data/spec/celluloid/internals/stack/summary_spec.rb +4 -0
  99. data/spec/celluloid/internals/thread_handle_spec.rb +60 -0
  100. data/spec/celluloid/internals/uuid_spec.rb +9 -0
  101. data/spec/celluloid/logging/ring_buffer_spec.rb +36 -0
  102. data/spec/celluloid/mailbox/evented_spec.rb +11 -22
  103. data/spec/celluloid/misc/leak_spec.rb +3 -4
  104. data/spec/celluloid/notifications_spec.rb +140 -0
  105. data/spec/celluloid/probe_spec.rb +102 -0
  106. data/spec/celluloid/proxy_spec.rb +30 -30
  107. data/spec/celluloid/supervision/behavior_spec.rb +74 -0
  108. data/spec/celluloid/supervision/configuration_spec.rb +181 -0
  109. data/spec/celluloid/supervision/container_spec.rb +72 -0
  110. data/spec/celluloid/supervision/instance_spec.rb +13 -0
  111. data/spec/celluloid/supervision/root_spec.rb +28 -0
  112. data/spec/celluloid/supervision/supervisor_spec.rb +93 -0
  113. data/spec/celluloid/task/fibered_spec.rb +1 -3
  114. data/spec/celluloid/task/threaded_spec.rb +1 -3
  115. data/spec/shared/actor_examples.rb +58 -33
  116. data/spec/shared/group_examples.rb +2 -2
  117. data/spec/shared/mailbox_examples.rb +1 -1
  118. data/spec/shared/stack_examples.rb +87 -0
  119. data/spec/shared/task_examples.rb +2 -3
  120. data/spec/spec_helper.rb +2 -4
  121. data/spec/support/configure_rspec.rb +2 -3
  122. data/spec/support/coverage.rb +2 -4
  123. data/spec/support/crash_checking.rb +2 -2
  124. data/spec/support/examples/actor_class.rb +3 -8
  125. data/spec/support/examples/call_class.rb +2 -2
  126. data/spec/support/examples/container_class.rb +35 -0
  127. data/spec/support/examples/evented_mailbox_class.rb +1 -2
  128. data/spec/support/examples/stack_classes.rb +58 -0
  129. data/spec/support/examples/stack_methods.rb +23 -0
  130. data/spec/support/examples/subordinate_class.rb +19 -0
  131. data/spec/support/logging.rb +2 -34
  132. data/spec/support/loose_threads.rb +3 -16
  133. data/spec/support/reset_class_variables.rb +5 -1
  134. data/spec/support/stubbing.rb +1 -1
  135. metadata +91 -323
  136. data/culture/CONDUCT.md +0 -38
  137. data/culture/GSoC/1010-why_we_will_participate.md +0 -17
  138. data/culture/GSoC/1020-how_mentors_stay_engaged.md +0 -7
  139. data/culture/GSoC/1030-keeping_students_on_schedule.md +0 -9
  140. data/culture/GSoC/1040-getting_students_involved.md +0 -5
  141. data/culture/GSoC/1050-student_involvement_after.md +0 -5
  142. data/culture/GSoC/README.md +0 -16
  143. data/culture/Gemfile +0 -9
  144. data/culture/LICENSE.txt +0 -22
  145. data/culture/README.md +0 -22
  146. data/culture/Rakefile +0 -5
  147. data/culture/SYNC.md +0 -70
  148. data/culture/celluloid-culture.gemspec +0 -18
  149. data/culture/gems/README.md +0 -39
  150. data/culture/gems/dependencies.yml +0 -93
  151. data/culture/gems/loader.rb +0 -101
  152. data/culture/rubocop/README.md +0 -38
  153. data/culture/rubocop/lint.yml +0 -8
  154. data/culture/rubocop/metrics.yml +0 -15
  155. data/culture/rubocop/perf.yml +0 -0
  156. data/culture/rubocop/rubocop.yml +0 -5
  157. data/culture/rubocop/style.yml +0 -61
  158. data/culture/spec/gems_spec.rb +0 -2
  159. data/culture/spec/spec_helper.rb +0 -0
  160. data/culture/spec/sync_spec.rb +0 -2
  161. data/culture/sync.rb +0 -56
  162. data/culture/tasks/rspec.rake +0 -5
  163. data/culture/tasks/rubocop.rake +0 -2
  164. data/lib/celluloid/actor/manager.rb +0 -7
  165. data/lib/celluloid/backported.rb +0 -2
  166. data/lib/celluloid/current.rb +0 -2
  167. data/lib/celluloid/deprecate.rb +0 -34
  168. data/lib/celluloid/fiber.rb +0 -32
  169. data/lib/celluloid/managed.rb +0 -3
  170. data/lib/celluloid/notices.rb +0 -15
  171. data/spec/deprecate/actor_system_spec.rb +0 -72
  172. data/spec/deprecate/block_spec.rb +0 -52
  173. data/spec/deprecate/calls_spec.rb +0 -39
  174. data/spec/deprecate/evented_mailbox_spec.rb +0 -34
  175. data/spec/deprecate/future_spec.rb +0 -32
  176. data/spec/deprecate/internal_pool_spec.rb +0 -4
  177. data/spec/support/env.rb +0 -21
data/CONDUCT.md ADDED
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,39 @@
1
+ # Contribution Guidelines
2
+
3
+ If you are seeking support, or for discussions about Celluloid, you can use [the mailing list](http://groups.google.com/group/celluloid-ruby) or the IRC channel, #celluloid on freenode.
4
+
5
+ If you encounter an issue with Celluloid itself, you should go through the following checklist:
6
+
7
+ * Is this a known bug or are you falling into a common trap? Check the [Gotchas wiki page](https://github.com/celluloid/celluloid/wiki/Gotchas).
8
+ * Is there already an issue filed which looks like your issue? Check the [issue tracker](https://github.com/celluloid/celluloid/issues).
9
+ * Is the problem present in the latest released version of Celluloid? Upgrade and check!
10
+ * Is the problem present on the master branch of Celluloid? [Run pre-release](#running-pre-release-celluloid) from source control and check!
11
+
12
+ If you don't get anywhere with this checklist, please feel free to [file a bug report](#filing-a-bug-report).
13
+
14
+ ## Running pre-release Celluloid
15
+
16
+ If you encounter a bug, it's entirely possible that it has already been fixed but not yet included in a released version. You can establish this by trying to run your application with a pre-release version of Celluloid direct from source control. You can do this by modifying your application's Gemfile as follows:
17
+
18
+ ```ruby
19
+ gem 'celluloid', github: 'celluloid', submodules: true
20
+ ```
21
+
22
+ If it is suggested to you that you try a different branch, add `branch: 'somebranch'`.
23
+
24
+ If the problem is resolved, feel free to voice your desire for a new release of Celluloid on IRC (`irc.freenode.net/#celluloid`).
25
+
26
+ If it persists, you should consider [filing a bug report](#filing-a-bug-report).
27
+
28
+ ## Filing a bug report
29
+
30
+ * Bug reports should be filed on the [GitHub issue tracker](https://github.com/celluloid/celluloid/issues). Bug reports should contain the following things:
31
+ * A sensible subject that helps quickly identify the issue.
32
+ * Full steps to reproduce the issue, including minimal reproduction code. A minimal reproduction means only what is necessary to display the problem and nothing more. This is perhaps the most important thing, don't skip it!
33
+ * Output from a reproduction.
34
+ * Full references for version numbers (of Celluloid, dependencies, Ruby, Operating System, etc). One easy way to do this is to post your Gemfile.lock, though you will still need to tell us what version of Ruby is in use.
35
+ * See: [Triage Process](https://github.com/celluloid/celluloid/wiki/Triage-Process)
36
+ * Some more guidelines on filing good bug reports:
37
+ * http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
38
+ * http://itscommonsensestupid.blogspot.com/2008/07/tips-to-write-good-bug-report.html
39
+ * http://timheuer.com/blog/archive/2011/10/12/anatomy-of-a-good-bug-report.aspx
data/README.md CHANGED
@@ -1,89 +1,45 @@
1
- ![Celluloid](https://raw.github.com/celluloid/celluloid-logos/master/celluloid/celluloid.png)
2
- =========
3
- [![Gem Version](https://badge.fury.io/rb/celluloid.svg)](http://rubygems.org/gems/celluloid)
4
- [![Build Status](https://secure.travis-ci.org/celluloid/celluloid.svg?branch=master)](http://travis-ci.org/celluloid/celluloid)
5
- [![Code Climate](https://codeclimate.com/github/celluloid/celluloid.svg)](https://codeclimate.com/github/celluloid/celluloid)
6
- [![Coverage Status](https://coveralls.io/repos/celluloid/celluloid/badge.svg?branch=master)](https://coveralls.io/r/celluloid/celluloid)
7
-
8
- > "I thought of objects being like biological cells and/or individual
9
- > computers on a network, only able to communicate with messages"
10
- > _--Alan Kay, creator of Smalltalk, on the meaning of "object oriented programming"_
11
-
12
- Celluloid provides a simple and natural way to build fault-tolerant concurrent
13
- programs in Ruby. With Celluloid, you can build systems out of concurrent
14
- objects just as easily as you build sequential programs out of regular objects.
15
- Recommended for any developer, including novices, Celluloid should help ease
16
- your worries about building multithreaded Ruby programs.
17
-
18
- Much of the difficulty with building concurrent programs in Ruby arises because
19
- the object-oriented mechanisms for structuring code, such as classes and
20
- inheritance, are separate from the concurrency mechanisms, such as threads and
21
- locks. Celluloid combines these into a single structure, an active object
22
- running within a thread, called an "actor", or in Celluloid vernacular, a "cell".
23
-
24
- By combining concurrency with object oriented programming, Celluloid frees you
25
- up from worry about where to use threads and locks. Celluloid combines them
26
- together into a single concurrent object oriented programming model,
27
- encapsulating state in concurrent objects and thus avoiding many of the
28
- problems associated with multithreaded programming. Celluloid provides many
29
- features which make concurrent programming simple, easy, and fun:
30
-
31
- * __Automatic "deadlock-free" synchronization:__ Celluloid uses a concurrent
32
- object model which combines method dispatch and thread synchronization.
33
- Each actor is a concurrent object running in its own thread, and every method
34
- invocation is wrapped in a fiber that can be suspended whenever it calls
35
- out to other actors, and resumed when the response is available. This means
36
- methods which are waiting for responses from other actors, external messages,
37
- or other system events (including I/O with Celluloid::IO) can be suspended
38
- and will never block other methods that are ready to run. This won't prevent
39
- bugs in Celluloid, bugs in other thread-safe libraries you use, and even
40
- certain "dangerous" features of Celluloid from causing your program to
41
- deadlock, but in general, programs built with Celluloid will be naturally
42
- immune to deadlocks.
43
-
44
- * __Fault-tolerance:__ Celluloid has taken to heart many of Erlang's ideas
45
- about fault-tolerance in order to enable self-healing applications.
46
- The central idea: have you tried turning it off and on again? Celluloid
47
- takes care of rebooting subcomponents of your application when they crash,
48
- whether it's a single actor, or large (potentially multi-tiered) groups of
49
- actors that are all interdependent. This means rather than worrying about
50
- rescuing every last exception, you can just sit back, relax, and let parts
51
- of your program crash, knowing Celluloid will automatically reboot them in
52
- a clean state. Celluloid provides its own implementation of the core
53
- fault-tolerance concepts in Erlang including [linking](https://github.com/celluloid/celluloid/wiki/Linking),
54
- [supervisors](https://github.com/celluloid/celluloid/wiki/Supervisors),
55
- and [supervision groups](https://github.com/celluloid/celluloid/wiki/Supervision-Groups).
56
-
57
- * __[Futures](https://github.com/celluloid/celluloid/wiki/futures):__
58
- Ever wanted to call a method "in the background" and retrieve the
59
- value it returns later? Celluloid futures do just that. It's like
60
- calling ahead to a restaurant to place an order, so they can work
61
- on preparing your food while you're on your way to pick it up.
62
- When you ask for a method's return value, it's returned immediately
63
- if the method has already completed, or otherwise the current method is
64
- suspended until the value becomes available.
65
-
66
- You can also build distributed systems with Celluloid using its
67
- [sister project DCell](https://github.com/celluloid/dcell). Evented IO similar
68
- to EventMachine (with a synchronous API instead of callback/deferrable soup)
69
- is available through the [Celluloid::IO](https://github.com/celluloid/celluloid-io)
70
- library.
71
-
72
- Like Celluloid? [Join the mailing list/Google Group](http://groups.google.com/group/celluloid-ruby)
73
- or visit us on IRC at #celluloid on freenode
74
-
75
- ### Is it any good?
76
-
77
- [Yes](http://news.ycombinator.com/item?id=3067434)
78
-
79
- ### Is It "Production Ready™"?
80
-
81
- Yes, many users are now running Celluloid in production.
82
-
83
- * **See:** [Projects Using Celluloid](https://github.com/celluloid/celluloid/wiki/Projects-Using-Celluloid)
84
-
85
- Documentation
86
- -------------
1
+ # ![Celluloid][celluloid-logo-image-raw]
2
+
3
+ [![Gem Version][gem-image]][gem-link]
4
+ [![MIT licensed][license-image]][license-link]
5
+ [![Build Status][build-image]][build-link]
6
+ [![Maintained: no][maintained-image]][maintained-link]
7
+ [![Gitter Chat][gitter-image]][gitter-link]
8
+
9
+ [celluloid-logo-image-raw]: https://raw.github.com/celluloid/celluloid-logos/master/celluloid/celluloid.png
10
+ [gem-image]: https://badge.fury.io/rb/celluloid.svg
11
+ [gem-link]: http://rubygems.org/gems/celluloid
12
+ [build-image]: https://secure.travis-ci.org/celluloid/celluloid.svg?branch=master
13
+ [build-link]: http://travis-ci.org/celluloid/celluloid
14
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg
15
+ [license-link]: https://github.com/celluloid/celluloid/blob/master/LICENSE.txt
16
+ [maintained-image]: https://img.shields.io/maintenance/no/2016.svg
17
+ [maintained-link]: https://github.com/celluloid/celluloid/issues/779
18
+ [gitter-image]: https://badges.gitter.im/badge.svg
19
+ [gitter-link]: https://gitter.im/celluloid/celluloid
20
+
21
+ Celluloid is a framework for building asynchronous and multithreaded Ruby
22
+ programs using object-oriented concepts.
23
+
24
+ ## Revival Process Underway
25
+
26
+ `Celluloid` is in the process of being refactored and released back into the wild during `Google Summer of Code`. The next era will not have one individual active maintainer, but a team of collaborators. Going forward, previously dormant maintainer [Donovan Keme](https://github.com/digitalextremist) is returning to support future primary maintainer [Emese Padányi](https://github.com/emesepadanyi) during `GSoC 2020`. Her plan extends past the Summer program, and aims to revive the community and codebase of `Celluloid` together. Backing this process are [Harsh Deep](https://github.com/harsh183) and `GSoC` alumni [Dilum Navanjana](https://github.com/dilumn). We welcome your collaboration and contributions in this massive work.
27
+
28
+ The codebase is being refactored to pursue a stable release with no deprecation warnings, and with this cleaned up:
29
+
30
+ # ![Diagram][celluloid-diagram]
31
+ *Diagram meticulously developed by [Emese Padányi](https://github.com/emesepadanyi)*
32
+
33
+ [celluloid-diagram]: https://raw.githubusercontent.com/celluloid/celluloid/master/documentation/ClassDiagram-class_diagram.png
34
+
35
+ ### Proudly supported by the best cloud infrastructure provider in the world: [`DigitalOcean`](https://digitalocean.com)
36
+
37
+ ## Discussion
38
+
39
+ - [Gitter Chat][gitter-link]
40
+ - [Google Group](https://groups.google.com/group/celluloid-ruby)
41
+
42
+ ## Documentation
87
43
 
88
44
  [Please see the Celluloid Wiki](https://github.com/celluloid/celluloid/wiki)
89
45
  for more detailed documentation and usage notes.
@@ -95,11 +51,9 @@ The following API documentation is also available:
95
51
  * [Celluloid class methods](http://rubydoc.info/gems/celluloid/Celluloid/ClassMethods)
96
52
  * [All Celluloid classes](http://rubydoc.info/gems/celluloid/index)
97
53
 
98
- Related Projects
99
- ----------------
54
+ ## Related Projects
100
55
 
101
- Celluloid is the parent project of a related ecosystem of other projects. If you
102
- like Celluloid we definitely recommend you check them out:
56
+ See also: [Projects Using Celluloid](https://github.com/celluloid/celluloid/wiki/Projects-Using-Celluloid)
103
57
 
104
58
  * [Reel][reel]: An "evented" web server based on `Celluloid::IO`
105
59
  * [DCell][dcell]: The Celluloid actor protocol distributed over 0MQ
@@ -108,93 +62,28 @@ like Celluloid we definitely recommend you check them out:
108
62
  * [Celluloid::ZMQ][celluloid-zmq]: "Evented" 0MQ support for `Celluloid` actors
109
63
  * [Celluloid::DNS][celluloid-dns]: An "evented" DNS server based on `Celluloid::IO`
110
64
  * [Celluloid::SMTP][celluloid-smtp]: An "evented" SMTP server based on `Celluloid::IO`
111
- * [Lattice][lattice]: A concurrent realtime web framework based on `Celluloid::IO`
112
65
  * [nio4r][nio4r]: "New IO for Ruby": high performance IO selectors
113
66
  * [Timers][timers]: A generic Ruby timer library for event-based systems
114
67
 
115
68
  [reel]: https://github.com/celluloid/reel/
116
69
  [dcell]: https://github.com/celluloid/dcell/
117
- [ecell]: https://github.com/celluloid/ecell/
70
+ [ecell]: https://github.com/abstractive/ecell/
118
71
  [celluloid-io]: https://github.com/celluloid/celluloid-io/
119
72
  [celluloid-zmq]: https://github.com/celluloid/celluloid-zmq/
120
73
  [celluloid-dns]: https://github.com/celluloid/celluloid-dns/
121
- [celluloid-smtp]: https://github.com/celluloid/celluloid-smtp/
122
- [lattice]: https://github.com/celluloid/lattice/
74
+ [celluloid-smtp]: https://github.com/abstractive/celluloid-smtp/
123
75
  [nio4r]: https://github.com/celluloid/nio4r/
124
76
  [timers]: https://github.com/celluloid/timers/
125
77
 
126
- Installation
127
- ------------
128
-
129
- Add this line to your application's Gemfile:
130
-
131
- ```ruby
132
- gem 'celluloid'
133
- ```
134
-
135
- And then execute:
136
-
137
- $ bundle
138
-
139
- Or install it yourself as:
140
-
141
- $ gem install celluloid
142
-
143
- Inside of your Ruby program, require Celluloid with [newest API](https://github.com/celluloid/celluloid/wiki/DEPRECATION-WARNING):
144
-
145
- ```ruby
146
- require 'celluloid/current'
147
- ```
148
-
149
- Or to support the old API, use:
150
-
151
- ```ruby
152
- require 'celluloid/backported'
153
- ```
154
-
155
- ###Cloning via GitHub
156
-
157
- Right now `Celluloid` has a [submodule](https://github.com/celluloid/culture). To install the framework via GitHub, you need to clone the submodules as well.
158
-
159
- __Clone from scratch:__
160
-
161
- $ git clone --recursive https://github.com/celluloid/celluloid
162
-
163
- __If you already cloned `Celluloid` without submodules:__
164
-
165
- Run the following command in the directory containing `Celluloid`:
166
-
167
- git submodule update --init --recursive
168
-
169
- Supported Platforms
170
- -------------------
171
-
172
- Celluloid works on Ruby 2.0+, JRuby 1.7+, and Rubinius 2.0.
173
-
174
- JRuby or Rubinius are the preferred platforms as they support true thread-level
175
- parallelism when executing Ruby code, whereas MRI/YARV is constrained by a global
176
- interpreter lock (GIL) and can only execute one thread at a time.
177
-
178
- Celluloid requires Ruby 1.9 mode or higher on all interpreters.
179
-
180
- Additional Reading
181
- ------------------
182
-
183
- * [Concurrent Object-Oriented Programming in Python with
184
- ATOM](http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=11A3EACE78AAFF6D6D62A64118AFCA7C?doi=10.1.1.47.5074&rep=rep1&type=pdf):
185
- a similar system to Celluloid written in Python
186
-
187
- Contributing to Celluloid
188
- -------------------------
78
+ ## Contributing to Celluloid
189
79
 
190
- * Fork this repository on github
191
- * Make your changes and send us a pull request
192
- * If we like them we'll merge them
193
- * If we've accepted a patch, feel free to ask for commit access
80
+ - Fork this repository on github
81
+ - Make your changes and send us a pull request
82
+ - Pull requests will be reviewed for inclusion in the project
194
83
 
195
- License
196
- -------
84
+ ## License
197
85
 
198
- Copyright (c) 2011-2016 Tony Arcieri, Donovan Keme.
86
+ Copyright (c) 2011-2018 Tony Arcieri, Donovan Keme.
199
87
 
200
- Distributed under the MIT License. See [LICENSE.txt](https://github.com/celluloid/celluloid/blob/master/LICENSE.txt) for further details.
88
+ Distributed under the MIT License. See [LICENSE.txt](https://github.com/celluloid/celluloid/blob/master/LICENSE.txt)
89
+ for further details.
data/REFACTOR.md ADDED
@@ -0,0 +1 @@
1
+ 20200703113000: `require "celluloid/current"` is removed. use `require "celluloid"`
data/architecture.md ADDED
@@ -0,0 +1,120 @@
1
+ # Architecture
2
+
3
+ The purpose of this document is to provide an overview of the `Celluloid` project architecture. It is intended as a learning tool for
4
+ GSoC (Google Summer of Code) and for anyone else interested in peeking under the hood to figure out how Celluloid works.
5
+
6
+ This document will evolve since the people writing it are learning the project too. It will likely evolve in the following manner:
7
+
8
+ 1. Document all major classes by describing the purpose of each one.
9
+ 2. Document the dependencies between classes described in item 1.
10
+ 3. Describe the flow of messages between the classes documented in items 1 and 2.
11
+ 4. Generate a Big Picture overview of the overall Celluloid architecture.
12
+ 5. Create a flew graphics to depict class dependencies and message flows (perhaps as a directed acyclic graph).
13
+
14
+ ## Document Status
15
+
16
+ The document is working on item 1.
17
+
18
+ ## Required Libraries
19
+ `logger`
20
+ `thread`
21
+ `timeout`
22
+ `set`
23
+
24
+ ## Require Lifecycle
25
+ Document the steps taken from the moment `require "celluloid"` is executed by the runtime.
26
+
27
+ The file `celluloid.rb` is read in by the runtime. This file requires some standard libraries like `Thread` and `Set` (see Required Libraries for full list) and initializes the `Celluloid` module namespace. It then sets up a Celluloid singleton class which will contain utility functions that need to be accessed from anywhere. Think of these singleton methods as global methods. These specific methods should be considered private to the library and should not be directly called by user code.
28
+
29
+ From here it continues to `extend` and `include` other modules so that any Ruby object that executes `include Celluloid` as part of its class definition automatically gains all of the Celluloid magic.
30
+
31
+ Next, it defines regular methods within the Celluloid namespace. These are also global methods but they are essentially the public API to the outside world. These methods (such as `current_actor` and `terminate`) can be called by user code.
32
+
33
+ Next we have a list of `require`'d subfiles. This loads the remainder of the library in preparation to start running.
34
+
35
+ Next, the code sets up two global default settings for the `task_class` and `group_class`. I don't know what these are yet but by exposing them this way it's clearly intended for these items to be defined in such a way that user code can override them with use-case-specific code. The code here can also read names from the environment variables to set the defaults. This is likely intended for use by the spec/test system.
36
+
37
+ Lastly, the code registers some methods for shutdown to terminate all actors `at_exit` and then initializes the system.
38
+
39
+ To boot the system, call `require 'celluloid'`.
40
+
41
+ ## Supervision Lifecycle
42
+ The final call to `Actor::System.new.start` kicks off the top level supervisor. The supervisor container is an actor and it will keep track of all defined actors as they are added for supervision. A user may create an actor that is not supervised, so the top-level supervisor does not necessarily have a reference to every actor in the system.
43
+
44
+ The Registry is also created at this time and lives within the main container. Actors can be added to the registry even if they are not supervised. The two concepts are separate even though the code is somewhat comingled.
45
+
46
+ ## Classes / Modules
47
+
48
+ ### Celluloid Module
49
+ * Sets up class accessors used throughout/globally such as `logger`
50
+ * When using `include Celluloid` on a class, it performs the following work during `include`:
51
+ * Extends `ClassMethods` and `Internals::Properties`
52
+ * Includes `InstanceMethods`
53
+ * Sets properties on the class object.
54
+ * Removes `trap_exit` and `exclusive` if they exist on the singleton class so that Celluloid can redefine them for itself.
55
+ * Defines class methods inside the `Celluloid` namespace such as `actor?` and `mailbox` and `cores`. These are utility functions. They are defined on the Celluloid singleton.
56
+ * Provides the entry method `boot` to start up the whole system and its opposite `shutdown` to terminate everything.
57
+
58
+ #### Depends On Classes
59
+ * Internals::Logger
60
+ * Internals::CallChain
61
+ * Actor::System
62
+ * Celluloid::Mailbox
63
+ * Thread (primarily for Thread.current to access fiber locals like `:celluloid_actor`)
64
+ * Future
65
+
66
+ ### ClassMethods Module
67
+ This class contains class-level methods which are added to every user class that contains `include Celluloid`.
68
+
69
+ * Overrides `new` for the class object.
70
+
71
+ #### Depends On Classes
72
+ * Cell
73
+ * Actor
74
+ * Celluloid
75
+
76
+ ### InstanceMethods Module
77
+ This module contains instance-level methods which are added to every user class that contains `include Celluloid`.
78
+
79
+ #### Depends on Classes
80
+ * Actor
81
+ * Celluloid
82
+
83
+
84
+ ### Actor::System class
85
+ Is created and `start`'ed as part of the entire boot sequence. This class provides essential services utilized by the rest of the library such as the Registry and the top-level Supervisor.
86
+
87
+ #### Lifecycle
88
+ Creates the `Registry` and initializes the `Celluloid.group_class`. Upon `start` it makes sure that it switches the `Thread.current[:celluloid_actor_system]` to itself, then defines and deploys the `Root` services.
89
+
90
+ #### Depends On Classes
91
+ * Supervision::Service::Root which is in gem `celluloid-supervision`
92
+ * Celluloid::Notifications::Fanout
93
+ * Celluloid::IncidentReporter
94
+ * Celluloid::Supervision::Service::Public
95
+ * Celluloid::Actor::Manager
96
+ * Celluloid
97
+ * Internals::Registry
98
+ * Celluloid.group_class
99
+
100
+ ## Gem - celluloid-supervision
101
+ Necessary for the core system to boot.
102
+
103
+ Really has only two classes/modules of note. One is Supervision::Container which is an actor that keeps track of all actors under supervision. It also handles restart. Two is Supervision::Configuration. This class manages the several different ways that an actor may be placed under supervision, arguments passed to it, and other data.
104
+
105
+ Be careful when reading the code. Each file in the gem relies on open Ruby classes. These files reopen previously defined classes and add more behavior, so to get a complete picture for what the Configuration and Container classes can do you must look through all of the files. While this logical separation of business logic to its own file is neat, it adds to the cognitive load when reading the code since the entire class defintion is spread over multiple files.
106
+
107
+ ### Supervision::Service::Root
108
+
109
+ #### Depends On Classes
110
+ * Supervision::Container
111
+
112
+
113
+ ### Supervision::Container
114
+ Stores references to Actors on behalf of a Supervisor.
115
+
116
+ This is the only class under the `Supervision` namespace that is an Actor. Every other class is a regular Ruby class.
117
+
118
+ #### Depends On Classes
119
+ * Supervision::Configuration
120
+ *
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
3
+ $LOAD_PATH.push File.expand_path("../lib", __dir__)
4
4
  require "celluloid/autostart"
5
5
 
6
6
  class Counter
@@ -0,0 +1,78 @@
1
+ require "celluloid"
2
+
3
+ puts "Use Supervision::Configuration objects!"
4
+
5
+ class Hello
6
+ include Celluloid
7
+
8
+ finalizer :ceasing
9
+
10
+ def initialize(to)
11
+ @to = to
12
+ puts "Created Hello #{@to}"
13
+ end
14
+
15
+ def ceasing
16
+ puts "Hello #{@to} go buhbye"
17
+ end
18
+ end
19
+
20
+ class FooBar
21
+ include Celluloid
22
+
23
+ finalizer :ceasing
24
+
25
+ def initialize(i = 0)
26
+ @i = i
27
+ puts "Created FooBar: #{@i}"
28
+ end
29
+
30
+ def ceasing
31
+ puts "FooBar FooBar: #{@i} go buhbye"
32
+ end
33
+ end
34
+
35
+ puts "\nInstantiated in bulk, using #deploy"
36
+
37
+ config = Celluloid::Supervision::Configuration.define([
38
+ { type: FooBar, as: :foobar },
39
+ { type: Hello, as: :hello, args: ["World"] }
40
+ ])
41
+
42
+ config.deploy
43
+ puts "...shut it down"
44
+ config.shutdown
45
+
46
+ puts "\nInstantiated in bulk, using .deploy"
47
+
48
+ config = Celluloid::Supervision::Configuration.deploy([
49
+ { type: FooBar, as: :foobar, args: [1] },
50
+ { type: Hello, as: :hello, args: ["World"] }
51
+ ])
52
+
53
+ puts "...shut it down"
54
+ config.shutdown
55
+
56
+ puts "\nInstantiated two actors individually, using a local configuration object"
57
+
58
+ config = Celluloid::Supervision::Configuration.new
59
+ config.define type: FooBar, as: :foobar11, args: [11]
60
+ config.define type: FooBar, as: :foobar33, args: [33]
61
+ config.deploy
62
+
63
+ puts "Instantiated another, which starts automatically."
64
+ puts "... using the local configuration object"
65
+ puts "... using a lazy loaded argument"
66
+ config.add type: Hello, as: :hello, args: -> { "Spinning World" }
67
+
68
+ config.shutdown
69
+
70
+ puts "\nReuse our last configuration!"
71
+
72
+ config.deploy
73
+ puts "...shut it down"
74
+ config.shutdown
75
+
76
+ puts "Thinking for 4 seconds, and 4 seconds only."
77
+ sleep 4
78
+ puts "Use Supervision::Configuration objects. Really!"