tipi 0.31 → 0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/Gemfile.lock +10 -4
- data/LICENSE +1 -1
- data/TODO.md +13 -47
- data/bin/tipi +13 -0
- data/df/agent.rb +63 -0
- data/df/etc_benchmark.rb +15 -0
- data/df/multi_agent_supervisor.rb +87 -0
- data/df/multi_client.rb +84 -0
- data/df/routing_benchmark.rb +60 -0
- data/df/sample_agent.rb +89 -0
- data/df/server.rb +54 -0
- data/df/sse_page.html +29 -0
- data/df/stress.rb +24 -0
- data/df/ws_page.html +38 -0
- data/examples/http_request_ws_server.rb +34 -0
- data/examples/http_server.rb +6 -6
- data/examples/http_server_forked.rb +4 -5
- data/examples/http_server_form.rb +23 -0
- data/examples/http_server_throttled_accept.rb +23 -0
- data/examples/http_unix_socket_server.rb +17 -0
- data/examples/http_ws_server.rb +10 -12
- data/examples/routing_server.rb +34 -0
- data/examples/websocket_client.rb +1 -2
- data/examples/websocket_demo.rb +4 -2
- data/examples/ws_page.html +1 -2
- data/lib/tipi.rb +7 -5
- data/lib/tipi/config_dsl.rb +153 -0
- data/lib/tipi/configuration.rb +1 -1
- data/lib/tipi/digital_fabric.rb +7 -0
- data/lib/tipi/digital_fabric/agent.rb +225 -0
- data/lib/tipi/digital_fabric/agent_proxy.rb +265 -0
- data/lib/tipi/digital_fabric/executive.rb +100 -0
- data/lib/tipi/digital_fabric/executive/index.html +69 -0
- data/lib/tipi/digital_fabric/protocol.rb +90 -0
- data/lib/tipi/digital_fabric/request_adapter.rb +48 -0
- data/lib/tipi/digital_fabric/service.rb +230 -0
- data/lib/tipi/http1_adapter.rb +59 -37
- data/lib/tipi/http2_adapter.rb +5 -3
- data/lib/tipi/http2_stream.rb +19 -7
- data/lib/tipi/rack_adapter.rb +11 -3
- data/lib/tipi/version.rb +1 -1
- data/lib/tipi/websocket.rb +33 -13
- data/test/helper.rb +1 -2
- data/test/test_http_server.rb +3 -2
- data/test/test_request.rb +108 -0
- data/tipi.gemspec +7 -3
- metadata +59 -7
- data/lib/tipi/request.rb +0 -118
data/lib/tipi/request.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
module Tipi
|
6
|
-
# HTTP request
|
7
|
-
class Request
|
8
|
-
attr_reader :headers, :adapter
|
9
|
-
attr_accessor :__next__
|
10
|
-
|
11
|
-
def initialize(headers, adapter)
|
12
|
-
@headers = headers
|
13
|
-
@adapter = adapter
|
14
|
-
end
|
15
|
-
|
16
|
-
def protocol
|
17
|
-
@protocol = @adapter.protocol
|
18
|
-
end
|
19
|
-
|
20
|
-
def method
|
21
|
-
@method ||= @headers[':method']
|
22
|
-
end
|
23
|
-
|
24
|
-
def scheme
|
25
|
-
@scheme ||= @headers[':scheme']
|
26
|
-
end
|
27
|
-
|
28
|
-
def uri
|
29
|
-
@uri ||= URI.parse(@headers[':path'] || '')
|
30
|
-
end
|
31
|
-
|
32
|
-
def path
|
33
|
-
@path ||= uri.path
|
34
|
-
end
|
35
|
-
|
36
|
-
def query_string
|
37
|
-
@query_string ||= uri.query
|
38
|
-
end
|
39
|
-
|
40
|
-
def query
|
41
|
-
return @query if @query
|
42
|
-
|
43
|
-
@query = (q = uri.query) ? split_query_string(q) : {}
|
44
|
-
end
|
45
|
-
|
46
|
-
def split_query_string(query)
|
47
|
-
query.split('&').each_with_object({}) do |kv, h|
|
48
|
-
k, v = kv.split('=')
|
49
|
-
h[k.to_sym] = URI.decode_www_form_component(v)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def buffer_body_chunk(chunk)
|
54
|
-
@buffered_body_chunks ||= []
|
55
|
-
@buffered_body_chunks << chunk
|
56
|
-
end
|
57
|
-
|
58
|
-
def each_chunk(&block)
|
59
|
-
if @buffered_body_chunks
|
60
|
-
@buffered_body_chunks.each(&block)
|
61
|
-
@buffered_body_chunks = nil
|
62
|
-
end
|
63
|
-
while !@message_complete && (chunk = @adapter.get_body_chunk)
|
64
|
-
yield chunk
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def complete!(keep_alive = nil)
|
69
|
-
@message_complete = true
|
70
|
-
@keep_alive = keep_alive
|
71
|
-
end
|
72
|
-
|
73
|
-
def complete?
|
74
|
-
@message_complete
|
75
|
-
end
|
76
|
-
|
77
|
-
def consume
|
78
|
-
@adapter.consume_request
|
79
|
-
end
|
80
|
-
|
81
|
-
def keep_alive?
|
82
|
-
@keep_alive
|
83
|
-
end
|
84
|
-
|
85
|
-
def read
|
86
|
-
buf = @buffered_body_chunks ? @buffered_body_chunks.join : +''
|
87
|
-
while (chunk = @adapter.get_body_chunk)
|
88
|
-
buf << chunk
|
89
|
-
end
|
90
|
-
buf
|
91
|
-
end
|
92
|
-
|
93
|
-
def respond(body, headers = {})
|
94
|
-
@adapter.respond(body, headers)
|
95
|
-
@headers_sent = true
|
96
|
-
end
|
97
|
-
|
98
|
-
def send_headers(headers = {}, empty_response = false)
|
99
|
-
return if @headers_sent
|
100
|
-
|
101
|
-
@headers_sent = true
|
102
|
-
@adapter.send_headers(headers, empty_response: empty_response)
|
103
|
-
end
|
104
|
-
|
105
|
-
def send_chunk(body, done: false)
|
106
|
-
send_headers({}) unless @headers_sent
|
107
|
-
|
108
|
-
@adapter.send_chunk(body, done: done)
|
109
|
-
end
|
110
|
-
alias_method :<<, :send_chunk
|
111
|
-
|
112
|
-
def finish
|
113
|
-
send_headers({}) unless @headers_sent
|
114
|
-
|
115
|
-
@adapter.finish
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|