langrove 0.0.4.5 → 0.0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +29 -38
- data/Gemfile +13 -7
- data/Gemfile.lock +35 -32
- data/Guardfile +11 -0
- data/README.md +34 -0
- data/Rakefile +8 -6
- data/bin/README.md +3 -0
- data/bin/langrove +1 -2
- data/langrove.gemspec +35 -0
- data/lib/langrove/README.md +82 -0
- data/lib/langrove/adaptor/README.md +92 -0
- data/lib/langrove/adaptor/adaptor_base.rb +123 -0
- data/lib/langrove/adaptor/base.rb +12 -2
- data/lib/langrove/adaptor/default.rb +8 -0
- data/lib/langrove/adaptor/event_machine_adaptor.rb +152 -0
- data/lib/langrove/adaptor/query_adaptor.rb +271 -0
- data/lib/langrove/behaviour/README.md +170 -0
- data/lib/langrove/behaviour/assessable.rb +63 -0
- data/lib/langrove/behaviour/base.rb +16 -0
- data/lib/langrove/behaviour/behaviour_base.rb +341 -0
- data/lib/langrove/behaviour/enqueueable.rb +104 -0
- data/lib/langrove/behaviour/notifiable.rb +48 -0
- data/lib/langrove/behaviour/persistable.rb +89 -0
- data/lib/langrove/behaviour/preloadable.rb +63 -0
- data/lib/langrove/daemon/README.md +7 -0
- data/lib/langrove/daemon/base.rb +9 -2
- data/lib/langrove/daemon/daemon_base.rb +330 -0
- data/lib/langrove/daemon/default.rb +3 -0
- data/lib/langrove/ext/README.md +48 -0
- data/lib/langrove/ext/class_loader.rb +9 -66
- data/lib/langrove/ext/config_item.rb +31 -23
- data/lib/langrove/ext/config_loader.rb +42 -8
- data/lib/langrove/ext/fake_config.rb +121 -0
- data/lib/langrove/ext/fake_logger.rb +50 -7
- data/lib/langrove/ext/fake_root.rb +38 -0
- data/lib/langrove/ext/hash.rb +56 -0
- data/lib/langrove/ext/i.rb +43 -0
- data/lib/langrove/ext/log_monitor.rb +272 -0
- data/lib/langrove/ext/module_loader.rb +52 -0
- data/lib/langrove/ext/recursive_string.rb +94 -0
- data/lib/langrove/ext/spec_helper.rb +84 -0
- data/lib/langrove/ext.rb +8 -2
- data/lib/langrove/handler/README.md +161 -0
- data/lib/langrove/handler/base.rb +29 -2
- data/lib/langrove/handler/default.rb +4 -0
- data/lib/langrove/handler/deferred.rb +105 -0
- data/lib/langrove/handler/handler_base.rb +242 -0
- data/lib/langrove/handler/http_servlet.rb +58 -0
- data/lib/langrove/handler/socket.rb +21 -0
- data/lib/langrove/handler/socket_base.rb +127 -0
- data/lib/langrove/handler/socket_multiplexer.rb +438 -0
- data/lib/langrove/handler/web_socket.rb +41 -0
- data/lib/langrove/plugin/README.md +76 -0
- data/lib/langrove/plugin/assessor.rb +363 -0
- data/lib/langrove/plugin/base.rb +18 -0
- data/lib/langrove/plugin/buffered_persistor.rb +97 -0
- data/lib/langrove/plugin/enqueuer.rb +186 -0
- data/lib/langrove/plugin/notifier.rb +144 -0
- data/lib/langrove/plugin/persistor.rb +360 -0
- data/lib/langrove/plugin/plugin_base.rb +79 -0
- data/lib/langrove/plugin/yaml_file.md +5 -0
- data/lib/langrove/plugin/yaml_file.rb +261 -0
- data/lib/langrove/protocol/README.md +102 -0
- data/lib/langrove/protocol/base.rb +10 -2
- data/lib/langrove/protocol/default.rb +3 -0
- data/lib/langrove/protocol/protocol_base.rb +60 -0
- data/lib/langrove/protocol/syslog.rb +34 -27
- data/lib/langrove/root/README.md +17 -0
- data/lib/langrove/root/base.rb +11 -0
- data/lib/langrove/root/config.rb +163 -0
- data/lib/langrove/root/root_base.rb +259 -0
- data/lib/langrove/server/README.md +7 -0
- data/lib/langrove/server/base.rb +9 -0
- data/lib/langrove/server/default.rb +3 -0
- data/lib/langrove/server/server_base.rb +301 -0
- data/lib/langrove/version.rb +3 -1
- data/lib/langrove.rb +44 -1
- data/spec/langrove/adaptor/adaptor_base_spec.rb +33 -0
- data/spec/langrove/adaptor/event_machine_adaptor_spec.rb +62 -0
- data/spec/langrove/adaptor/query_adaptor_spec.rb +94 -0
- data/spec/langrove/behaviour/assessable_spec.rb +42 -0
- data/spec/langrove/behaviour/behaviour_base_spec.rb +396 -0
- data/spec/langrove/behaviour/enqueueable_spec.rb +19 -0
- data/spec/langrove/behaviour/notifiable_spec.rb +6 -0
- data/spec/langrove/behaviour/persistable_spec.rb +19 -0
- data/spec/langrove/behaviour/preloadable_spec.rb +19 -0
- data/spec/langrove/daemon/base_spec.rb +6 -0
- data/spec/langrove/daemon/daemon_base_spec.rb +253 -0
- data/spec/langrove/ext/class_loader_spec.rb +9 -12
- data/spec/langrove/ext/fake_config_spec.rb +50 -0
- data/spec/langrove/ext/fake_logger_spec.rb +12 -0
- data/spec/langrove/ext/fake_root_spec.rb +19 -0
- data/spec/langrove/ext/hash_spec.rb +54 -0
- data/spec/langrove/ext/i_spec.rb +11 -0
- data/spec/langrove/ext/log_monitor_spec.rb +254 -0
- data/spec/langrove/ext/module_loader_spec.rb +70 -0
- data/spec/langrove/ext/recursive_string_spec.rb +132 -0
- data/{functional/config/environments/development.rb → spec/langrove/ext/spec_helper_spec.rb} +0 -0
- data/spec/langrove/handler/deferred_spec.rb +9 -0
- data/spec/langrove/handler/handler_base_spec.rb +134 -0
- data/spec/langrove/handler/socket_base_spec.rb +76 -0
- data/spec/langrove/handler/socket_multiplexer_spec.rb +480 -0
- data/spec/langrove/handler/socket_spec.rb +6 -0
- data/spec/langrove/handler/web_socket_spec.rb +19 -0
- data/spec/langrove/plugin/assessor_spec.rb +278 -0
- data/spec/langrove/plugin/buffered_persistor_spec.rb +94 -0
- data/spec/langrove/plugin/enqueuer_spec.rb +136 -0
- data/spec/langrove/plugin/notifier_spec.rb +107 -0
- data/spec/langrove/plugin/persistor_spec.rb +300 -0
- data/spec/langrove/plugin/plugin_base_spec.rb +86 -0
- data/spec/langrove/plugin/yaml_file_spec.rb +348 -0
- data/spec/langrove/protocol/protocol_base_spec.rb +19 -0
- data/spec/langrove/protocol/syslog_spec.rb +5 -2
- data/spec/langrove/root/config_spec.rb +103 -0
- data/spec/langrove/root/root_base_spec.rb +93 -0
- data/spec/langrove/server/server_base_spec.rb +414 -0
- data/spec/spec_helper.rb +38 -0
- metadata +157 -92
- data/.watchr +0 -27
- data/functional/config/boot.rb +0 -64
- data/functional/config/daemons.yml +0 -13
- data/functional/config/environment.rb +0 -28
- data/functional/config/environments/production.rb +0 -0
- data/functional/config/environments/test.rb +0 -0
- data/functional/lib/client/socket_to_file.rb +0 -47
- data/functional/lib/daemon/datagram.rb +0 -21
- data/functional/lib/protocol/socket_to_file.rb +0 -55
- data/functional/libexec/daemon.rb +0 -68
- data/functional/tmp/README +0 -1
- data/lib/langrove/_base.rb +0 -28
- data/lib/langrove/adaptor_base.rb +0 -116
- data/lib/langrove/client/base.rb +0 -2
- data/lib/langrove/client/datagram.rb +0 -25
- data/lib/langrove/client_base.rb +0 -92
- data/lib/langrove/daemon_base.rb +0 -281
- data/lib/langrove/ext/find.rb +0 -90
- data/lib/langrove/ext/persistable.rb +0 -103
- data/lib/langrove/handler_base.rb +0 -148
- data/lib/langrove/job/base.rb +0 -1
- data/lib/langrove/job_base.rb +0 -24
- data/lib/langrove/protocol_base.rb +0 -32
- data/spec/functional/daemon/datagram_spec.rb +0 -121
- data/spec/langrove/adaptor_base_spec.rb +0 -63
- data/spec/langrove/client/datagram_spec.rb +0 -1
- data/spec/langrove/client_base_spec.rb +0 -5
- data/spec/langrove/daemon_base_spec.rb +0 -154
- data/spec/langrove/ext/find_spec.rb +0 -53
- data/spec/langrove/ext/persistable_spec.rb +0 -117
- data/spec/langrove/handler_base_spec.rb +0 -103
- data/spec/langrove/job_base_spec.rb +0 -28
- data/spec/langrove/protocol_base_spec.rb +0 -6
- data/spec/todo_spec.rb +0 -12
- data/tmp/README +0 -2
data/lib/langrove/_base.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#$LOAD_PATH.unshift 'langrove' unless $LOAD_PATH.include?( 'langrove' )
|
2
|
-
|
3
|
-
#$LOAD_PATH.inspect
|
4
|
-
|
5
|
-
#
|
6
|
-
# For the implementation client
|
7
|
-
#
|
8
|
-
module Adaptor; end
|
9
|
-
module Client; end
|
10
|
-
module Daemon; end
|
11
|
-
module Handler; end
|
12
|
-
module Protocol; end
|
13
|
-
module Job; end
|
14
|
-
|
15
|
-
module LanGrove
|
16
|
-
|
17
|
-
class DaemonConfigException < Exception; end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'langrove/ext'
|
22
|
-
|
23
|
-
require 'langrove/daemon/base'
|
24
|
-
require 'langrove/adaptor/base'
|
25
|
-
require 'langrove/handler/base'
|
26
|
-
require 'langrove/protocol/base'
|
27
|
-
require 'langrove/client/base'
|
28
|
-
require 'langrove/job/base'
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'eventmachine'
|
2
|
-
|
3
|
-
require 'langrove'
|
4
|
-
|
5
|
-
module LanGrove::Adaptor
|
6
|
-
|
7
|
-
class Base
|
8
|
-
|
9
|
-
def initialize( config, logger )
|
10
|
-
|
11
|
-
@config = config
|
12
|
-
@logger = logger
|
13
|
-
|
14
|
-
@transport = :tcp
|
15
|
-
@iface = '127.0.0.1'
|
16
|
-
@port = 12701
|
17
|
-
|
18
|
-
@iface = @config[ :iface ] if @config.has_key? :iface
|
19
|
-
@port = @config[ :port ] if @config.has_key? :port
|
20
|
-
@transport = @config[ :transport ].to_sym if @config.has_key? :transport
|
21
|
-
|
22
|
-
#
|
23
|
-
# Assign the call signature for the EventMachine server
|
24
|
-
#
|
25
|
-
@em_server_call = case @transport
|
26
|
-
|
27
|
-
when :tcp
|
28
|
-
|
29
|
-
:start_server
|
30
|
-
|
31
|
-
when :udp
|
32
|
-
|
33
|
-
:open_datagram_socket
|
34
|
-
|
35
|
-
else
|
36
|
-
|
37
|
-
:start_server
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def listen( client, protocol, handler )
|
44
|
-
|
45
|
-
#
|
46
|
-
# <client> = {
|
47
|
-
#
|
48
|
-
# :class => <loaded class constant>
|
49
|
-
# :config => <client's branch of config>
|
50
|
-
#
|
51
|
-
# }
|
52
|
-
#
|
53
|
-
# <protocol> = { ...the same, but protocolic }
|
54
|
-
#
|
55
|
-
#
|
56
|
-
|
57
|
-
@logger.info "starting listen at UDP #{@iface}:#{@port}"
|
58
|
-
|
59
|
-
EventMachine::send( @em_server_call, @iface, @port,
|
60
|
-
|
61
|
-
client[:class] ) do | client_connected |
|
62
|
-
|
63
|
-
#
|
64
|
-
# @em_server_call as:
|
65
|
-
#
|
66
|
-
# udp - EM::open_datagram_socket, yields an instance of
|
67
|
-
# client[:class] into here on bind to the port
|
68
|
-
#
|
69
|
-
# ie. at starting to listen
|
70
|
-
#
|
71
|
-
# unverified: ? If more than 1 datagram source is
|
72
|
-
# transmitting to here - will there still
|
73
|
-
# still be only ONE EM:Connection instance?
|
74
|
-
#
|
75
|
-
# tcp - EM::start_server yields an new instance of client[:class]
|
76
|
-
# with every connecting socket pair.
|
77
|
-
#
|
78
|
-
# ie. On socket pair binding - so each remote client will
|
79
|
-
# have it's own associated instance of a client[:class]
|
80
|
-
# running in the machine.
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
# Initialize the client with the (application layer) Protocol
|
86
|
-
#
|
87
|
-
|
88
|
-
client_connected.logger = @logger
|
89
|
-
|
90
|
-
client_connected.config = client[ :config ]
|
91
|
-
|
92
|
-
client_connected.protocol = protocol[ :class ]\
|
93
|
-
|
94
|
-
.new( protocol[ :config ], @logger )
|
95
|
-
|
96
|
-
@logger.info( "TODO: make a reference to the Client on the Handler" )
|
97
|
-
|
98
|
-
#
|
99
|
-
# Bi-Directionally bind the Client and Handler
|
100
|
-
#
|
101
|
-
handler.connect( client_connected )
|
102
|
-
client_connected.handler = handler
|
103
|
-
|
104
|
-
#
|
105
|
-
# Client is ready and running inside the reactor
|
106
|
-
#
|
107
|
-
# EM::start_server will yield again on the next connect.
|
108
|
-
#
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
data/lib/langrove/client/base.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module LanGrove
|
2
|
-
|
3
|
-
module Client
|
4
|
-
|
5
|
-
class Datagram < Base
|
6
|
-
|
7
|
-
def receive( data )
|
8
|
-
|
9
|
-
#
|
10
|
-
# Quick hack, datagram client routes
|
11
|
-
# data back to the Handler - to get
|
12
|
-
# back to friday position.
|
13
|
-
#
|
14
|
-
# But with the gem
|
15
|
-
#
|
16
|
-
|
17
|
-
@handler.receive( data )
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/lib/langrove/client_base.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
require 'eventmachine'
|
2
|
-
require 'langrove'
|
3
|
-
|
4
|
-
module LanGrove
|
5
|
-
|
6
|
-
module Client
|
7
|
-
|
8
|
-
class Base < EventMachine::Connection
|
9
|
-
|
10
|
-
#
|
11
|
-
# Misnomer.
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# This is not the client,
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# It is the server's perspective of the client,
|
18
|
-
#
|
19
|
-
# These are generally stored in the daemon's
|
20
|
-
# handler collection,
|
21
|
-
#
|
22
|
-
# Which contains this and all similar clients,
|
23
|
-
#
|
24
|
-
# Each bonded through the daemon's connection
|
25
|
-
# adaptor to the socket that couples them to
|
26
|
-
# their actual client..
|
27
|
-
#
|
28
|
-
|
29
|
-
attr_accessor :handler
|
30
|
-
attr_accessor :protocol
|
31
|
-
attr_accessor :config
|
32
|
-
attr_accessor :logger
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
# Data arriving through the Adaptor is passed
|
37
|
-
# through the config assigned protocol and
|
38
|
-
# then arrives here in whatever format the
|
39
|
-
# <Protocol>.decode() method returned.
|
40
|
-
#
|
41
|
-
#
|
42
|
-
def receive( decoded_data )
|
43
|
-
|
44
|
-
#
|
45
|
-
# OVERRIDE
|
46
|
-
#
|
47
|
-
# - Inbound data arrived at the adaptor
|
48
|
-
#
|
49
|
-
# - It has passed through the protocol as
|
50
|
-
# defined in config.
|
51
|
-
#
|
52
|
-
# The protocol should have arranged the data
|
53
|
-
# into a Hash of:
|
54
|
-
#
|
55
|
-
# - key and value pairs
|
56
|
-
#
|
57
|
-
# - key and more_complicated_thing pairs.
|
58
|
-
#
|
59
|
-
# - The decoded data was then passed into
|
60
|
-
# this function.
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
def receive_data( data )
|
67
|
-
|
68
|
-
#
|
69
|
-
# Event machine writes into here at receiving data
|
70
|
-
# from the client.
|
71
|
-
#
|
72
|
-
|
73
|
-
receive( @protocol.decode( data ) )
|
74
|
-
|
75
|
-
#
|
76
|
-
# ?Multi-message protocol?
|
77
|
-
#
|
78
|
-
# @protocol.accumulate( multi_message_part, self )
|
79
|
-
#
|
80
|
-
# ---- With protocol responding directly to source
|
81
|
-
#
|
82
|
-
# ---- With protocol then calling receive_decoded()
|
83
|
-
# via the self being passed in.
|
84
|
-
#
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
data/lib/langrove/daemon_base.rb
DELETED
@@ -1,281 +0,0 @@
|
|
1
|
-
require 'eventmachine'
|
2
|
-
|
3
|
-
require 'langrove'
|
4
|
-
|
5
|
-
module LanGrove::Daemon class Base
|
6
|
-
|
7
|
-
def listen
|
8
|
-
|
9
|
-
#
|
10
|
-
# <Client> and <Protocol> are passed into
|
11
|
-
# the Adaptor.listen for binding onto the
|
12
|
-
# sockets at connect.
|
13
|
-
#
|
14
|
-
@adaptor.listen(
|
15
|
-
|
16
|
-
#
|
17
|
-
# pass Client, Protocol and Handler to 'listener'
|
18
|
-
#
|
19
|
-
|
20
|
-
{ :class => @client, :config => @my_config[ :client ] },
|
21
|
-
|
22
|
-
{ :class => @protocol, :config => @my_config[ :protocol ] },
|
23
|
-
|
24
|
-
@handler
|
25
|
-
|
26
|
-
)
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def stop_daemon
|
31
|
-
|
32
|
-
#
|
33
|
-
# Handle stopping daemon
|
34
|
-
#
|
35
|
-
@logger.info "#{self} received stop_daemon"
|
36
|
-
@handler.stop_daemon
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def reload_daemon
|
41
|
-
|
42
|
-
#
|
43
|
-
# TODO: Handle reloading daemon properly
|
44
|
-
#
|
45
|
-
# [ !!complexities abound around reloading config!! ]
|
46
|
-
#
|
47
|
-
|
48
|
-
@logger.info "#{self} received reload_daemon"
|
49
|
-
@handler.reload_daemon
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
def schedule
|
54
|
-
|
55
|
-
@logger.info "#{self} Scheduling periodic ...TODO..."
|
56
|
-
|
57
|
-
EM::add_periodic_timer( @my_config[ :periodic ] ) do
|
58
|
-
|
59
|
-
#
|
60
|
-
# TODO: This can be a lot more usefull than
|
61
|
-
# then one ticker to one function call
|
62
|
-
#
|
63
|
-
|
64
|
-
@handler.periodic
|
65
|
-
|
66
|
-
end if @my_config.has_key? :periodic
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
def run
|
71
|
-
|
72
|
-
EventMachine::run do
|
73
|
-
|
74
|
-
#
|
75
|
-
# https://github.com/eventmachine/eventmachine/wiki/Protocol-Implementations
|
76
|
-
#
|
77
|
-
|
78
|
-
schedule
|
79
|
-
|
80
|
-
listen if @server
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def initialize( config_hash, daemon_name, logger )
|
87
|
-
|
88
|
-
@config = config_hash
|
89
|
-
@daemon_name = daemon_name
|
90
|
-
@logger = logger
|
91
|
-
@server = true
|
92
|
-
|
93
|
-
#
|
94
|
-
# A network connection.
|
95
|
-
#
|
96
|
-
@adaptor = nil
|
97
|
-
|
98
|
-
#
|
99
|
-
# The client collection class.
|
100
|
-
#
|
101
|
-
@handler = nil
|
102
|
-
|
103
|
-
#
|
104
|
-
# The client type
|
105
|
-
#
|
106
|
-
@client = nil
|
107
|
-
|
108
|
-
#
|
109
|
-
# The protocol type
|
110
|
-
#
|
111
|
-
@protocol = nil
|
112
|
-
|
113
|
-
|
114
|
-
begin
|
115
|
-
|
116
|
-
@logger.info "Starting daemon: #{@daemon_name}"
|
117
|
-
|
118
|
-
rescue
|
119
|
-
|
120
|
-
#
|
121
|
-
# you shall not pass
|
122
|
-
#
|
123
|
-
raise LanGrove::DaemonConfigException.new( "Requires a logger" )
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
begin
|
128
|
-
|
129
|
-
@my_config = @config[ :daemons ][ @daemon_name ]
|
130
|
-
|
131
|
-
@server = @my_config[ :server ] if @my_config.has_key? :server
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
if @my_config[ :adaptor ].has_key? :class
|
136
|
-
|
137
|
-
adaptor = @my_config[ :adaptor ][ :class ]
|
138
|
-
|
139
|
-
else
|
140
|
-
|
141
|
-
@logger.warn( "Defaulting to Adaptor::Base" )
|
142
|
-
adaptor = 'Base'
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
@logger.info "TODO: fall back to default Handler::Base"
|
149
|
-
|
150
|
-
handler = @my_config[ :handler ][ :collection ]
|
151
|
-
|
152
|
-
client = @my_config[ :client ][ :class ]
|
153
|
-
|
154
|
-
protocol = @my_config[ :protocol ][ :class ]
|
155
|
-
|
156
|
-
@logger.info "TODO: Warn instead of raise and allow nil into ClassLoader -> load default"
|
157
|
-
|
158
|
-
rescue
|
159
|
-
|
160
|
-
error = "Missing config item for daemon: #{@daemon_name}"
|
161
|
-
|
162
|
-
@logger.error "EXIT: #{error}"
|
163
|
-
|
164
|
-
raise LanGrove::DaemonConfigException.new(
|
165
|
-
|
166
|
-
"Missing config item for daemon: #{@daemon_name}"
|
167
|
-
|
168
|
-
)
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
#
|
174
|
-
# initialize the connection adaptor specified in config
|
175
|
-
#
|
176
|
-
# daemons:
|
177
|
-
# name_of_daemon:
|
178
|
-
# adaptor:
|
179
|
-
# class: MySocket <----------( optional )
|
180
|
-
# transport: tcp|udp
|
181
|
-
# iface: N.N.n.n
|
182
|
-
# port: nNn
|
183
|
-
# handler:
|
184
|
-
# collection: CollectionOfClients
|
185
|
-
#
|
186
|
-
|
187
|
-
@logger.info "CREATE: Adaptor::#{adaptor}.new( @my_config[ :adaptor ], logger )"
|
188
|
-
|
189
|
-
@adaptor = LanGrove::ClassLoader.create( {
|
190
|
-
|
191
|
-
:module => 'Adaptor',
|
192
|
-
:class => adaptor
|
193
|
-
|
194
|
-
} ).new( @my_config[ :adaptor ], logger )
|
195
|
-
|
196
|
-
|
197
|
-
#
|
198
|
-
# bind to the handler collection specified in config
|
199
|
-
#
|
200
|
-
# daemons:
|
201
|
-
# name_of_daemon:
|
202
|
-
# adaptor:
|
203
|
-
# connection: TcpServer
|
204
|
-
# handler:
|
205
|
-
# collection: CollectionOfClients <----------
|
206
|
-
#
|
207
|
-
# CollectionOfClients ---> is the handler passed into listen()
|
208
|
-
#
|
209
|
-
|
210
|
-
@logger.info "CREATE: Handler::#{handler}.new( config_hash, '#{daemon_name}', logger )"
|
211
|
-
|
212
|
-
@handler = LanGrove::ClassLoader.create( {
|
213
|
-
|
214
|
-
:module => 'Handler',
|
215
|
-
:class => handler
|
216
|
-
|
217
|
-
} ).new( @config, @daemon_name, @logger )
|
218
|
-
|
219
|
-
|
220
|
-
#
|
221
|
-
# initialize the client specified in config
|
222
|
-
#
|
223
|
-
# daemons:
|
224
|
-
# name_of_daemon:
|
225
|
-
# client:
|
226
|
-
# class: Client <---------
|
227
|
-
# adaptor:
|
228
|
-
# connection: TcpServer
|
229
|
-
# handler:
|
230
|
-
# collection: CollectionOfClients
|
231
|
-
#
|
232
|
-
#
|
233
|
-
|
234
|
-
@logger.info "DEFINE: Client::#{client}"
|
235
|
-
|
236
|
-
@client = LanGrove::ClassLoader.create( {
|
237
|
-
|
238
|
-
:module => 'Client',
|
239
|
-
:class => client
|
240
|
-
|
241
|
-
} )
|
242
|
-
|
243
|
-
|
244
|
-
#
|
245
|
-
# initialize the client specified in config
|
246
|
-
#
|
247
|
-
# daemons:
|
248
|
-
# name_of_daemon:
|
249
|
-
# protocol:
|
250
|
-
# class: Protocol <---------
|
251
|
-
# more: config
|
252
|
-
# client:
|
253
|
-
# class: Client
|
254
|
-
# adaptor:
|
255
|
-
# connection: TcpServer
|
256
|
-
# handler:
|
257
|
-
# collection: CollectionOfClients
|
258
|
-
#
|
259
|
-
#
|
260
|
-
|
261
|
-
@logger.info "DEFINE: Protocol::#{protocol}"
|
262
|
-
|
263
|
-
@protocol = LanGrove::ClassLoader.create( {
|
264
|
-
|
265
|
-
:module => 'Protocol',
|
266
|
-
:class => protocol
|
267
|
-
|
268
|
-
} )
|
269
|
-
|
270
|
-
|
271
|
-
#
|
272
|
-
# Notifiy the handler
|
273
|
-
#
|
274
|
-
# About to go to listen...
|
275
|
-
#
|
276
|
-
|
277
|
-
@handler.start_daemon
|
278
|
-
|
279
|
-
end
|
280
|
-
|
281
|
-
end; end
|
data/lib/langrove/ext/find.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
module LanGrove
|
2
|
-
|
3
|
-
class Find
|
4
|
-
|
5
|
-
def self.with( arg_hash , &block )
|
6
|
-
|
7
|
-
type = :file
|
8
|
-
@path = '.'
|
9
|
-
|
10
|
-
#
|
11
|
-
# TODO: filter
|
12
|
-
#
|
13
|
-
|
14
|
-
@incl = nil
|
15
|
-
|
16
|
-
@relative = false
|
17
|
-
|
18
|
-
|
19
|
-
arg_hash.each do |key, value|
|
20
|
-
|
21
|
-
case key
|
22
|
-
|
23
|
-
when :type
|
24
|
-
|
25
|
-
type = value
|
26
|
-
|
27
|
-
when :path
|
28
|
-
|
29
|
-
@path = value
|
30
|
-
|
31
|
-
when :include
|
32
|
-
|
33
|
-
@incl = value
|
34
|
-
|
35
|
-
when :relative
|
36
|
-
|
37
|
-
@relative = value
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
self.send( :"find_#{type}", @path, &block )
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.find_file( path, &block )
|
49
|
-
|
50
|
-
puts "in #{path}"
|
51
|
-
|
52
|
-
Dir.entries( path ).each do | sub |
|
53
|
-
|
54
|
-
next if sub == '.'
|
55
|
-
next if sub == '..'
|
56
|
-
|
57
|
-
subdir = "#{path}/#{sub}"
|
58
|
-
|
59
|
-
begin
|
60
|
-
|
61
|
-
if @incl.nil? then
|
62
|
-
|
63
|
-
yield relative(subdir) if block
|
64
|
-
|
65
|
-
else
|
66
|
-
|
67
|
-
yield relative(subdir) unless /#{@incl}/.match( subdir ).nil?
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
next
|
72
|
-
|
73
|
-
end if File.file?( subdir ) and block
|
74
|
-
|
75
|
-
find_file( subdir, &block )
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.relative( file_path )
|
82
|
-
|
83
|
-
return file_path.gsub( "#{@path}/",'' ) if @relative
|
84
|
-
return file_path
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|