langrove 0.0.4.5 → 0.0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. data/.rvmrc +29 -38
  2. data/Gemfile +13 -7
  3. data/Gemfile.lock +35 -32
  4. data/Guardfile +11 -0
  5. data/README.md +34 -0
  6. data/Rakefile +8 -6
  7. data/bin/README.md +3 -0
  8. data/bin/langrove +1 -2
  9. data/langrove.gemspec +35 -0
  10. data/lib/langrove/README.md +82 -0
  11. data/lib/langrove/adaptor/README.md +92 -0
  12. data/lib/langrove/adaptor/adaptor_base.rb +123 -0
  13. data/lib/langrove/adaptor/base.rb +12 -2
  14. data/lib/langrove/adaptor/default.rb +8 -0
  15. data/lib/langrove/adaptor/event_machine_adaptor.rb +152 -0
  16. data/lib/langrove/adaptor/query_adaptor.rb +271 -0
  17. data/lib/langrove/behaviour/README.md +170 -0
  18. data/lib/langrove/behaviour/assessable.rb +63 -0
  19. data/lib/langrove/behaviour/base.rb +16 -0
  20. data/lib/langrove/behaviour/behaviour_base.rb +341 -0
  21. data/lib/langrove/behaviour/enqueueable.rb +104 -0
  22. data/lib/langrove/behaviour/notifiable.rb +48 -0
  23. data/lib/langrove/behaviour/persistable.rb +89 -0
  24. data/lib/langrove/behaviour/preloadable.rb +63 -0
  25. data/lib/langrove/daemon/README.md +7 -0
  26. data/lib/langrove/daemon/base.rb +9 -2
  27. data/lib/langrove/daemon/daemon_base.rb +330 -0
  28. data/lib/langrove/daemon/default.rb +3 -0
  29. data/lib/langrove/ext/README.md +48 -0
  30. data/lib/langrove/ext/class_loader.rb +9 -66
  31. data/lib/langrove/ext/config_item.rb +31 -23
  32. data/lib/langrove/ext/config_loader.rb +42 -8
  33. data/lib/langrove/ext/fake_config.rb +121 -0
  34. data/lib/langrove/ext/fake_logger.rb +50 -7
  35. data/lib/langrove/ext/fake_root.rb +38 -0
  36. data/lib/langrove/ext/hash.rb +56 -0
  37. data/lib/langrove/ext/i.rb +43 -0
  38. data/lib/langrove/ext/log_monitor.rb +272 -0
  39. data/lib/langrove/ext/module_loader.rb +52 -0
  40. data/lib/langrove/ext/recursive_string.rb +94 -0
  41. data/lib/langrove/ext/spec_helper.rb +84 -0
  42. data/lib/langrove/ext.rb +8 -2
  43. data/lib/langrove/handler/README.md +161 -0
  44. data/lib/langrove/handler/base.rb +29 -2
  45. data/lib/langrove/handler/default.rb +4 -0
  46. data/lib/langrove/handler/deferred.rb +105 -0
  47. data/lib/langrove/handler/handler_base.rb +242 -0
  48. data/lib/langrove/handler/http_servlet.rb +58 -0
  49. data/lib/langrove/handler/socket.rb +21 -0
  50. data/lib/langrove/handler/socket_base.rb +127 -0
  51. data/lib/langrove/handler/socket_multiplexer.rb +438 -0
  52. data/lib/langrove/handler/web_socket.rb +41 -0
  53. data/lib/langrove/plugin/README.md +76 -0
  54. data/lib/langrove/plugin/assessor.rb +363 -0
  55. data/lib/langrove/plugin/base.rb +18 -0
  56. data/lib/langrove/plugin/buffered_persistor.rb +97 -0
  57. data/lib/langrove/plugin/enqueuer.rb +186 -0
  58. data/lib/langrove/plugin/notifier.rb +144 -0
  59. data/lib/langrove/plugin/persistor.rb +360 -0
  60. data/lib/langrove/plugin/plugin_base.rb +79 -0
  61. data/lib/langrove/plugin/yaml_file.md +5 -0
  62. data/lib/langrove/plugin/yaml_file.rb +261 -0
  63. data/lib/langrove/protocol/README.md +102 -0
  64. data/lib/langrove/protocol/base.rb +10 -2
  65. data/lib/langrove/protocol/default.rb +3 -0
  66. data/lib/langrove/protocol/protocol_base.rb +60 -0
  67. data/lib/langrove/protocol/syslog.rb +34 -27
  68. data/lib/langrove/root/README.md +17 -0
  69. data/lib/langrove/root/base.rb +11 -0
  70. data/lib/langrove/root/config.rb +163 -0
  71. data/lib/langrove/root/root_base.rb +259 -0
  72. data/lib/langrove/server/README.md +7 -0
  73. data/lib/langrove/server/base.rb +9 -0
  74. data/lib/langrove/server/default.rb +3 -0
  75. data/lib/langrove/server/server_base.rb +301 -0
  76. data/lib/langrove/version.rb +3 -1
  77. data/lib/langrove.rb +44 -1
  78. data/spec/langrove/adaptor/adaptor_base_spec.rb +33 -0
  79. data/spec/langrove/adaptor/event_machine_adaptor_spec.rb +62 -0
  80. data/spec/langrove/adaptor/query_adaptor_spec.rb +94 -0
  81. data/spec/langrove/behaviour/assessable_spec.rb +42 -0
  82. data/spec/langrove/behaviour/behaviour_base_spec.rb +396 -0
  83. data/spec/langrove/behaviour/enqueueable_spec.rb +19 -0
  84. data/spec/langrove/behaviour/notifiable_spec.rb +6 -0
  85. data/spec/langrove/behaviour/persistable_spec.rb +19 -0
  86. data/spec/langrove/behaviour/preloadable_spec.rb +19 -0
  87. data/spec/langrove/daemon/base_spec.rb +6 -0
  88. data/spec/langrove/daemon/daemon_base_spec.rb +253 -0
  89. data/spec/langrove/ext/class_loader_spec.rb +9 -12
  90. data/spec/langrove/ext/fake_config_spec.rb +50 -0
  91. data/spec/langrove/ext/fake_logger_spec.rb +12 -0
  92. data/spec/langrove/ext/fake_root_spec.rb +19 -0
  93. data/spec/langrove/ext/hash_spec.rb +54 -0
  94. data/spec/langrove/ext/i_spec.rb +11 -0
  95. data/spec/langrove/ext/log_monitor_spec.rb +254 -0
  96. data/spec/langrove/ext/module_loader_spec.rb +70 -0
  97. data/spec/langrove/ext/recursive_string_spec.rb +132 -0
  98. data/{functional/config/environments/development.rb → spec/langrove/ext/spec_helper_spec.rb} +0 -0
  99. data/spec/langrove/handler/deferred_spec.rb +9 -0
  100. data/spec/langrove/handler/handler_base_spec.rb +134 -0
  101. data/spec/langrove/handler/socket_base_spec.rb +76 -0
  102. data/spec/langrove/handler/socket_multiplexer_spec.rb +480 -0
  103. data/spec/langrove/handler/socket_spec.rb +6 -0
  104. data/spec/langrove/handler/web_socket_spec.rb +19 -0
  105. data/spec/langrove/plugin/assessor_spec.rb +278 -0
  106. data/spec/langrove/plugin/buffered_persistor_spec.rb +94 -0
  107. data/spec/langrove/plugin/enqueuer_spec.rb +136 -0
  108. data/spec/langrove/plugin/notifier_spec.rb +107 -0
  109. data/spec/langrove/plugin/persistor_spec.rb +300 -0
  110. data/spec/langrove/plugin/plugin_base_spec.rb +86 -0
  111. data/spec/langrove/plugin/yaml_file_spec.rb +348 -0
  112. data/spec/langrove/protocol/protocol_base_spec.rb +19 -0
  113. data/spec/langrove/protocol/syslog_spec.rb +5 -2
  114. data/spec/langrove/root/config_spec.rb +103 -0
  115. data/spec/langrove/root/root_base_spec.rb +93 -0
  116. data/spec/langrove/server/server_base_spec.rb +414 -0
  117. data/spec/spec_helper.rb +38 -0
  118. metadata +157 -92
  119. data/.watchr +0 -27
  120. data/functional/config/boot.rb +0 -64
  121. data/functional/config/daemons.yml +0 -13
  122. data/functional/config/environment.rb +0 -28
  123. data/functional/config/environments/production.rb +0 -0
  124. data/functional/config/environments/test.rb +0 -0
  125. data/functional/lib/client/socket_to_file.rb +0 -47
  126. data/functional/lib/daemon/datagram.rb +0 -21
  127. data/functional/lib/protocol/socket_to_file.rb +0 -55
  128. data/functional/libexec/daemon.rb +0 -68
  129. data/functional/tmp/README +0 -1
  130. data/lib/langrove/_base.rb +0 -28
  131. data/lib/langrove/adaptor_base.rb +0 -116
  132. data/lib/langrove/client/base.rb +0 -2
  133. data/lib/langrove/client/datagram.rb +0 -25
  134. data/lib/langrove/client_base.rb +0 -92
  135. data/lib/langrove/daemon_base.rb +0 -281
  136. data/lib/langrove/ext/find.rb +0 -90
  137. data/lib/langrove/ext/persistable.rb +0 -103
  138. data/lib/langrove/handler_base.rb +0 -148
  139. data/lib/langrove/job/base.rb +0 -1
  140. data/lib/langrove/job_base.rb +0 -24
  141. data/lib/langrove/protocol_base.rb +0 -32
  142. data/spec/functional/daemon/datagram_spec.rb +0 -121
  143. data/spec/langrove/adaptor_base_spec.rb +0 -63
  144. data/spec/langrove/client/datagram_spec.rb +0 -1
  145. data/spec/langrove/client_base_spec.rb +0 -5
  146. data/spec/langrove/daemon_base_spec.rb +0 -154
  147. data/spec/langrove/ext/find_spec.rb +0 -53
  148. data/spec/langrove/ext/persistable_spec.rb +0 -117
  149. data/spec/langrove/handler_base_spec.rb +0 -103
  150. data/spec/langrove/job_base_spec.rb +0 -28
  151. data/spec/langrove/protocol_base_spec.rb +0 -6
  152. data/spec/todo_spec.rb +0 -12
  153. data/tmp/README +0 -2
data/.rvmrc CHANGED
@@ -3,60 +3,51 @@
3
3
  # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
4
  # development environment upon cd'ing into the directory
5
5
 
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
- environment_id="ruby-1.9.2-p0@langrove"
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.2" > .rvmrc
9
+ environment_id="ruby-1.9.2-p318@langrove"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.12.3 (master)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
8
17
 
9
- #
10
- # Uncomment following line if you want options to be set only for given project.
11
- #
12
- # PROJECT_JRUBY_OPTS=( --1.9 )
13
-
14
- #
15
18
  # First we attempt to load the desired environment directly from the environment
16
19
  # file. This is very fast and efficient compared to running through the entire
17
20
  # CLI and selector. If you want feedback on which environment was used then
18
21
  # insert the word 'use' after --create as this triggers verbose mode.
19
- #
20
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
21
23
  && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
22
24
  then
23
25
  \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
24
-
25
- if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
26
- then
27
- . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ if [[ $- == *i* ]] # check for interactive shells
29
+ then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
30
+ else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
28
31
  fi
29
32
  else
30
33
  # If the environment file has not yet been created, use the RVM CLI to select.
31
- if ! rvm --create use "$environment_id"
32
- then
34
+ rvm --create use "$environment_id" || {
33
35
  echo "Failed to create RVM environment '${environment_id}'."
34
36
  return 1
35
- fi
37
+ }
36
38
  fi
37
39
 
38
- #
39
- # If you use an RVM gemset file to install a list of gems (*.gems), you can have
40
- # it be automatically loaded. Uncomment the following and adjust the filename if
41
- # necessary.
42
- #
43
- # filename=".gems"
44
- # if [[ -s "$filename" ]]
45
- # then
46
- # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
47
- # fi
48
40
 
49
41
  # If you use bundler, this might be useful to you:
50
- # if command -v bundle && [[ -s Gemfile ]]
42
+ # if [[ -s Gemfile ]] && {
43
+ # ! builtin command -v bundle >/dev/null ||
44
+ # builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
45
+ # }
51
46
  # then
52
- # bundle install
47
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
48
+ # gem install bundler
49
+ # fi
50
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
51
+ # then
52
+ # bundle install | grep -vE '^Using|Your bundle is complete'
53
53
  # fi
54
-
55
- if [[ $- == *i* ]] # check for interactive shells
56
- then
57
- echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
58
- else
59
- echo "Using: $GEM_HOME" # don't use colors in interactive shells
60
- fi
61
-
62
-
data/Gemfile CHANGED
@@ -1,16 +1,22 @@
1
1
  source :gemcutter
2
2
  source "http://rubygems.org"
3
3
 
4
- gem 'watchr'
5
- gem 'rspec'
4
+ group :development do
5
+
6
+ gem 'rspec'
7
+ gem 'guard-rspec'
8
+ gem 'guard'
9
+ gem 'rake'
10
+ gem 'em-rspec'
11
+
12
+ end
13
+
14
+
15
+ gem 'awesome_print'
6
16
 
7
- # daemon-kit
8
17
  gem 'daemon-kit'
9
18
  gem 'eventmachine'
10
19
  gem 'em-http-request'
11
- gem 'awesome_print'
12
-
20
+ gem 'em-websocket'
13
21
  gem 'eventmachine_httpserver'
14
22
 
15
- gem 'resque'
16
- gem 'rake'
data/Gemfile.lock CHANGED
@@ -2,7 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  remote: http://rubygems.org/
4
4
  specs:
5
- addressable (2.2.7)
5
+ addressable (2.2.8)
6
6
  awesome_print (1.0.2)
7
7
  daemon-kit (0.1.8.2)
8
8
  eventmachine (>= 0.12.10)
@@ -12,39 +12,40 @@ GEM
12
12
  addressable (>= 2.0.0)
13
13
  escape_utils
14
14
  eventmachine (>= 0.12.9)
15
+ em-rspec (0.1.1)
16
+ eventmachine (>= 0.12.10)
17
+ em-websocket (0.3.8)
18
+ addressable (>= 2.1.1)
19
+ eventmachine (>= 0.12.9)
15
20
  escape_utils (0.2.4)
16
21
  eventmachine (0.12.10)
17
22
  eventmachine_httpserver (0.2.1)
18
- multi_json (1.3.2)
19
- rack (1.4.1)
20
- rack-protection (1.2.0)
21
- rack
22
- rake (0.8.7)
23
- redis (2.2.2)
24
- redis-namespace (1.0.3)
25
- redis (< 3.0.0)
26
- resque (1.20.0)
27
- multi_json (~> 1.0)
28
- redis-namespace (~> 1.0.2)
29
- sinatra (>= 0.9.2)
30
- vegas (~> 0.1.2)
31
- rspec (2.9.0)
32
- rspec-core (~> 2.9.0)
33
- rspec-expectations (~> 2.9.0)
34
- rspec-mocks (~> 2.9.0)
35
- rspec-core (2.9.0)
36
- rspec-expectations (2.9.1)
23
+ ffi (1.0.11)
24
+ guard (1.2.3)
25
+ listen (>= 0.4.2)
26
+ thor (>= 0.14.6)
27
+ guard-rspec (1.2.0)
28
+ guard (>= 1.1)
29
+ listen (0.4.7)
30
+ rb-fchange (~> 0.0.5)
31
+ rb-fsevent (~> 0.9.1)
32
+ rb-inotify (~> 0.8.8)
33
+ rake (0.9.2.2)
34
+ rb-fchange (0.0.5)
35
+ ffi
36
+ rb-fsevent (0.9.1)
37
+ rb-inotify (0.8.8)
38
+ ffi (>= 0.5.0)
39
+ rspec (2.11.0)
40
+ rspec-core (~> 2.11.0)
41
+ rspec-expectations (~> 2.11.0)
42
+ rspec-mocks (~> 2.11.0)
43
+ rspec-core (2.11.0)
44
+ rspec-expectations (2.11.1)
37
45
  diff-lcs (~> 1.1.3)
38
- rspec-mocks (2.9.0)
39
- safely (0.3.1)
40
- sinatra (1.3.2)
41
- rack (~> 1.3, >= 1.3.6)
42
- rack-protection (~> 1.2)
43
- tilt (~> 1.3, >= 1.3.3)
44
- tilt (1.3.3)
45
- vegas (0.1.11)
46
- rack (>= 1.0.0)
47
- watchr (0.7)
46
+ rspec-mocks (2.11.1)
47
+ safely (0.3.2)
48
+ thor (0.15.4)
48
49
 
49
50
  PLATFORMS
50
51
  ruby
@@ -53,9 +54,11 @@ DEPENDENCIES
53
54
  awesome_print
54
55
  daemon-kit
55
56
  em-http-request
57
+ em-rspec
58
+ em-websocket
56
59
  eventmachine
57
60
  eventmachine_httpserver
61
+ guard
62
+ guard-rspec
58
63
  rake
59
- resque
60
64
  rspec
61
- watchr
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec',
2
+
3
+ :cli => "--color",
4
+ :all_on_start => false,
5
+ :all_after_pass => false,
6
+ :spec_paths => ['spec'] do
7
+
8
+ watch(%r{^spec/.+_spec\.rb$})
9
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
10
+
11
+ end
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ LanGrove
2
+ ========
3
+
4
+ [LanGrove](http://www.google.com/search?hl=en&safe=off&biw=1065&bih=884&tbm=isch&sa=1&q=mangrove&btnG=) levarages [EventMachine](http://eventmachine.rubyforge.org/EventMachine.html) and [DaemonKit](https://github.com/kennethkalmer/daemon-kit/) to provide a framework for quick to implement network aware systems by providing an easily configurable transport and session layer and exposing generic interfaces into the application layer.
5
+
6
+ ### Getting started quickly with [Scaffold and Configuration](https://github.com/cluetechnologies/langrove-enterprise/tree/master/bin)
7
+
8
+ ### Understanding the [Framework Components](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove)
9
+
10
+ Change Log
11
+ ----------
12
+
13
+ ### 2012-08-08
14
+
15
+ * v0.0.5.3
16
+
17
+
18
+ Todo
19
+ ----
20
+
21
+ * Rename this to `langrove`
22
+ * Rename the original to `langrove-enterprise`
23
+ * Swing all document links
24
+ * Publish this repo
25
+ * Start on the Enterprise Extensions
26
+
27
+
28
+ Note to Developers
29
+ ------------------
30
+
31
+ * Uses [Guard](https://github.com/guard/guard/) to watch for changes in `lib` or `spec` directories
32
+ * Runs specs accordingly.
33
+ * `bundle exec guard`
34
+
data/Rakefile CHANGED
@@ -16,9 +16,11 @@ task :publish do
16
16
 
17
17
  end
18
18
 
19
- desc "Push to github"
20
- task :push_world do
21
-
22
- puts "TODO"
23
-
24
- end
19
+ #
20
+ # brew install markdown
21
+ #
22
+ desc "Make ./tmp/readme.html"
23
+ task :readme do
24
+ sh "markdown< README.md > tmp/README.html"
25
+ end
26
+
data/bin/README.md ADDED
@@ -0,0 +1,3 @@
1
+ Scaffold and Configuration
2
+ ==========================
3
+
data/bin/langrove CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- puts "warbel"
2
+ puts "pending config scaffolding tool"
data/langrove.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ $LOAD_PATH.unshift 'lib'
2
+
3
+ require 'date'
4
+ require 'langrove/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = %q{langrove}
8
+ spec.version = ::LanGrove::Version
9
+ spec.date = DateTime.now.strftime( "%Y-%m-%d" )
10
+ spec.authors = ["Richard","","",""]
11
+ spec.email = %q{ops@clue.co.za}
12
+ spec.summary = %q{eventmachine based networked daemon framework}
13
+ spec.homepage = %q{}
14
+ spec.description = %q{}
15
+
16
+ # Executables
17
+ spec.executables << 'langrove'
18
+
19
+ #spec.executables << 'langrove-init'
20
+ #spec.executables << 'langrove-stats'
21
+ #spec.executables << 'langrove-error-stats'
22
+ #spec.executables << 'error_report'
23
+
24
+ spec.add_runtime_dependency 'eventmachine'
25
+ spec.add_runtime_dependency 'em-http-request'
26
+ spec.add_runtime_dependency 'em-websocket'
27
+ spec.add_runtime_dependency 'eventmachine_httpserver'
28
+ spec.add_runtime_dependency 'daemon-kit'
29
+ spec.add_runtime_dependency 'awesome_print'
30
+
31
+ spec.files = `git ls-files`.strip.split("\n")
32
+
33
+ end
34
+
35
+
@@ -0,0 +1,82 @@
1
+ Foundation
2
+ ==========
3
+
4
+ ### [Langrove::Root::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/root)
5
+
6
+ Provides the `Config` and `Logger`.
7
+
8
+ ### [LanGrove::Daemon::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/daemon)
9
+
10
+ Defines the `Container` that houses the Primary Daemon Components
11
+
12
+
13
+ Primary Components
14
+ ==================
15
+
16
+
17
+ ### [LanGrove::Adaptor::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/adaptor)
18
+
19
+ Defines the `Object` to which remote processes attach.
20
+
21
+
22
+ ### [LanGrove::Handler::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/handler)
23
+
24
+ Defines the `Object` that is spawned to handle each attached remote process.
25
+
26
+
27
+ ### [LanGrove::Protocol::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/protocol)
28
+
29
+ Defines the `Object` that encapsulates the method of communication.
30
+
31
+
32
+ ### [LanGrove::Server::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/server)
33
+
34
+ Defines the `Object` that houses the collection of all presently connected remote processes.
35
+
36
+ Configuration
37
+ -------------
38
+
39
+ Each component is configured in a subtree nested at the root of the daemons config branch.
40
+
41
+ <pre>
42
+
43
+ :daemons:
44
+ ...
45
+ ...
46
+ my_daemon:
47
+
48
+ :adaptor:
49
+ ...
50
+
51
+ :handler:
52
+ ...
53
+
54
+ :protocol:
55
+ ...
56
+
57
+ :server:
58
+ ...
59
+
60
+ </pre>
61
+
62
+
63
+ Secondary Components
64
+ ====================
65
+
66
+
67
+ ### [LanGrove::Behaviour::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/behaviour)
68
+
69
+ Defines a set of Behaviours that can be applied to Primary Daemon Components
70
+
71
+
72
+ ### [LanGrove::Plugin::Base](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/plugin)
73
+
74
+ Defines the `Interface Base` to implement Behaviour actions.
75
+
76
+
77
+
78
+ Tools and Things
79
+ ================
80
+
81
+ ### [LanGrove::Ext](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/ext)
82
+
@@ -0,0 +1,92 @@
1
+ <pre>
2
+
3
+ </pre>
4
+
5
+ LanGrove::Adaptor::Base
6
+ ========================
7
+
8
+ Defines the extendable `Interface` for spawning [Handler](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/handler)s into the [Server](https://github.com/cluetechnologies/langrove-enterprise/tree/master/lib/langrove/server) process.
9
+
10
+
11
+ EventMachineAdaptor
12
+ -------------------
13
+
14
+ This is the default Adaptor and will be used when :class: is unspecified.
15
+
16
+ It listens.
17
+
18
+ ### `./config/my_daemon.yml`
19
+
20
+ <pre>
21
+
22
+ :daemons:
23
+
24
+ my_daemon:
25
+ ...
26
+ ...
27
+
28
+ :adaptor:
29
+ # :class: Unspecified
30
+ :connect: tcp
31
+ :iface: 10.0.0.2
32
+ :port: 16369
33
+
34
+ ...
35
+ ...
36
+
37
+ </pre>
38
+
39
+
40
+
41
+ QueryAdaptor
42
+ ------------
43
+
44
+ ### Pending...
45
+
46
+ [EventMachine::Protocols::Postgres3](http://eventmachine.rubyforge.org/EventMachine/Protocols/Postgres3.html)
47
+
48
+
49
+
50
+ Implementing a custom Adaptor
51
+ =============================
52
+
53
+ * Adaptor implementations should define validate_config() and connector()
54
+ * connector() receives a params Hash containing the definition of the Handler and Protocol along with their configs.
55
+ * connector() should instanciate a new Handler with each connection made and yield that Handler
56
+
57
+ ### `lib/adaptor/my_adaptor.rb`
58
+
59
+ <pre>
60
+
61
+ module Adaptor
62
+
63
+ class MyAdaptor <code>&#60;</code> LanGrove::Adaptor::Base
64
+
65
+ def validate_config
66
+
67
+ @config
68
+
69
+ end
70
+
71
+ def connector( params, &block )
72
+
73
+ #
74
+ # Event Loop (or something)
75
+ #
76
+ #
77
+ # (Listen)
78
+ #
79
+ #
80
+ # Yield new Handlers
81
+ #
82
+ #
83
+ # But keep looping (probably)
84
+ #
85
+
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ </pre>
@@ -0,0 +1,123 @@
1
+ module LanGrove
2
+
3
+ module Adaptor
4
+
5
+ class Base < LanGrove::Base
6
+
7
+ def stop
8
+
9
+ #
10
+ # OVERRIDE
11
+ #
12
+ # Daemon has been called to stop
13
+ #
14
+
15
+ end
16
+
17
+ def reload
18
+
19
+ #
20
+ # OVERRIDE
21
+ #
22
+ # Daemon has been called to HUP
23
+ #
24
+
25
+ end
26
+
27
+ def validate_config
28
+
29
+ #
30
+ # OVERRIDE
31
+ #
32
+
33
+ @config
34
+
35
+ end
36
+
37
+ def connector( params, &block )
38
+
39
+ #
40
+ # OVERRIDE
41
+ #
42
+ # To define the adaptor device to which clients
43
+ # connect.
44
+ #
45
+
46
+ raise LanGrove::PluginException.new(
47
+
48
+ "#{self.class}.connector() - missing implementation."
49
+
50
+ )
51
+
52
+ end
53
+
54
+
55
+ ###
56
+
57
+ def stop_adaptor
58
+
59
+ stop
60
+
61
+ end
62
+
63
+ def reload_adaptor
64
+
65
+ reload
66
+
67
+ end
68
+
69
+ def initialize( root, config, deamon_name )
70
+
71
+ super( root )
72
+
73
+ @config = config
74
+
75
+ validate_config_adaptor
76
+
77
+ end
78
+
79
+ def validate_config_adaptor
80
+
81
+ unless @config.nil? or @config[:plugin].nil?
82
+
83
+ @config[:plugin] = @root.config.get_plugin_config( @config[:plugin] )
84
+
85
+ end
86
+
87
+ validate_config
88
+
89
+ end
90
+
91
+ def listen( handler, protocol, server )
92
+
93
+ connector( {
94
+
95
+ :handler => handler,
96
+ :protocol => protocol
97
+
98
+ } ) do |connected_handler|
99
+
100
+ #
101
+ # A newly connected Handler
102
+ #
103
+
104
+ connected_handler.assign( {
105
+
106
+ :root => @root,
107
+ :handler => handler,
108
+ :protocol => protocol,
109
+ :server => server
110
+
111
+ } )
112
+
113
+ connected_handler.start_handler
114
+
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
121
+ end
122
+
123
+ end
@@ -1,2 +1,12 @@
1
- module LanGrove::Adaptor; end
2
- require 'langrove/adaptor_base'
1
+ module LanGrove
2
+
3
+ module Adaptor
4
+
5
+ end
6
+
7
+ end
8
+
9
+ require 'langrove/adaptor/adaptor_base'
10
+
11
+ require 'langrove/adaptor/event_machine_adaptor'
12
+ require 'langrove/adaptor/query_adaptor'
@@ -0,0 +1,8 @@
1
+ require 'langrove/adaptor/base'
2
+
3
+ LanGrove::Adaptor::Default = LanGrove::Adaptor::EventMachineAdaptor
4
+
5
+ #
6
+ # Base does not define the adaptor.connect() method.
7
+ # Default to EventMachines socket listener.
8
+ #