bmx-event_hook_client_server 1.0.13 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +21 -16
- data/event_hook_client_server.gemspec +2 -0
- data/lib/event_hook_client_server/client.rb +77 -21
- data/lib/event_hook_client_server/client/models/integration.rb +1 -0
- data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/enums/integrator_pb.rb +2 -1
- data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/messages/error_pb.rb +1 -1
- data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/messages/integration_pb.rb +18 -15
- data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/messages/pagination_pb.rb +3 -3
- data/lib/event_hook_client_server/server.rb +6 -26
- data/lib/event_hook_client_server/server/definition_helpers.rb +25 -0
- data/lib/event_hook_client_server/version.rb +2 -2
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed419af695ba5667d416f2fd3826b5297e942aac442c84e7d8d3bc3dca806ac2
|
4
|
+
data.tar.gz: f3176686619effb003a699fc16212cdfb822a8042e489f28100d73788e649d61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a50cc931db6446dda08c410cfd24bac1cf9329929f5cdb6e342dd47f8b5997b764403a63a118040d583d53ed2384e1b88b01e207816231e71f7cf41c916e4a5
|
7
|
+
data.tar.gz: 8b81ffe9c68db56bcc4dc27d43ca00635e38d4f544df224073ec2d14f9972ab172e44d665a25a0041f7e3f3732045378a99de7e8a51d870644c6b4f36675235c
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bmx-event_hook_client_server (1.0.
|
4
|
+
bmx-event_hook_client_server (1.0.16)
|
5
5
|
dry-struct (~> 1.0)
|
6
6
|
google-protobuf (~> 3.9.2)
|
7
7
|
grpc (~> 1.24.0)
|
8
|
+
retriable (~> 3.1.2)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
13
|
coderay (1.1.2)
|
13
|
-
concurrent-ruby (1.1.
|
14
|
+
concurrent-ruby (1.1.6)
|
14
15
|
diff-lcs (1.3)
|
15
|
-
dry-configurable (0.
|
16
|
+
dry-configurable (0.11.5)
|
16
17
|
concurrent-ruby (~> 1.0)
|
17
18
|
dry-core (~> 0.4, >= 0.4.7)
|
19
|
+
dry-equalizer (~> 0.2)
|
18
20
|
dry-container (0.7.2)
|
19
21
|
concurrent-ruby (~> 1.0)
|
20
22
|
dry-configurable (~> 0.1, >= 0.1.3)
|
@@ -22,20 +24,20 @@ GEM
|
|
22
24
|
concurrent-ruby (~> 1.0)
|
23
25
|
dry-equalizer (0.3.0)
|
24
26
|
dry-inflector (0.2.0)
|
25
|
-
dry-logic (1.0.
|
27
|
+
dry-logic (1.0.6)
|
26
28
|
concurrent-ruby (~> 1.0)
|
27
29
|
dry-core (~> 0.2)
|
28
30
|
dry-equalizer (~> 0.2)
|
29
|
-
dry-struct (1.
|
30
|
-
dry-core (~> 0.4, >= 0.4.
|
31
|
-
dry-equalizer (~> 0.
|
32
|
-
dry-types (~> 1.
|
31
|
+
dry-struct (1.3.0)
|
32
|
+
dry-core (~> 0.4, >= 0.4.4)
|
33
|
+
dry-equalizer (~> 0.3)
|
34
|
+
dry-types (~> 1.3)
|
33
35
|
ice_nine (~> 0.11)
|
34
|
-
dry-types (1.
|
36
|
+
dry-types (1.4.0)
|
35
37
|
concurrent-ruby (~> 1.0)
|
36
38
|
dry-container (~> 0.3)
|
37
39
|
dry-core (~> 0.4, >= 0.4.4)
|
38
|
-
dry-equalizer (~> 0.
|
40
|
+
dry-equalizer (~> 0.3)
|
39
41
|
dry-inflector (~> 0.1, >= 0.1.2)
|
40
42
|
dry-logic (~> 1.0, >= 1.0.2)
|
41
43
|
google-protobuf (3.9.2)
|
@@ -44,26 +46,28 @@ GEM
|
|
44
46
|
grpc (1.24.0)
|
45
47
|
google-protobuf (~> 3.8)
|
46
48
|
googleapis-common-protos-types (~> 1.0)
|
47
|
-
grpc-tools (1.
|
49
|
+
grpc-tools (1.27.0)
|
48
50
|
ice_nine (0.11.2)
|
49
51
|
method_source (0.9.2)
|
50
52
|
pry (0.12.2)
|
51
53
|
coderay (~> 1.1.0)
|
52
54
|
method_source (~> 0.9.0)
|
53
55
|
rake (10.5.0)
|
56
|
+
retriable (3.1.2)
|
54
57
|
rspec (3.9.0)
|
55
58
|
rspec-core (~> 3.9.0)
|
56
59
|
rspec-expectations (~> 3.9.0)
|
57
60
|
rspec-mocks (~> 3.9.0)
|
58
|
-
rspec-core (3.9.
|
59
|
-
rspec-support (~> 3.9.
|
61
|
+
rspec-core (3.9.1)
|
62
|
+
rspec-support (~> 3.9.1)
|
60
63
|
rspec-expectations (3.9.0)
|
61
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
65
|
rspec-support (~> 3.9.0)
|
63
|
-
rspec-mocks (3.9.
|
66
|
+
rspec-mocks (3.9.1)
|
64
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
68
|
rspec-support (~> 3.9.0)
|
66
|
-
rspec-support (3.9.
|
69
|
+
rspec-support (3.9.2)
|
70
|
+
timecop (0.9.1)
|
67
71
|
|
68
72
|
PLATFORMS
|
69
73
|
ruby
|
@@ -76,6 +80,7 @@ DEPENDENCIES
|
|
76
80
|
pry
|
77
81
|
rake (~> 10.0)
|
78
82
|
rspec (~> 3.0)
|
83
|
+
timecop
|
79
84
|
|
80
85
|
BUNDLED WITH
|
81
|
-
2.1.
|
86
|
+
2.1.4
|
@@ -59,6 +59,8 @@ Gem::Specification.new do |spec|
|
|
59
59
|
spec.add_dependency 'dry-struct', '~> 1.0'
|
60
60
|
spec.add_dependency 'google-protobuf', '~> 3.9.2'
|
61
61
|
spec.add_dependency 'grpc', '~> 1.24.0'
|
62
|
+
spec.add_dependency 'retriable', '~> 3.1.2'
|
63
|
+
# spec.add_dependency 'zeitwerk'
|
62
64
|
|
63
65
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
64
66
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'resolv'
|
5
|
+
require 'retriable'
|
4
6
|
require 'event_hook_client_server/protobuf/event_hook_client_server/v1/services/webhook_configurator_services_pb'
|
5
7
|
require 'event_hook_client_server/refinements/protobuf/nullable_values'
|
6
8
|
require 'event_hook_client_server/refinements/protobuf/hashable_struct_values'
|
@@ -15,7 +17,10 @@ using EventHookClientServer::Refinements::Hash::Transmute
|
|
15
17
|
using EventHookClientServer::Refinements::Protobuf::HashableStructValues
|
16
18
|
|
17
19
|
module EventHookClientServer
|
18
|
-
class Client
|
20
|
+
class Client
|
21
|
+
GRPC_CLIENT_CLASS = EventHookClientServer::V1::Services::EventHook::Stub
|
22
|
+
private_constant :GRPC_CLIENT_CLASS
|
23
|
+
|
19
24
|
# Configuration options can be found @
|
20
25
|
# https://github.com/grpc/grpc/issues/19734
|
21
26
|
DEFAULT_CONFIG = {
|
@@ -39,6 +44,15 @@ module EventHookClientServer
|
|
39
44
|
}.freeze
|
40
45
|
private_constant :DEFAULT_CONFIG
|
41
46
|
|
47
|
+
RETRIABLE_ERRORS = [
|
48
|
+
GRPC::DeadlineExceeded, GRPC::Unavailable, GRPC::ResourceExhausted,
|
49
|
+
GRPC::Unknown
|
50
|
+
]
|
51
|
+
private_constant :RETRIABLE_ERRORS
|
52
|
+
|
53
|
+
SRV = Resolv::DNS::Resource::IN::SRV
|
54
|
+
private_constant :SRV
|
55
|
+
|
42
56
|
def self.default
|
43
57
|
@default ||= new(default_config)
|
44
58
|
end
|
@@ -47,10 +61,38 @@ module EventHookClientServer
|
|
47
61
|
@default_config ||= DEFAULT_CONFIG.dup
|
48
62
|
end
|
49
63
|
|
64
|
+
attr_reader :hosts
|
65
|
+
attr_reader :hosts_expire_at
|
66
|
+
attr_reader :options
|
67
|
+
attr_reader :grpc_client
|
68
|
+
|
50
69
|
def initialize(options)
|
51
|
-
options = self.class.default_config.merge(options)
|
52
|
-
|
53
|
-
|
70
|
+
@options = self.class.default_config.merge(options)
|
71
|
+
|
72
|
+
refresh_hosts!
|
73
|
+
recreate_grpc_client!
|
74
|
+
end
|
75
|
+
|
76
|
+
def rotate_host!
|
77
|
+
refresh_hosts!
|
78
|
+
recreate_grpc_client!
|
79
|
+
end
|
80
|
+
|
81
|
+
def refresh_hosts!
|
82
|
+
return if !hosts_expire_at.nil? && Time.now.to_i < hosts_expire_at
|
83
|
+
|
84
|
+
result = fetch_srv_host_record
|
85
|
+
@hosts_expire_at = Time.now.to_i + (result.map(&:ttl).min || 60)
|
86
|
+
|
87
|
+
hosts = result.map { |r| [r.target&.to_s, r.port].compact.join(':') }
|
88
|
+
hosts = [options[:host]].compact if hosts.empty?
|
89
|
+
|
90
|
+
@hosts = hosts.each.cycle
|
91
|
+
end
|
92
|
+
|
93
|
+
def recreate_grpc_client!
|
94
|
+
@grpc_client = GRPC_CLIENT_CLASS.new(
|
95
|
+
hosts.next,
|
54
96
|
options[:channel_mode],
|
55
97
|
timeout: options[:timeout],
|
56
98
|
channel_args: options[:channel_args]
|
@@ -64,7 +106,9 @@ module EventHookClientServer
|
|
64
106
|
pagination: { cursor: cursor }
|
65
107
|
)
|
66
108
|
|
67
|
-
response =
|
109
|
+
response = retry_on_failure do
|
110
|
+
grpc_client.find_integration_from_headers(request)
|
111
|
+
end
|
68
112
|
|
69
113
|
integrations = response.integrations.map do |integration|
|
70
114
|
Integration.new(integration.to_h)
|
@@ -78,7 +122,7 @@ module EventHookClientServer
|
|
78
122
|
def integration(id)
|
79
123
|
request = V1::Messages::GetIntegrationRequest.new(id: id.to_s)
|
80
124
|
|
81
|
-
response =
|
125
|
+
response = retry_on_failure { grpc_client.integration(request) }
|
82
126
|
|
83
127
|
if response.errors.any?
|
84
128
|
Response.fail!(response.errors.map { |e| Error.new(e.to_h) })
|
@@ -106,7 +150,7 @@ module EventHookClientServer
|
|
106
150
|
V1::Messages::ListIntegrationsRequest.new(query_params: query_params,
|
107
151
|
pagination: pagination)
|
108
152
|
|
109
|
-
response =
|
153
|
+
response = retry_on_failure { grpc_client.integrations(request) }
|
110
154
|
|
111
155
|
integrations = response.integrations.map do |integration|
|
112
156
|
Integration.new(integration.to_h)
|
@@ -124,7 +168,7 @@ module EventHookClientServer
|
|
124
168
|
|
125
169
|
request = V1::Messages::IntegrationCreateRequest.new(input: params)
|
126
170
|
|
127
|
-
response =
|
171
|
+
response = retry_on_failure { grpc_client.create_integration(request) }
|
128
172
|
|
129
173
|
if response.errors.any?
|
130
174
|
Response.fail!(response.errors.map { |e| Error.new(e.to_h) })
|
@@ -141,7 +185,7 @@ module EventHookClientServer
|
|
141
185
|
|
142
186
|
request = V1::Messages::IntegrationUpdateRequest.new(id: id.to_s,
|
143
187
|
input: params)
|
144
|
-
response =
|
188
|
+
response = retry_on_failure { grpc_client.update_integration(request) }
|
145
189
|
|
146
190
|
if response.errors.any?
|
147
191
|
Response.fail!(response.errors.map { |e| Error.new(e.to_h) })
|
@@ -154,7 +198,7 @@ module EventHookClientServer
|
|
154
198
|
def destroy_integration(id:)
|
155
199
|
request = V1::Messages::IntegrationDestroyRequest.new(id: id.to_s)
|
156
200
|
|
157
|
-
response =
|
201
|
+
response = retry_on_failure { grpc_client.destroy_integration(request) }
|
158
202
|
|
159
203
|
if response.errors.any?
|
160
204
|
Response.fail!([])
|
@@ -165,22 +209,34 @@ module EventHookClientServer
|
|
165
209
|
|
166
210
|
private
|
167
211
|
|
168
|
-
def
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
try += 1
|
174
|
-
|
175
|
-
sleep(sleep_time) if sleep_time.positive?
|
176
|
-
retry if try < max_retries
|
177
|
-
|
178
|
-
raise(error)
|
212
|
+
def retry_on_failure(&block)
|
213
|
+
Retriable
|
214
|
+
.retriable(on: RETRIABLE_ERRORS, on_retry: proc { rotate_host! }) do
|
215
|
+
block.call
|
216
|
+
end
|
179
217
|
end
|
180
218
|
|
181
219
|
def symbolize_keys(hash)
|
182
220
|
JSON.parse(hash.to_json, symbolize_names: true)
|
183
221
|
end
|
222
|
+
|
223
|
+
def fetch_srv_host_record
|
224
|
+
records = []
|
225
|
+
|
226
|
+
Resolv::DNS.new
|
227
|
+
.each_resource(options[:host], SRV) do |x|
|
228
|
+
records << x
|
229
|
+
end
|
230
|
+
|
231
|
+
records.sort do |a, b|
|
232
|
+
priority = a.priority <=> b.priority
|
233
|
+
weight = (a.weight <=> b.weight) * -1
|
234
|
+
|
235
|
+
priority.zero? ? weight : priority
|
236
|
+
end
|
237
|
+
rescue Resolv::ResolvError, ArgumentError
|
238
|
+
[]
|
239
|
+
end
|
184
240
|
end
|
185
241
|
end
|
186
242
|
|
@@ -17,6 +17,7 @@ module EventHookClientServer
|
|
17
17
|
attribute :building_id, Types::Strict::String.optional
|
18
18
|
attribute :tenant_id, Types::Strict::String.optional
|
19
19
|
attribute :company_id, Types::Strict::String.optional
|
20
|
+
attribute :unit_id, Types::Strict::String.optional
|
20
21
|
attribute :integrator, Types::Strict::Symbol
|
21
22
|
attribute :config, Types::Strict::Hash
|
22
23
|
attribute :bindings, Types::Array.of(Binding)
|
data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/enums/integrator_pb.rb
CHANGED
@@ -8,6 +8,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
8
8
|
add_enum "event_hook_client_server.v1.enums.Integrator" do
|
9
9
|
value :WEBHOOK, 0
|
10
10
|
value :PDK, 9
|
11
|
+
value :AIRBNB, 1
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -15,7 +16,7 @@ end
|
|
15
16
|
module EventHookClientServer
|
16
17
|
module V1
|
17
18
|
module Enums
|
18
|
-
Integrator = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.enums.Integrator").enummodule
|
19
|
+
Integrator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.enums.Integrator").enummodule
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
module EventHookClientServer
|
18
18
|
module V1
|
19
19
|
module Messages
|
20
|
-
Error = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Error").msgclass
|
20
|
+
Error = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Error").msgclass
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/messages/integration_pb.rb
CHANGED
@@ -18,6 +18,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
18
18
|
optional :building_id, :message, 10, "google.protobuf.StringValue"
|
19
19
|
optional :tenant_id, :message, 11, "google.protobuf.StringValue"
|
20
20
|
optional :company_id, :message, 12, "google.protobuf.StringValue"
|
21
|
+
optional :unit_id, :message, 13, "google.protobuf.StringValue"
|
21
22
|
end
|
22
23
|
add_message "event_hook_client_server.v1.messages.IntegrationConfiguration" do
|
23
24
|
optional :type, :enum, 1, "event_hook_client_server.v1.enums.Integrator"
|
@@ -34,6 +35,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
34
35
|
optional :building_id, :message, 10, "google.protobuf.StringValue"
|
35
36
|
optional :tenant_id, :message, 11, "google.protobuf.StringValue"
|
36
37
|
optional :company_id, :message, 12, "google.protobuf.StringValue"
|
38
|
+
optional :unit_id, :message, 13, "google.protobuf.StringValue"
|
37
39
|
end
|
38
40
|
add_message "event_hook_client_server.v1.messages.IntegrationInputConfiguration" do
|
39
41
|
optional :type, :enum, 1, "event_hook_client_server.v1.enums.Integrator"
|
@@ -80,6 +82,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
80
82
|
optional :building_id, :message, 10, "google.protobuf.StringValue"
|
81
83
|
optional :tenant_id, :message, 11, "google.protobuf.StringValue"
|
82
84
|
optional :company_id, :message, 12, "google.protobuf.StringValue"
|
85
|
+
optional :unit_id, :message, 13, "google.protobuf.StringValue"
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
@@ -87,21 +90,21 @@ end
|
|
87
90
|
module EventHookClientServer
|
88
91
|
module V1
|
89
92
|
module Messages
|
90
|
-
Integration = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Integration").msgclass
|
91
|
-
IntegrationConfiguration = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationConfiguration").msgclass
|
92
|
-
IntegrationBinding = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationBinding").msgclass
|
93
|
-
IntegrationInput = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationInput").msgclass
|
94
|
-
IntegrationInputConfiguration = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationInputConfiguration").msgclass
|
95
|
-
IntegrationBindingInput = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationBindingInput").msgclass
|
96
|
-
IntegrationCreateRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationCreateRequest").msgclass
|
97
|
-
IntegrationUpdateRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationUpdateRequest").msgclass
|
98
|
-
IntegrationDestroyRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationDestroyRequest").msgclass
|
99
|
-
GetIntegrationRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.GetIntegrationRequest").msgclass
|
100
|
-
ListIntegrationsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.ListIntegrationsRequest").msgclass
|
101
|
-
FindIntegrationsFromHeadersRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.FindIntegrationsFromHeadersRequest").msgclass
|
102
|
-
IntegrationSingleResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationSingleResponse").msgclass
|
103
|
-
IntegrationsListResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationsListResponse").msgclass
|
104
|
-
IntegrationQueryParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationQueryParams").msgclass
|
93
|
+
Integration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Integration").msgclass
|
94
|
+
IntegrationConfiguration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationConfiguration").msgclass
|
95
|
+
IntegrationBinding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationBinding").msgclass
|
96
|
+
IntegrationInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationInput").msgclass
|
97
|
+
IntegrationInputConfiguration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationInputConfiguration").msgclass
|
98
|
+
IntegrationBindingInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationBindingInput").msgclass
|
99
|
+
IntegrationCreateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationCreateRequest").msgclass
|
100
|
+
IntegrationUpdateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationUpdateRequest").msgclass
|
101
|
+
IntegrationDestroyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationDestroyRequest").msgclass
|
102
|
+
GetIntegrationRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.GetIntegrationRequest").msgclass
|
103
|
+
ListIntegrationsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.ListIntegrationsRequest").msgclass
|
104
|
+
FindIntegrationsFromHeadersRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.FindIntegrationsFromHeadersRequest").msgclass
|
105
|
+
IntegrationSingleResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationSingleResponse").msgclass
|
106
|
+
IntegrationsListResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationsListResponse").msgclass
|
107
|
+
IntegrationQueryParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.IntegrationQueryParams").msgclass
|
105
108
|
end
|
106
109
|
end
|
107
110
|
end
|
data/lib/event_hook_client_server/protobuf/event_hook_client_server/v1/messages/pagination_pb.rb
CHANGED
@@ -27,9 +27,9 @@ end
|
|
27
27
|
module EventHookClientServer
|
28
28
|
module V1
|
29
29
|
module Messages
|
30
|
-
Cursors = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Cursors").msgclass
|
31
|
-
Pagination = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Pagination").msgclass
|
32
|
-
PaginationInput = Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.PaginationInput").msgclass
|
30
|
+
Cursors = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Cursors").msgclass
|
31
|
+
Pagination = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.Pagination").msgclass
|
32
|
+
PaginationInput = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("event_hook_client_server.v1.messages.PaginationInput").msgclass
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -4,6 +4,9 @@ require 'event_hook_client_server/protobuf/event_hook_client_server/v1/services/
|
|
4
4
|
|
5
5
|
module EventHookClientServer
|
6
6
|
class Server < EventHookClientServer::V1::Services::EventHook::Service
|
7
|
+
require 'event_hook_client_server/server/definition_helpers'
|
8
|
+
extend EventHookClientServer::Server::DefinitionHelpers
|
9
|
+
|
7
10
|
# Configuration options can be found @
|
8
11
|
# https://github.com/grpc/grpc/issues/19734
|
9
12
|
DEFAULT_CONFIG = {
|
@@ -29,31 +32,6 @@ module EventHookClientServer
|
|
29
32
|
}.freeze
|
30
33
|
private_constant :DEFAULT_CONFIG
|
31
34
|
|
32
|
-
def self.generic_rpc(name, options = {})
|
33
|
-
[
|
34
|
-
[:create_],
|
35
|
-
[:update_],
|
36
|
-
[:destroy_],
|
37
|
-
[],
|
38
|
-
[nil, :s]
|
39
|
-
].compact.each do |prefix, suffix|
|
40
|
-
method_name = [prefix, name, suffix].compact.join
|
41
|
-
handler_name = "#{method_name}_handler".to_sym
|
42
|
-
|
43
|
-
attr_accessor handler_name
|
44
|
-
|
45
|
-
# NOTE: this is ugly, but it's (performance wise) much faster than
|
46
|
-
# define_method
|
47
|
-
method_definition = <<-RUBY
|
48
|
-
def #{method_name}(input, request)
|
49
|
-
process_request(:#{method_name}, input, request)
|
50
|
-
end
|
51
|
-
RUBY
|
52
|
-
|
53
|
-
class_eval(method_definition, __FILE__, __LINE__ - 5)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
35
|
def self.default_config
|
58
36
|
@default_config ||= DEFAULT_CONFIG.dup
|
59
37
|
end
|
@@ -90,11 +68,13 @@ module EventHookClientServer
|
|
90
68
|
@logger ||= Logger.new(STDOUT)
|
91
69
|
end
|
92
70
|
|
71
|
+
# Defines SHOW, INDEX, CREATE, UPDATE and DELETE methods
|
93
72
|
generic_rpc :integration
|
94
73
|
|
95
74
|
attr_accessor :find_integration_from_headers_handler
|
75
|
+
|
96
76
|
def find_integration_from_headers(input, request)
|
97
|
-
process_request(
|
77
|
+
process_request(__method__, input, request)
|
98
78
|
end
|
99
79
|
|
100
80
|
protected
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EventHookClientServer
|
2
|
+
class Server
|
3
|
+
module DefinitionHelpers
|
4
|
+
def generic_rpc(name, options = {})
|
5
|
+
[[:create_], [:update_], [:destroy_], [], [nil, :s]]
|
6
|
+
.compact.each do |prefix, suffix|
|
7
|
+
method_name = [prefix, name, suffix].compact.join
|
8
|
+
handler_name = "#{method_name}_handler".to_sym
|
9
|
+
|
10
|
+
attr_accessor handler_name
|
11
|
+
|
12
|
+
# NOTE: this is ugly, but it's (performance wise) much faster than
|
13
|
+
# define_method
|
14
|
+
method_definition = <<-RUBY
|
15
|
+
def #{method_name}(input, request)
|
16
|
+
process_request(:#{method_name}, input, request)
|
17
|
+
end
|
18
|
+
RUBY
|
19
|
+
|
20
|
+
class_eval(method_definition, __FILE__, __LINE__ - 5)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmx-event_hook_client_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanko K.R.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.24.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: retriable
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.2
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +137,7 @@ files:
|
|
123
137
|
- lib/event_hook_client_server/refinements/protobuf/hashable_struct_values.rb
|
124
138
|
- lib/event_hook_client_server/refinements/protobuf/nullable_values.rb
|
125
139
|
- lib/event_hook_client_server/server.rb
|
140
|
+
- lib/event_hook_client_server/server/definition_helpers.rb
|
126
141
|
- lib/event_hook_client_server/server/request_processor.rb
|
127
142
|
- lib/event_hook_client_server/service.rb
|
128
143
|
- lib/event_hook_client_server/services/grpc/struct_encoder.rb
|
@@ -135,7 +150,7 @@ metadata:
|
|
135
150
|
homepage_uri: https://github.com/runslikebutter/event_hook_client_server
|
136
151
|
source_code_uri: https://github.com/runslikebutter/event_hook_client_server
|
137
152
|
changelog_uri: https://github.com/runslikebutter/event_hook_client_server/blob/master/CHANGELOG.md
|
138
|
-
post_install_message:
|
153
|
+
post_install_message:
|
139
154
|
rdoc_options: []
|
140
155
|
require_paths:
|
141
156
|
- lib
|
@@ -151,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
166
|
version: '0'
|
152
167
|
requirements: []
|
153
168
|
rubygems_version: 3.1.2
|
154
|
-
signing_key:
|
169
|
+
signing_key:
|
155
170
|
specification_version: 4
|
156
171
|
summary: Client and server implementation for the Webhook Configurator service.
|
157
172
|
test_files: []
|