dapr 0.1.11 → 0.1.12
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 +4 -4
- data/lib/dapr/service/subscriber.rb +30 -12
- data/lib/dapr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4332d8def6773de1fb03bbf6a835a1d402d9a1aec4d1ccdfe852ca52b1e5598c
|
4
|
+
data.tar.gz: a79b3edc9e3db9619c95016c5a01f757b806239e57bd96d26510964f99ad4410
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d300d786cb4918d1ba37e833bdfbd4232b8019564121d1f0b2984b5d7109ba78d503874840aa20dfe67ad3ad90ea70b4101f2c48be7e517494564bd82a7e485
|
7
|
+
data.tar.gz: aed9109b6fe5c6663bd13cf3200b3f586e99e885ea7c8c6c9a042bb8f62b9f450e7ea3d0339bdd8a6168e8e0cf771d01558c40cf34703907a17993f7d3878584
|
@@ -13,13 +13,11 @@ module Rubyists
|
|
13
13
|
|
14
14
|
attr_reader(:service_proto, :runtime_proto, :pubsub_name, :topics, :event_handler)
|
15
15
|
|
16
|
-
Port = ENV.fetch('DAPR_GRPC_APP_PORT', 50_051)
|
17
|
-
|
18
16
|
def initialize(pubsub_name:,
|
19
17
|
topics:,
|
20
18
|
handler: nil,
|
21
|
-
service_proto: Dapr::Proto::Runtime::V1::AppCallback::Service,
|
22
|
-
runtime_proto: Dapr::Proto::Runtime::V1)
|
19
|
+
service_proto: ::Dapr::Proto::Runtime::V1::AppCallback::Service,
|
20
|
+
runtime_proto: ::Dapr::Proto::Runtime::V1)
|
23
21
|
@topics = Array(topics)
|
24
22
|
@pubsub_name = pubsub_name
|
25
23
|
@service_proto = service_proto
|
@@ -27,6 +25,32 @@ module Rubyists
|
|
27
25
|
@handler = handler
|
28
26
|
end
|
29
27
|
|
28
|
+
# Start the subscriber service. This method will block until the service is terminated.
|
29
|
+
# The service will listen on the specified port and address.
|
30
|
+
#
|
31
|
+
# @note if grpc_port is not provided, the service will listen on the port returned by the #port method.
|
32
|
+
# @note the service will listen on all interfaces by default.
|
33
|
+
#
|
34
|
+
# @param [Integer] grpc_port the port to listen on
|
35
|
+
# @param [String] listen_address the address to listen on
|
36
|
+
#
|
37
|
+
# @return [Subscriber] the subscriber instance
|
38
|
+
def start!(grpc_port: nil, listen_address: '0.0.0.0')
|
39
|
+
server = GRPC::RpcServer.new
|
40
|
+
grpc_port ||= port
|
41
|
+
server.add_http2_port("#{listen_address}:#{grpc_port}", :this_port_is_insecure)
|
42
|
+
server.handle(service)
|
43
|
+
log.warn('Starting Dapr Subscriber service', grpc_port:)
|
44
|
+
server.run_till_terminated_or_interrupted([1, +'int', +'SIGQUIT'])
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def port
|
51
|
+
@port ||= ENV.fetch('DAPR_GRPC_APP_PORT', 50_051)
|
52
|
+
end
|
53
|
+
|
30
54
|
def handle_event!(topic_event, topic_call)
|
31
55
|
return handler&.call(topic_event, topic_call) if handler.respond_to?(:call)
|
32
56
|
|
@@ -36,12 +60,14 @@ module Rubyists
|
|
36
60
|
handler:)
|
37
61
|
end
|
38
62
|
|
63
|
+
# @return [Array] The list of subscriptions for the Subscriber
|
39
64
|
def subscriptions
|
40
65
|
@subscriptions ||= topics.map do |topic|
|
41
66
|
runtime_proto::TopicSubscription.new(pubsub_name:, topic:)
|
42
67
|
end
|
43
68
|
end
|
44
69
|
|
70
|
+
# @return [Class] the service class to use for the Subscriber
|
45
71
|
def service # rubocop:disable Metrics/MethodLength
|
46
72
|
return @service if @service
|
47
73
|
|
@@ -56,14 +82,6 @@ module Rubyists
|
|
56
82
|
end
|
57
83
|
end
|
58
84
|
end
|
59
|
-
|
60
|
-
def start!
|
61
|
-
server = GRPC::RpcServer.new
|
62
|
-
server.add_http2_port("0.0.0.0:#{Port}", :this_port_is_insecure)
|
63
|
-
server.handle(service)
|
64
|
-
log.warn('Starting Dapr Subscriber service', port: Port)
|
65
|
-
server.run_till_terminated_or_interrupted([1, +'int', +'SIGQUIT'])
|
66
|
-
end
|
67
85
|
end
|
68
86
|
end
|
69
87
|
end
|
data/lib/dapr/version.rb
CHANGED