david 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +2 -2
- data/Gemfile +8 -2
- data/Gemfile.lock +84 -44
- data/README.md +87 -5
- data/benchmarks/Gemfile +1 -0
- data/benchmarks/Gemfile.lock +3 -1
- data/benchmarks/coapbench.sh +20 -0
- data/benchmarks/quick.sh +2 -0
- data/benchmarks/rackup/Gemfile +10 -0
- data/benchmarks/rackup/Gemfile.lock +159 -0
- data/benchmarks/rackup/grape.ru +18 -0
- data/benchmarks/rackup/rack.ru +7 -0
- data/benchmarks/rackup/rails.ru +14 -0
- data/benchmarks/rps.rb +14 -2
- data/benchmarks/stress.sh +17 -0
- data/david.gemspec +0 -3
- data/experiments/Gemfile +6 -0
- data/experiments/concurrency/Gemfile +3 -0
- data/experiments/concurrency/stub.rb +88 -0
- data/experiments/hash_key.rb +64 -0
- data/experiments/string_concat.rb +21 -0
- data/experiments/symbol_to_proc.rb +15 -0
- data/experiments/thread_safe.rb +40 -0
- data/lib/david.rb +8 -4
- data/lib/david/actor.rb +1 -11
- data/lib/david/app_config.rb +112 -0
- data/lib/david/exchange.rb +124 -0
- data/lib/david/fake_logger.rb +11 -0
- data/lib/david/garbage_collector.rb +9 -17
- data/lib/david/guerilla/rack/utils.rb +18 -0
- data/lib/david/interop.rb +4 -0
- data/lib/david/interop/mandatory_etsi.rb +4 -0
- data/lib/david/interop/mandatory_etsi/grape.rb +37 -0
- data/lib/david/interop/mandatory_etsi/hobbit.rb +30 -0
- data/lib/david/interop/mandatory_etsi/nyny.rb +36 -0
- data/lib/david/interop/mandatory_etsi/rack.rb +26 -0
- data/lib/david/interop/mandatory_etsi/sinatra.rb +36 -0
- data/lib/david/observe.rb +24 -29
- data/lib/david/rails/action_controller/base.rb +9 -7
- data/lib/david/railties/config.rb +4 -4
- data/lib/david/registry.rb +22 -0
- data/lib/david/server.rb +56 -56
- data/lib/david/server/constants.rb +1 -0
- data/lib/david/server/mapping.rb +43 -11
- data/lib/david/server/mid_cache.rb +29 -0
- data/lib/david/server/multicast.rb +7 -5
- data/lib/david/server/respond.rb +53 -43
- data/lib/david/server/utility.rb +2 -1
- data/lib/david/show_exceptions.rb +12 -8
- data/lib/david/transmitter.rb +44 -0
- data/lib/david/trap.rb +10 -0
- data/lib/david/version.rb +1 -1
- data/lib/rack/handler/david.rb +6 -10
- data/lib/rack/hello_world.rb +25 -0
- data/spec/app_config_spec.rb +56 -0
- data/spec/dummy/app/controllers/etsis_controller.rb +26 -0
- data/spec/dummy/app/controllers/tests_controller.rb +9 -0
- data/spec/dummy/config/application.rb +4 -6
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/environments/test.rb +2 -2
- data/spec/dummy/config/routes.rb +13 -53
- data/spec/interop/mandatory_spec.rb +100 -0
- data/spec/observe_spec.rb +8 -7
- data/spec/resource_discovery_spec.rb +3 -3
- data/spec/server_spec.rb +60 -15
- data/spec/spec_helper.rb +21 -2
- metadata +40 -33
- data/lib/david/request.rb +0 -80
- data/lib/david/server/deduplication.rb +0 -21
- data/lib/david/server/options.rb +0 -79
data/lib/david/server/options.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
module David
|
2
|
-
class Server
|
3
|
-
module Options
|
4
|
-
protected
|
5
|
-
|
6
|
-
def choose(name, value)
|
7
|
-
send(('choose_' + name.to_s).to_sym, value)
|
8
|
-
end
|
9
|
-
|
10
|
-
def choose_block(value)
|
11
|
-
default_to_true(:block, value)
|
12
|
-
end
|
13
|
-
|
14
|
-
def choose_cbor(value)
|
15
|
-
if value.nil? && defined? Rails
|
16
|
-
value = Rails.application.config.coap.cbor
|
17
|
-
end
|
18
|
-
|
19
|
-
!!value
|
20
|
-
end
|
21
|
-
|
22
|
-
def choose_default_format(value)
|
23
|
-
if value.nil? && defined? Rails
|
24
|
-
value = Rails.application.config.coap.default_format
|
25
|
-
end
|
26
|
-
|
27
|
-
value.nil? ? 'application/json' : value
|
28
|
-
end
|
29
|
-
|
30
|
-
# Rails starts on 'localhost' since 4.2.0.beta1
|
31
|
-
# (Resolv class seems not to consider /etc/hosts)
|
32
|
-
def choose_host(value)
|
33
|
-
Socket::getaddrinfo(value, nil, nil, Socket::SOCK_STREAM)[0][3]
|
34
|
-
end
|
35
|
-
|
36
|
-
def choose_logger(log)
|
37
|
-
fd = $stderr
|
38
|
-
level = ::Logger::INFO
|
39
|
-
|
40
|
-
case log
|
41
|
-
when 'debug'
|
42
|
-
level = ::Logger::DEBUG
|
43
|
-
when 'none'
|
44
|
-
fd = File.open('/dev/null', 'w')
|
45
|
-
end
|
46
|
-
|
47
|
-
logger = ::Logger.new(fd)
|
48
|
-
logger.level = level
|
49
|
-
logger.formatter = proc do |sev, time, prog, msg|
|
50
|
-
"#{time.strftime('[%Y-%m-%d %H:%M:%S]')} #{sev} #{msg}\n"
|
51
|
-
end
|
52
|
-
|
53
|
-
Celluloid.logger = logger
|
54
|
-
|
55
|
-
logger
|
56
|
-
end
|
57
|
-
|
58
|
-
def choose_mcast(value)
|
59
|
-
default_to_true(:multicast, value)
|
60
|
-
end
|
61
|
-
|
62
|
-
def choose_observe(value)
|
63
|
-
default_to_true(:observe, value)
|
64
|
-
end
|
65
|
-
|
66
|
-
def default_to_true(key, value)
|
67
|
-
if value.nil? && defined? Rails
|
68
|
-
value = Rails.application.config.coap.send(key)
|
69
|
-
end
|
70
|
-
|
71
|
-
return true if value.nil? || value.to_s == 'true'
|
72
|
-
|
73
|
-
false
|
74
|
-
end
|
75
|
-
|
76
|
-
module_function :default_to_true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|