evt-event_store-http-connect 0.0.0.0
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.
- checksums.yaml +7 -0
- data/lib/event_store/http/connect.rb +16 -0
- data/lib/event_store/http/connect/assertions.rb +23 -0
- data/lib/event_store/http/connect/connect.rb +174 -0
- data/lib/event_store/http/connect/controls.rb +20 -0
- data/lib/event_store/http/connect/controls/cluster.rb +21 -0
- data/lib/event_store/http/connect/controls/cluster/hostname.rb +15 -0
- data/lib/event_store/http/connect/controls/cluster/ip_address.rb +52 -0
- data/lib/event_store/http/connect/controls/cluster/resolve_host.rb +22 -0
- data/lib/event_store/http/connect/controls/cluster/size.rb +15 -0
- data/lib/event_store/http/connect/controls/host.rb +19 -0
- data/lib/event_store/http/connect/controls/hostname.rb +35 -0
- data/lib/event_store/http/connect/controls/ip_address.rb +13 -0
- data/lib/event_store/http/connect/controls/ip_address/loopback.rb +15 -0
- data/lib/event_store/http/connect/controls/ip_address/loopback/alias.rb +66 -0
- data/lib/event_store/http/connect/controls/ip_address/non_routable.rb +15 -0
- data/lib/event_store/http/connect/controls/ip_address/unavailable.rb +25 -0
- data/lib/event_store/http/connect/controls/net_http.rb +37 -0
- data/lib/event_store/http/connect/controls/port.rb +32 -0
- data/lib/event_store/http/connect/controls/resolve_host.rb +18 -0
- data/lib/event_store/http/connect/controls/settings.rb +22 -0
- data/lib/event_store/http/connect/controls/timeouts.rb +25 -0
- data/lib/event_store/http/connect/defaults.rb +11 -0
- data/lib/event_store/http/connect/log.rb +13 -0
- data/lib/event_store/http/connect/log_attributes.rb +19 -0
- data/lib/event_store/http/connect/net_http.rb +25 -0
- data/lib/event_store/http/connect/settings.rb +21 -0
- data/lib/event_store/http/connect/telemetry.rb +24 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 97a7bd0fee4ca0e32f4c360b0a6133c080be1933
|
4
|
+
data.tar.gz: 8252510cab8534e3cb9194f2f7421c0dfb1fab82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb4b8d2b156765f99275efd0f32cf3fb15e451f86f0cf1ce20b37b1a3c97300fb0589b6f38453aa2d7706bed95e256fd25a50ca49d29a9d1c4ea71cf472cdebb
|
7
|
+
data.tar.gz: 512436e0c43e5d6bbf3b7010309d49236d2f05068921633b47ffdc484757b8c96cb04a688694b802b1be24c05398b005a1eb8f41d35b431ae55bb03f267f70ea
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
require 'dns/resolve_host'
|
4
|
+
|
5
|
+
require 'event_store/http/connect/log'
|
6
|
+
|
7
|
+
require 'event_store/http/connect/defaults'
|
8
|
+
require 'event_store/http/connect/net_http'
|
9
|
+
require 'event_store/http/connect/settings'
|
10
|
+
|
11
|
+
require 'event_store/http/connect/assertions'
|
12
|
+
require 'event_store/http/connect/log_attributes'
|
13
|
+
|
14
|
+
require 'event_store/http/connect/telemetry'
|
15
|
+
|
16
|
+
require 'event_store/http/connect/connect'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Assertions
|
5
|
+
def settings?(settings, namespace: nil)
|
6
|
+
namespace = Array(namespace)
|
7
|
+
|
8
|
+
Settings.names.all? do |name|
|
9
|
+
settings_value = settings.get name, *namespace
|
10
|
+
|
11
|
+
if settings_value.nil?
|
12
|
+
true
|
13
|
+
else
|
14
|
+
instance_value = __send__ name
|
15
|
+
|
16
|
+
instance_value == settings_value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
include Log::Dependency
|
5
|
+
|
6
|
+
dependency :resolve_host, DNS::ResolveHost
|
7
|
+
dependency :telemetry, ::Telemetry
|
8
|
+
|
9
|
+
setting :host
|
10
|
+
setting :port
|
11
|
+
|
12
|
+
setting :continue_timeout
|
13
|
+
setting :keep_alive_timeout
|
14
|
+
setting :open_timeout
|
15
|
+
setting :read_timeout
|
16
|
+
|
17
|
+
def self.build(settings=nil, namespace: nil)
|
18
|
+
settings ||= Settings.build
|
19
|
+
namespace = Array(namespace)
|
20
|
+
|
21
|
+
instance = new
|
22
|
+
DNS::ResolveHost.configure instance
|
23
|
+
::Telemetry.configure instance
|
24
|
+
settings.set instance, *namespace
|
25
|
+
instance
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.call(settings=nil, namespace: nil, host: nil, &block)
|
29
|
+
instance = build settings, namespace: namespace
|
30
|
+
instance.(host, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure(receiver, settings=nil, namespace: nil, connect: nil, attr_name: nil)
|
34
|
+
attr_name ||= :connect
|
35
|
+
|
36
|
+
if connect.nil?
|
37
|
+
instance = build settings, namespace: namespace
|
38
|
+
else
|
39
|
+
instance = connect
|
40
|
+
end
|
41
|
+
|
42
|
+
receiver.public_send "#{attr_name}=", instance
|
43
|
+
|
44
|
+
instance
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.register_telemetry_sink(instance)
|
48
|
+
sink = Telemetry::Sink.new
|
49
|
+
instance.telemetry.register sink
|
50
|
+
sink
|
51
|
+
end
|
52
|
+
|
53
|
+
def call(host=nil, &block)
|
54
|
+
log_attributes = LogAttributes.get self, host: host
|
55
|
+
|
56
|
+
host ||= self.host
|
57
|
+
|
58
|
+
logger.trace { "Establishing HTTP connection to EventStore (#{log_attributes})" }
|
59
|
+
|
60
|
+
begin
|
61
|
+
ip_addresses = resolve_ip_address host
|
62
|
+
rescue DNS::ResolveHost::ResolutionError => error
|
63
|
+
error_message = "Could not connect to EventStore (#{log_attributes}, Error: #{error.class})"
|
64
|
+
logger.error error_message
|
65
|
+
|
66
|
+
record_host_resolution_failed host, error
|
67
|
+
|
68
|
+
raise ConnectionError, error
|
69
|
+
end
|
70
|
+
|
71
|
+
record_host_resolved host, ip_addresses
|
72
|
+
|
73
|
+
net_http = nil
|
74
|
+
|
75
|
+
ip_addresses.each_with_index do |ip_address, index|
|
76
|
+
net_http = new_connection ip_address
|
77
|
+
|
78
|
+
begin
|
79
|
+
net_http.start
|
80
|
+
|
81
|
+
record_connection_established host, ip_address, net_http
|
82
|
+
|
83
|
+
break
|
84
|
+
rescue Errno::EADDRNOTAVAIL, Errno::ECONNREFUSED, SocketError => error
|
85
|
+
record_connection_attempt_failed host, ip_address, error
|
86
|
+
|
87
|
+
error_message = "Could not connect to EventStore (#{log_attributes}, IPAddress: #{ip_address} (#{index.next} of #{ip_addresses.count}), Error: #{error.class})"
|
88
|
+
|
89
|
+
if index + 1 == ip_addresses.count
|
90
|
+
logger.error error_message
|
91
|
+
raise ConnectionError, error_message
|
92
|
+
else
|
93
|
+
logger.warn error_message
|
94
|
+
net_http = nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
unless block.nil?
|
100
|
+
begin
|
101
|
+
block.(net_http)
|
102
|
+
ensure
|
103
|
+
net_http.finish
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
logger.info { "HTTP connection to EventStore established (#{log_attributes}, IPAddress: #{net_http.address})" }
|
108
|
+
|
109
|
+
net_http
|
110
|
+
end
|
111
|
+
|
112
|
+
def resolve_ip_address(host)
|
113
|
+
logger.trace { "Resolving IP address from host (Host: #{host})" }
|
114
|
+
|
115
|
+
ip_addresses = resolve_host.(host) do |dns_resolver|
|
116
|
+
dns_resolver.timeouts = open_timeout
|
117
|
+
end
|
118
|
+
|
119
|
+
logger.debug { "Resolved IP address from host (Host: #{host}, IPAddresses: #{ip_addresses.inspect})" }
|
120
|
+
|
121
|
+
ip_addresses
|
122
|
+
end
|
123
|
+
|
124
|
+
def record_connection_established(host, ip_address, connection)
|
125
|
+
record = Telemetry::ConnectionEstablished.new host, ip_address, port, connection
|
126
|
+
|
127
|
+
telemetry.record :connection_established, record
|
128
|
+
|
129
|
+
record
|
130
|
+
end
|
131
|
+
|
132
|
+
def record_connection_attempt_failed(host, ip_address, error)
|
133
|
+
record = Telemetry::ConnectionAttemptFailed.new host, ip_address, port, error
|
134
|
+
|
135
|
+
telemetry.record :connection_attempt_failed, record
|
136
|
+
|
137
|
+
record
|
138
|
+
end
|
139
|
+
|
140
|
+
def record_host_resolved(host, ip_addresses)
|
141
|
+
record = Telemetry::HostResolved.new host, ip_addresses
|
142
|
+
|
143
|
+
telemetry.record :host_resolved, record
|
144
|
+
|
145
|
+
record
|
146
|
+
end
|
147
|
+
|
148
|
+
def record_host_resolution_failed(host, error)
|
149
|
+
record = Telemetry::HostResolutionFailed.new host, error
|
150
|
+
|
151
|
+
telemetry.record :host_resolution_failed, record
|
152
|
+
|
153
|
+
record
|
154
|
+
end
|
155
|
+
|
156
|
+
def new_connection(ip_address)
|
157
|
+
net_http = Net::HTTP.new ip_address, port
|
158
|
+
|
159
|
+
net_http.continue_timeout = continue_timeout unless continue_timeout.nil?
|
160
|
+
net_http.keep_alive_timeout = keep_alive_timeout unless keep_alive_timeout.nil?
|
161
|
+
net_http.open_timeout = open_timeout unless open_timeout.nil?
|
162
|
+
net_http.read_timeout = read_timeout unless read_timeout.nil?
|
163
|
+
|
164
|
+
net_http
|
165
|
+
end
|
166
|
+
|
167
|
+
def port
|
168
|
+
@port ||= Defaults.port
|
169
|
+
end
|
170
|
+
|
171
|
+
ConnectionError = Class.new StandardError
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
require 'event_store/http/connect/controls/ip_address'
|
4
|
+
require 'event_store/http/connect/controls/ip_address/loopback'
|
5
|
+
require 'event_store/http/connect/controls/ip_address/loopback/alias'
|
6
|
+
require 'event_store/http/connect/controls/ip_address/non_routable'
|
7
|
+
require 'event_store/http/connect/controls/ip_address/unavailable'
|
8
|
+
|
9
|
+
require 'event_store/http/connect/controls/cluster/hostname'
|
10
|
+
require 'event_store/http/connect/controls/cluster/ip_address'
|
11
|
+
require 'event_store/http/connect/controls/cluster/resolve_host'
|
12
|
+
require 'event_store/http/connect/controls/cluster/size'
|
13
|
+
|
14
|
+
require 'event_store/http/connect/controls/host'
|
15
|
+
require 'event_store/http/connect/controls/hostname'
|
16
|
+
require 'event_store/http/connect/controls/net_http'
|
17
|
+
require 'event_store/http/connect/controls/port'
|
18
|
+
require 'event_store/http/connect/controls/resolve_host'
|
19
|
+
require 'event_store/http/connect/controls/settings'
|
20
|
+
require 'event_store/http/connect/controls/timeouts'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Cluster
|
6
|
+
module Hostname
|
7
|
+
def self.example
|
8
|
+
Hostname.example 'cluster'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Size
|
13
|
+
def self.example
|
14
|
+
3
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Cluster
|
6
|
+
module IPAddress
|
7
|
+
def self.example(member_index=nil, third_octet: nil)
|
8
|
+
member_index ||= 1
|
9
|
+
third_octet ||= 111
|
10
|
+
|
11
|
+
Controls::IPAddress::Loopback::Alias.example(
|
12
|
+
member_index,
|
13
|
+
third_octet: third_octet
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
module List
|
18
|
+
def list
|
19
|
+
(1..Size.example).map do |member_index|
|
20
|
+
example member_index
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
extend List
|
25
|
+
|
26
|
+
module Unavailable
|
27
|
+
extend List
|
28
|
+
|
29
|
+
def self.example(member_index=nil)
|
30
|
+
IPAddress.example member_index, third_octet: 222
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module PartiallyAvailable
|
35
|
+
extend List
|
36
|
+
|
37
|
+
def self.example(member_index=nil)
|
38
|
+
member_index ||= nil
|
39
|
+
|
40
|
+
if member_index == 1
|
41
|
+
Unavailable.example member_index
|
42
|
+
else
|
43
|
+
IPAddress.example member_index
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Cluster
|
6
|
+
module ResolveHost
|
7
|
+
def self.configure(receiver, host: nil, ip_addresses: nil)
|
8
|
+
host ||= Hostname.example
|
9
|
+
ip_addresses ||= IPAddress.list
|
10
|
+
|
11
|
+
Controls::ResolveHost.configure(
|
12
|
+
receiver,
|
13
|
+
host: host,
|
14
|
+
ip_addresses: ip_addresses
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Hostname
|
6
|
+
def self.example(suffix=nil)
|
7
|
+
if suffix.nil?
|
8
|
+
'eventstore.local'
|
9
|
+
else
|
10
|
+
"eventstore-#{suffix}.local"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Localhost
|
15
|
+
def self.example
|
16
|
+
'localhost'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Other
|
21
|
+
def self.example(randomize: nil)
|
22
|
+
if randomize
|
23
|
+
random = SecureRandom.hex 7
|
24
|
+
|
25
|
+
"some-hostname-#{random}"
|
26
|
+
else
|
27
|
+
'some-hostname'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module IPAddress
|
6
|
+
module Loopback
|
7
|
+
module Alias
|
8
|
+
def self.example(fourth_octet=nil, third_octet: nil)
|
9
|
+
third_octet ||= 0
|
10
|
+
|
11
|
+
if third_octet == 0
|
12
|
+
fourth_octet ||= 2
|
13
|
+
else
|
14
|
+
fourth_octet ||= 1
|
15
|
+
end
|
16
|
+
|
17
|
+
"127.0.#{third_octet}.#{fourth_octet}"
|
18
|
+
end
|
19
|
+
|
20
|
+
module VerifyAll
|
21
|
+
def self.call
|
22
|
+
port = Port::Unused.get
|
23
|
+
|
24
|
+
unaliased_ip_addresses = list.select do |ip_address|
|
25
|
+
begin
|
26
|
+
server = TCPServer.new ip_address, port
|
27
|
+
server.close
|
28
|
+
false
|
29
|
+
rescue Errno::EADDRNOTAVAIL
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
return true if unaliased_ip_addresses.none?
|
35
|
+
|
36
|
+
warn <<~MESSAGE
|
37
|
+
The following loopback aliases are not configured:
|
38
|
+
|
39
|
+
#{unaliased_ip_addresses * "\n "}
|
40
|
+
|
41
|
+
To setup a loopback alias, run the following command:
|
42
|
+
|
43
|
+
sudo ifconfig lo0 alias 127.0.111.1
|
44
|
+
|
45
|
+
Note that the above command was tested on OS X and may vary
|
46
|
+
on Linux systems.
|
47
|
+
MESSAGE
|
48
|
+
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.list
|
53
|
+
[
|
54
|
+
Alias.example,
|
55
|
+
*Cluster::IPAddress.list,
|
56
|
+
*Cluster::IPAddress::Unavailable.list
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module IPAddress
|
6
|
+
module Unavailable
|
7
|
+
def self.example
|
8
|
+
external
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.external
|
12
|
+
local_ip_address_list = Socket.ip_address_list
|
13
|
+
|
14
|
+
local_ip_address_list.map! &:ip_address
|
15
|
+
|
16
|
+
local_ip_address_list.find do |ip_address|
|
17
|
+
ip_address != IPAddress::Loopback.example
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module NetHTTP
|
6
|
+
def self.example
|
7
|
+
net_http = Net::HTTP.new host, port
|
8
|
+
net_http.start
|
9
|
+
net_http
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.host
|
13
|
+
IPAddress.example
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.port
|
17
|
+
Port.example
|
18
|
+
end
|
19
|
+
|
20
|
+
module Defaults
|
21
|
+
def self.keep_alive_timeout
|
22
|
+
2
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.open_timeout
|
26
|
+
60
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.read_timeout
|
30
|
+
60
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Port
|
6
|
+
def self.example
|
7
|
+
Connect::Defaults.port
|
8
|
+
end
|
9
|
+
|
10
|
+
module Unused
|
11
|
+
def self.get
|
12
|
+
localhost = IPAddress::Loopback.example
|
13
|
+
|
14
|
+
(10000..19999).each do |port|
|
15
|
+
begin
|
16
|
+
socket = TCPSocket.new localhost, port
|
17
|
+
socket.close
|
18
|
+
next
|
19
|
+
|
20
|
+
rescue Errno::ECONNREFUSED
|
21
|
+
return port
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
fail
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module ResolveHost
|
6
|
+
def self.configure(receiver, host: nil, ip_addresses: nil)
|
7
|
+
host ||= Hostname.example
|
8
|
+
ip_addresses ||= [IPAddress.example]
|
9
|
+
|
10
|
+
resolve_host = SubstAttr::Substitute.(:resolve_host, receiver)
|
11
|
+
resolve_host.set host, ip_addresses
|
12
|
+
resolve_host
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Settings
|
6
|
+
def self.example(host: nil, namespace: nil, **attributes)
|
7
|
+
host ||= IPAddress.example
|
8
|
+
namespace = Array(namespace)
|
9
|
+
|
10
|
+
attributes[:host] = host
|
11
|
+
|
12
|
+
data_source = namespace.reduce attributes do |hash, namespace|
|
13
|
+
{ namespace => hash }
|
14
|
+
end
|
15
|
+
|
16
|
+
EventStore::HTTP::Connect::Settings.build data_source
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Controls
|
5
|
+
module Timeouts
|
6
|
+
def self.continue
|
7
|
+
1
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.keep_alive
|
11
|
+
2
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.open
|
15
|
+
3
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.read
|
19
|
+
4
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module LogAttributes
|
5
|
+
def self.get(connect, host: nil)
|
6
|
+
if host.nil?
|
7
|
+
host_text = connect.host
|
8
|
+
else
|
9
|
+
host_text = "#{host} [Overriding setting: #{connect.host}]"
|
10
|
+
end
|
11
|
+
|
12
|
+
connect.instance_exec do
|
13
|
+
"Host: #{host_text}, Port: #{port}, KeepAliveTimeout: #{keep_alive_timeout || '(default)'}, ReadTimeout: #{read_timeout || '(default)'}, OpenTimeout: #{open_timeout || '(default)'}, ContinueTimeout: #{continue_timeout || '(none)'}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module NetHTTP
|
5
|
+
module Assertions
|
6
|
+
def connected?(ip_address: nil, port: nil)
|
7
|
+
unless ip_address.nil? || ip_address == self.address
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
|
11
|
+
unless port.nil? || port == self.port
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
|
15
|
+
active?
|
16
|
+
end
|
17
|
+
|
18
|
+
def closed?
|
19
|
+
not active?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
class Settings < ::Settings
|
5
|
+
def self.data_source
|
6
|
+
'settings/event_store_http.json'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.names
|
10
|
+
%i(
|
11
|
+
host
|
12
|
+
port
|
13
|
+
continue_timeout
|
14
|
+
read_timeout
|
15
|
+
open_timeout
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module EventStore
|
2
|
+
module HTTP
|
3
|
+
class Connect
|
4
|
+
module Telemetry
|
5
|
+
class Sink
|
6
|
+
include ::Telemetry::Sink
|
7
|
+
|
8
|
+
record :host_resolved
|
9
|
+
record :host_resolution_failed
|
10
|
+
record :connection_attempt_failed
|
11
|
+
record :connection_established
|
12
|
+
end
|
13
|
+
|
14
|
+
HostResolved = Struct.new :host, :ip_addresses
|
15
|
+
|
16
|
+
HostResolutionFailed = Struct.new :host, :error
|
17
|
+
|
18
|
+
ConnectionAttemptFailed = Struct.new :host, :ip_address, :port, :error
|
19
|
+
|
20
|
+
ConnectionEstablished = Struct.new :host, :ip_address, :port, :connection
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: evt-event_store-http-connect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- The Eventide Project
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: evt-dns-resolve_host
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test_bench
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: " "
|
42
|
+
email: opensource@eventide-project.org
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/event_store/http/connect.rb
|
48
|
+
- lib/event_store/http/connect/assertions.rb
|
49
|
+
- lib/event_store/http/connect/connect.rb
|
50
|
+
- lib/event_store/http/connect/controls.rb
|
51
|
+
- lib/event_store/http/connect/controls/cluster.rb
|
52
|
+
- lib/event_store/http/connect/controls/cluster/hostname.rb
|
53
|
+
- lib/event_store/http/connect/controls/cluster/ip_address.rb
|
54
|
+
- lib/event_store/http/connect/controls/cluster/resolve_host.rb
|
55
|
+
- lib/event_store/http/connect/controls/cluster/size.rb
|
56
|
+
- lib/event_store/http/connect/controls/host.rb
|
57
|
+
- lib/event_store/http/connect/controls/hostname.rb
|
58
|
+
- lib/event_store/http/connect/controls/ip_address.rb
|
59
|
+
- lib/event_store/http/connect/controls/ip_address/loopback.rb
|
60
|
+
- lib/event_store/http/connect/controls/ip_address/loopback/alias.rb
|
61
|
+
- lib/event_store/http/connect/controls/ip_address/non_routable.rb
|
62
|
+
- lib/event_store/http/connect/controls/ip_address/unavailable.rb
|
63
|
+
- lib/event_store/http/connect/controls/net_http.rb
|
64
|
+
- lib/event_store/http/connect/controls/port.rb
|
65
|
+
- lib/event_store/http/connect/controls/resolve_host.rb
|
66
|
+
- lib/event_store/http/connect/controls/settings.rb
|
67
|
+
- lib/event_store/http/connect/controls/timeouts.rb
|
68
|
+
- lib/event_store/http/connect/defaults.rb
|
69
|
+
- lib/event_store/http/connect/log.rb
|
70
|
+
- lib/event_store/http/connect/log_attributes.rb
|
71
|
+
- lib/event_store/http/connect/net_http.rb
|
72
|
+
- lib/event_store/http/connect/settings.rb
|
73
|
+
- lib/event_store/http/connect/telemetry.rb
|
74
|
+
homepage: https://github.com/eventide-project/event-store-http-connect
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.3.3
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.6.8
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Connection library to EventStore's HTTP interface
|
98
|
+
test_files: []
|