dapr 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5be2c698d6a8d00b8b21f5238aa7942a1cacf38a4aea6a5c3a0584d93b472a9
4
- data.tar.gz: 64d6da53862a61af5aaca44895040e18564c29a652736abfec4211ec2c87f3ed
3
+ metadata.gz: 4332d8def6773de1fb03bbf6a835a1d402d9a1aec4d1ccdfe852ca52b1e5598c
4
+ data.tar.gz: a79b3edc9e3db9619c95016c5a01f757b806239e57bd96d26510964f99ad4410
5
5
  SHA512:
6
- metadata.gz: b5e3feb9da80ab6d26593634ad56b3a6f5b1d82b19d987a697e26951e2e8a218a85ef29889dd5638d05b73f7c028192727a1b405257665f124464ddd137dd520
7
- data.tar.gz: ee01d6c05817cfc6737b6371e5a9bd6785831372094d8f369b2b9a5168d286ec3bf6d09264318944d67bf139c7f853d669acff92af4d22da1db14b8454934c78
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubyists
4
4
  module Dapr
5
- VERSION = '0.1.11'
5
+ VERSION = '0.1.12'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tj (bougyman) Vanderpoel