dapr 0.1.16 → 0.1.18
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/Readme.adoc +22 -0
- data/lib/dapr/service/subscriber.rb +1 -1
- data/lib/dapr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 799c05f8d8605bc143ba8a423cbcf141fb3b42f157efec50171fd071064b84e9
|
4
|
+
data.tar.gz: 80d22d6b23ee2a1b035133702210d8fb9575a3cd7f56d4d6f9d80e0e9d61c3c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67dfca3d49d95550858b5dbd5c55c2dc890db598d7e1e06da3ce126cba3ec492ba18cce0f46e53b992475a22ef9557ac8eab6b48513bf8ab2bb46f4ae4e85087
|
7
|
+
data.tar.gz: 44402e4fdcbf197aeb5404254419f2caafd57e724ca648d3ad456fd85be71b2c24e25d313fa3e2fb06da8fedc53a97a5a109c01e4f4685c9f48f8d3dd456c0d3
|
data/Readme.adoc
CHANGED
@@ -47,6 +47,28 @@ publisher.publish('topic-name', { message: 'Hello, Dapr!', from: 'Ruby' })
|
|
47
47
|
<2> Create a new publisher for the `pubsub-name` pubsub component. This component must be defined in the Dapr runtime.
|
48
48
|
<3> Publish a message to the `topic-name` topic.
|
49
49
|
|
50
|
+
=== Subscribe to topics
|
51
|
+
|
52
|
+
Subscriptions in Dapr work a little different than you may be used to. Instead of subscribing to a topic
|
53
|
+
then looping through consumed messages, you define a fully-fledged service that Dapr will
|
54
|
+
send each message to in the topic(s) that you specify. This unique appreach allows you to
|
55
|
+
focus on the business logic of your service, rather than the plumbing of message consumption.
|
56
|
+
|
57
|
+
[source,ruby]
|
58
|
+
----
|
59
|
+
require 'dapr/service/subscriber'
|
60
|
+
handler = ->(event) { puts "Got event: #{event}" } <1>
|
61
|
+
pubsub_name: 'pubsub' <2>
|
62
|
+
sub = Rubyists::Dapr::Service::Subscriber.new(pubsub_name:, topics: 'TOPIC-A', handler: handler) <3>
|
63
|
+
sub.start! <4>
|
64
|
+
----
|
65
|
+
<1> Define a handler that will be called for each message received. `event` will be a `CloudEvents::Event` instance.
|
66
|
+
<2> The name of the Dapr pubsub component this subscriber will utilize.
|
67
|
+
<3> Create a new subscriber for the `pubsub` pubsub component, subscribing to the `TOPIC-A` topic.
|
68
|
+
<4> Start the subscriber. This will block the current thread and call the handler for each message received.
|
69
|
+
|
70
|
+
TIP:: Multiple topics can be subscribed to simultaneously by passing an array of topic names to the `topics` argument.
|
71
|
+
|
50
72
|
== Development
|
51
73
|
|
52
74
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -11,7 +11,7 @@ module Rubyists
|
|
11
11
|
class Subscriber
|
12
12
|
include SemanticLogger::Loggable
|
13
13
|
|
14
|
-
attr_reader(:service_proto, :runtime_proto, :pubsub_name, :topics, :
|
14
|
+
attr_reader(:service_proto, :runtime_proto, :pubsub_name, :topics, :handler)
|
15
15
|
|
16
16
|
def initialize(pubsub_name:,
|
17
17
|
topics:,
|
data/lib/dapr/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tj (bougyman) Vanderpoel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-04-
|
12
|
+
date: 2024-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dapr-ruby
|