dapr-ruby 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/dapr.gemspec ADDED
@@ -0,0 +1,46 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "dapr/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dapr-ruby"
8
+ spec.version = Dapr::VERSION
9
+ spec.authors = ["tjwp","bougyman"]
10
+ spec.email = ["tjwp@users.noreply.github.com","bougyman@users.noreply.github.com"]
11
+
12
+ spec.summary = %q{Dapr SDK for Ruby}
13
+ spec.description = %q{Dapr SDK for Ruby}
14
+ spec.homepage = "https://github.com/rubyists/dapr-ruby-sdk"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = spec.homepage
24
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
25
+ spec.metadata["github_repo"] = "ssh://github.com/rubyists/dapr-ruby-sdk"
26
+ else
27
+ raise "RubyGems 2.0 or newer is required to protect against " \
28
+ "public gem pushes."
29
+ end
30
+
31
+ # Specify which files should be added to the gem when it is released.
32
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
34
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
+ end
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ["lib"]
39
+
40
+ spec.add_runtime_dependency "google-protobuf"
41
+
42
+ spec.add_development_dependency "grpc"
43
+ spec.add_development_dependency "grpc-tools"
44
+ spec.add_development_dependency "rake"
45
+ spec.add_development_dependency "rspec"
46
+ end
data/example.rb ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dapr/proto/runtime/v1/dapr_services_pb"
4
+
5
+ port = ENV.fetch('DAPR_GRPC_PORT', '5001')
6
+ dapr_uri = "localhost:#{port}"
7
+
8
+ client = Dapr::Proto::Runtime::V1::Dapr::Stub.new(dapr_uri, :this_channel_is_insecure)
9
+ data = 'lala'
10
+ client.publish_event(Dapr::Proto::Runtime::V1::PublishEventRequest.new(pubsub_name: 'pubsub', topic: 'sith', data: 'lala'))
11
+ puts('Published')
12
+
13
+ key = 'mykey'
14
+ store_name = 'statestore'
15
+ state = Dapr::Proto::Common::V1::StateItem.new(key: key, value: 'my state')
16
+ req = Dapr::Proto::Runtime::V1::SaveStateRequest.new(store_name: store_name, states: [state])
17
+ client.save_state(req)
18
+ puts('Saved!')
19
+
20
+ resp = client.get_state(Dapr::Proto::Runtime::V1::GetStateRequest.new(store_name: store_name, key: key))
21
+ puts('Got state!')
22
+ puts(resp)
23
+
24
+ client.delete_state(Dapr::Proto::Runtime::V1::DeleteStateRequest.new(store_name: store_name, key: key))
25
+ puts('Deleted!')
@@ -0,0 +1,25 @@
1
+ # AppCallbackExample
2
+
3
+ Run the example service:
4
+
5
+ ```bash
6
+ dapr run --app-id app-callback --app-protocol grpc --app-port 50051 \
7
+ -- bundle exec ruby app_callback_example.rb
8
+ ```
9
+
10
+ Make a request to invoke a method:
11
+
12
+ ```bash
13
+ dapr invoke --app-id app-callback --method foobar --data '{"foo": "bar"}'
14
+ ```
15
+
16
+ Publish a message to a topic:
17
+
18
+ ```bash
19
+ dapr publish -i app-callback --pubsub pubsub --topic "example" --data "5"
20
+ ```
21
+
22
+ Invoke the binding:
23
+ ```ruby
24
+ dapr run --app-id invoke-binding -- bundle exec ruby invoke-binding.rb
25
+ ```
@@ -0,0 +1,15 @@
1
+ require_relative "./app_callback_service"
2
+
3
+ $stdout.sync = true
4
+
5
+ port = '0.0.0.0:50051'
6
+ s = GRPC::RpcServer.new
7
+ s.add_http2_port(port, :this_port_is_insecure)
8
+ GRPC.logger.info("... running insecurely on #{port}")
9
+ service = AppCallbackService
10
+ s.handle(service)
11
+
12
+ # Runs the server with SIGHUP, SIGINT and SIGQUIT signal handlers to
13
+ # gracefully shutdown.
14
+ # User could also choose to run server via call to run_till_terminated
15
+ s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dapr/proto/runtime/v1/appcallback_services_pb"
4
+ require "json"
5
+
6
+ class AppCallbackService < Dapr::Proto::Runtime::V1::AppCallback::Service
7
+ Any = Google::Protobuf::Any
8
+ Protocol = Dapr::Proto::Runtime::V1
9
+
10
+ def on_invoke(invoke, _call)
11
+ # Be careful! method() is a builtin method in Ruby
12
+ method = invoke['method']
13
+ raw_data = invoke.data
14
+ puts "invoked method '#{method}' with data '#{raw_data}'!"
15
+ data = JSON.parse(raw_data.value) if raw_data&.value
16
+ result = { method: method, data: data }
17
+ Dapr::Proto::Common::V1::InvokeResponse.new(data: Any.new(value: result.to_json))
18
+ rescue => ex
19
+ Dapr::Proto::Common::V1::InvokeResponse.new(data: Any.new(value: { error: ex.inspect }.to_json))
20
+ end
21
+
22
+ def list_topic_subscriptions(_empty, _call)
23
+ puts "topics requested!"
24
+ pubsub_name = "pubsub"
25
+ Protocol::ListTopicSubscriptionsResponse.
26
+ new(subscriptions: Array(Protocol::TopicSubscription.new(pubsub_name: pubsub_name, topic: "example")))
27
+ end
28
+
29
+ def list_input_bindings(_empty, _call)
30
+ puts "bindings requested!"
31
+ bindings = %w(binding)
32
+ Protocol::ListInputBindingsResponse.new(bindings: bindings)
33
+ end
34
+
35
+ def on_binding_event(binding_event, _call)
36
+ puts "binding event!"
37
+ name = binding_event.name
38
+ raw_data = binding_event.data
39
+ _metadata = binding_event.metadata
40
+ puts "Binding Event: name:#{name}, data: #{raw_data}"
41
+ Protocol::BindingEventResponse.new # data: Any.new(value:)
42
+ end
43
+
44
+ def on_topic_event(topic_event, _call)
45
+ puts "topic event!"
46
+ topic = topic_event.topic
47
+ raw_data = topic_event.data
48
+ puts "Topic Event: topic:#{topic}, data: #{raw_data}"
49
+ Google::Protobuf::Empty.new
50
+ rescue => ex
51
+ puts ex.inspect
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ # Example - Invoke
2
+
3
+ This example utilizes a receiver and a caller for the OnInvoke / Invoke
4
+ functionality. It will create a gRPC server and bind the on_invoke method,
5
+ which gets called after a client sends a direct method invocation.
6
+
7
+ ## Running
8
+
9
+ To run this example, use the following code:
10
+
11
+ ```
12
+ # 1. Start Receiver (expose gRPC receiver server on port 50051)
13
+ dapr run --app-id invoke-receiver --app-protocol grpc --app-port 50051 -- bundle exec ruby invoke-receiver.rb
14
+
15
+ # 2. Start Caller
16
+ dapr run --app-id invoke-caller -- bundle exec ruby invoke-caller.rb
17
+ ```
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dapr/proto/runtime/v1/dapr_services_pb"
4
+
5
+ $stdout.sync = true
6
+
7
+ port = ENV["DAPR_GRPC_PORT"]
8
+ stub = Dapr::Proto::Runtime::V1::Dapr::Stub.new("localhost:#{port}", :this_channel_is_insecure)
9
+ request = Dapr::Proto::Runtime::V1::InvokeServiceRequest.
10
+ new(id: "invoke-receiver",
11
+ message: Dapr::Proto::Common::V1::InvokeRequest.new(
12
+ method: "my-method",
13
+ data: Google::Protobuf::Any.new(value: "TEST MESSAGE"),
14
+ content_type: "text/plain; charset=UTF-8"
15
+ ))
16
+ response = stub.invoke_service(request)
17
+
18
+ puts response.content_type
19
+ puts response.data.value
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ $stdout.sync = true
4
+
5
+ require "dapr/proto/runtime/v1/appcallback_services_pb"
6
+
7
+ class InvokeReceiverService < Dapr::Proto::Runtime::V1::AppCallback::Service
8
+ Any = Google::Protobuf::Any
9
+
10
+ def on_invoke(invoke, _call)
11
+ content_type = "text/plain; charset=UTF-8"
12
+ puts "Invoked method '#{invoke["method"]}' with value '#{invoke["data"]["value"]}'"
13
+ data = if invoke["method"] == "my-method"
14
+ Any.new(value: "INVOKE_RECEIVED")
15
+ else
16
+ Any.new(value: "unsupported method")
17
+ end
18
+
19
+ Dapr::Proto::Common::V1::InvokeResponse.new(data: data, content_type: content_type)
20
+ end
21
+ end
22
+
23
+ server = GRPC::RpcServer.new
24
+ server.add_http2_port("0.0.0.0:50051", :this_port_is_insecure)
25
+ server.handle(InvokeReceiverService)
26
+
27
+ server.run_till_terminated_or_interrupted([1, +"int", +"SIGQUIT"])
@@ -0,0 +1,13 @@
1
+ # Example - Pub/Sub
2
+
3
+ ## Running
4
+
5
+ To run this example, use the following commands:
6
+
7
+ ```bash
8
+ # 1. Start Subscriber (expose gRPC receiver server on port 50051)
9
+ dapr run --app-id subscriber --app-protocol grpc --app-port 50051 -- bundle exec ruby subscriber.rb
10
+
11
+ # 2. Start Publisher
12
+ dapr run --app-id publisher -- bundle exec ruby publisher.rb
13
+ ```
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dapr/proto/runtime/v1/dapr_services_pb"
4
+
5
+ $stdout.sync = true
6
+
7
+ RuntimeV1 = Dapr::Proto::Runtime::V1
8
+
9
+ port = ENV["DAPR_GRPC_PORT"]
10
+ client = Dapr::Proto::Runtime::V1::Dapr::Stub.new("localhost:#{port}", :this_channel_is_insecure)
11
+
12
+ # This matches the name of the pubsub component used
13
+ pubsub_name = "pubsub"
14
+
15
+ data = "ACTION=1"
16
+ client.publish_event(RuntimeV1::PublishEventRequest.
17
+ new(pubsub_name: pubsub_name, topic: "TOPIC_A", data: data))
18
+
19
+ puts "Published #{data}"
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dapr/proto/runtime/v1/appcallback_services_pb"
4
+
5
+ $stdout.sync = true
6
+
7
+ class Subscriber < Dapr::Proto::Runtime::V1::AppCallback::Service
8
+ RuntimeV1 = Dapr::Proto::Runtime::V1
9
+
10
+
11
+ # Dapr will call this method to get the list of topics the app
12
+ # wants to subscribe to. In this example, we are telling Dapr
13
+ # To subscribe to a topic named TOPIC_A
14
+ def list_topic_subscriptions(_empty, _call)
15
+ # Name of the configured pubsub component
16
+ pubsub_name = "pubsub"
17
+
18
+ RuntimeV1::ListTopicSubscriptionsResponse.new(
19
+ subscriptions: Array(RuntimeV1::TopicSubscription.new(pubsub_name: pubsub_name, topic: "TOPIC_A")))
20
+ end
21
+
22
+ def on_topic_event(topic_event, _call)
23
+ puts "Event received #{topic_event}!"
24
+ Google::Protobuf::Empty.new
25
+ end
26
+ end
27
+
28
+ server = GRPC::RpcServer.new
29
+ server.add_http2_port("0.0.0.0:50051", :this_port_is_insecure)
30
+ server.handle(Subscriber)
31
+
32
+ server.run_till_terminated_or_interrupted([1, +"int", +"SIGQUIT"])
@@ -0,0 +1,7 @@
1
+ # Example - State Store
2
+
3
+ This example demonstrates saving, fetching, and deleting state from the store.
4
+
5
+ ```bash
6
+ dapr run --app-id state-store --app-protocol grpc -- bundle exec ruby state-store.rb
7
+ ```
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dapr/proto/runtime/v1/dapr_services_pb"
4
+
5
+ $stdout.sync = true
6
+
7
+ RuntimeV1 = Dapr::Proto::Runtime::V1
8
+
9
+ port = ENV["DAPR_GRPC_PORT"]
10
+ client = Dapr::Proto::Runtime::V1::Dapr::Stub.new("localhost:#{port}", :this_channel_is_insecure)
11
+
12
+ key = "my-key"
13
+ store_name = "statestore"
14
+
15
+ state = Dapr::Proto::Common::V1::StateItem.
16
+ new(key: key, value: "my state")
17
+
18
+ client.save_state(RuntimeV1::SaveStateRequest.
19
+ new(store_name: store_name, states: Array(state)))
20
+ puts "Saved!"
21
+
22
+ response = client.get_state(RuntimeV1::GetStateRequest.
23
+ new(store_name: store_name, key: key))
24
+ puts "Fetched!"
25
+ puts response.inspect
26
+
27
+ client.delete_state(RuntimeV1::DeleteStateRequest.
28
+ new(store_name: store_name, key: key))
29
+ puts "Deleted!"
@@ -0,0 +1,90 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: dapr/proto/common/v1/common.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/protobuf/any_pb'
7
+
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("dapr/proto/common/v1/common.proto", :syntax => :proto3) do
10
+ add_message "dapr.proto.common.v1.HTTPExtension" do
11
+ optional :verb, :enum, 1, "dapr.proto.common.v1.HTTPExtension.Verb"
12
+ optional :querystring, :string, 2
13
+ end
14
+ add_enum "dapr.proto.common.v1.HTTPExtension.Verb" do
15
+ value :NONE, 0
16
+ value :GET, 1
17
+ value :HEAD, 2
18
+ value :POST, 3
19
+ value :PUT, 4
20
+ value :DELETE, 5
21
+ value :CONNECT, 6
22
+ value :OPTIONS, 7
23
+ value :TRACE, 8
24
+ value :PATCH, 9
25
+ end
26
+ add_message "dapr.proto.common.v1.InvokeRequest" do
27
+ optional :method, :string, 1
28
+ optional :data, :message, 2, "google.protobuf.Any"
29
+ optional :content_type, :string, 3
30
+ optional :http_extension, :message, 4, "dapr.proto.common.v1.HTTPExtension"
31
+ end
32
+ add_message "dapr.proto.common.v1.InvokeResponse" do
33
+ optional :data, :message, 1, "google.protobuf.Any"
34
+ optional :content_type, :string, 2
35
+ end
36
+ add_message "dapr.proto.common.v1.StreamPayload" do
37
+ optional :data, :bytes, 1
38
+ optional :seq, :uint64, 2
39
+ end
40
+ add_message "dapr.proto.common.v1.StateItem" do
41
+ optional :key, :string, 1
42
+ optional :value, :bytes, 2
43
+ optional :etag, :message, 3, "dapr.proto.common.v1.Etag"
44
+ map :metadata, :string, :string, 4
45
+ optional :options, :message, 5, "dapr.proto.common.v1.StateOptions"
46
+ end
47
+ add_message "dapr.proto.common.v1.Etag" do
48
+ optional :value, :string, 1
49
+ end
50
+ add_message "dapr.proto.common.v1.StateOptions" do
51
+ optional :concurrency, :enum, 1, "dapr.proto.common.v1.StateOptions.StateConcurrency"
52
+ optional :consistency, :enum, 2, "dapr.proto.common.v1.StateOptions.StateConsistency"
53
+ end
54
+ add_enum "dapr.proto.common.v1.StateOptions.StateConcurrency" do
55
+ value :CONCURRENCY_UNSPECIFIED, 0
56
+ value :CONCURRENCY_FIRST_WRITE, 1
57
+ value :CONCURRENCY_LAST_WRITE, 2
58
+ end
59
+ add_enum "dapr.proto.common.v1.StateOptions.StateConsistency" do
60
+ value :CONSISTENCY_UNSPECIFIED, 0
61
+ value :CONSISTENCY_EVENTUAL, 1
62
+ value :CONSISTENCY_STRONG, 2
63
+ end
64
+ add_message "dapr.proto.common.v1.ConfigurationItem" do
65
+ optional :value, :string, 1
66
+ optional :version, :string, 2
67
+ map :metadata, :string, :string, 3
68
+ end
69
+ end
70
+ end
71
+
72
+ module Dapr
73
+ module Proto
74
+ module Common
75
+ module V1
76
+ HTTPExtension = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.HTTPExtension").msgclass
77
+ HTTPExtension::Verb = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.HTTPExtension.Verb").enummodule
78
+ InvokeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.InvokeRequest").msgclass
79
+ InvokeResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.InvokeResponse").msgclass
80
+ StreamPayload = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.StreamPayload").msgclass
81
+ StateItem = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.StateItem").msgclass
82
+ Etag = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.Etag").msgclass
83
+ StateOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.StateOptions").msgclass
84
+ StateOptions::StateConcurrency = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.StateOptions.StateConcurrency").enummodule
85
+ StateOptions::StateConsistency = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.StateOptions.StateConsistency").enummodule
86
+ ConfigurationItem = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.common.v1.ConfigurationItem").msgclass
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,139 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: dapr/proto/runtime/v1/appcallback.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/protobuf/empty_pb'
7
+ require 'dapr/proto/common/v1/common_pb'
8
+ require 'google/protobuf/struct_pb'
9
+
10
+ Google::Protobuf::DescriptorPool.generated_pool.build do
11
+ add_file("dapr/proto/runtime/v1/appcallback.proto", :syntax => :proto3) do
12
+ add_message "dapr.proto.runtime.v1.TopicEventRequest" do
13
+ optional :id, :string, 1
14
+ optional :source, :string, 2
15
+ optional :type, :string, 3
16
+ optional :spec_version, :string, 4
17
+ optional :data_content_type, :string, 5
18
+ optional :data, :bytes, 7
19
+ optional :topic, :string, 6
20
+ optional :pubsub_name, :string, 8
21
+ optional :path, :string, 9
22
+ optional :extensions, :message, 10, "google.protobuf.Struct"
23
+ end
24
+ add_message "dapr.proto.runtime.v1.TopicEventResponse" do
25
+ optional :status, :enum, 1, "dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus"
26
+ end
27
+ add_enum "dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus" do
28
+ value :SUCCESS, 0
29
+ value :RETRY, 1
30
+ value :DROP, 2
31
+ end
32
+ add_message "dapr.proto.runtime.v1.TopicEventCERequest" do
33
+ optional :id, :string, 1
34
+ optional :source, :string, 2
35
+ optional :type, :string, 3
36
+ optional :spec_version, :string, 4
37
+ optional :data_content_type, :string, 5
38
+ optional :data, :bytes, 6
39
+ optional :extensions, :message, 7, "google.protobuf.Struct"
40
+ end
41
+ add_message "dapr.proto.runtime.v1.TopicEventBulkRequestEntry" do
42
+ optional :entry_id, :string, 1
43
+ optional :content_type, :string, 4
44
+ map :metadata, :string, :string, 5
45
+ oneof :event do
46
+ optional :bytes, :bytes, 2
47
+ optional :cloud_event, :message, 3, "dapr.proto.runtime.v1.TopicEventCERequest"
48
+ end
49
+ end
50
+ add_message "dapr.proto.runtime.v1.TopicEventBulkRequest" do
51
+ optional :id, :string, 1
52
+ repeated :entries, :message, 2, "dapr.proto.runtime.v1.TopicEventBulkRequestEntry"
53
+ map :metadata, :string, :string, 3
54
+ optional :topic, :string, 4
55
+ optional :pubsub_name, :string, 5
56
+ optional :type, :string, 6
57
+ optional :path, :string, 7
58
+ end
59
+ add_message "dapr.proto.runtime.v1.TopicEventBulkResponseEntry" do
60
+ optional :entry_id, :string, 1
61
+ optional :status, :enum, 2, "dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus"
62
+ end
63
+ add_message "dapr.proto.runtime.v1.TopicEventBulkResponse" do
64
+ repeated :statuses, :message, 1, "dapr.proto.runtime.v1.TopicEventBulkResponseEntry"
65
+ end
66
+ add_message "dapr.proto.runtime.v1.BindingEventRequest" do
67
+ optional :name, :string, 1
68
+ optional :data, :bytes, 2
69
+ map :metadata, :string, :string, 3
70
+ end
71
+ add_message "dapr.proto.runtime.v1.BindingEventResponse" do
72
+ optional :store_name, :string, 1
73
+ repeated :states, :message, 2, "dapr.proto.common.v1.StateItem"
74
+ repeated :to, :string, 3
75
+ optional :data, :bytes, 4
76
+ optional :concurrency, :enum, 5, "dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency"
77
+ end
78
+ add_enum "dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency" do
79
+ value :SEQUENTIAL, 0
80
+ value :PARALLEL, 1
81
+ end
82
+ add_message "dapr.proto.runtime.v1.ListTopicSubscriptionsResponse" do
83
+ repeated :subscriptions, :message, 1, "dapr.proto.runtime.v1.TopicSubscription"
84
+ end
85
+ add_message "dapr.proto.runtime.v1.TopicSubscription" do
86
+ optional :pubsub_name, :string, 1
87
+ optional :topic, :string, 2
88
+ map :metadata, :string, :string, 3
89
+ optional :routes, :message, 5, "dapr.proto.runtime.v1.TopicRoutes"
90
+ optional :dead_letter_topic, :string, 6
91
+ optional :bulk_subscribe, :message, 7, "dapr.proto.runtime.v1.BulkSubscribeConfig"
92
+ end
93
+ add_message "dapr.proto.runtime.v1.TopicRoutes" do
94
+ repeated :rules, :message, 1, "dapr.proto.runtime.v1.TopicRule"
95
+ optional :default, :string, 2
96
+ end
97
+ add_message "dapr.proto.runtime.v1.TopicRule" do
98
+ optional :match, :string, 1
99
+ optional :path, :string, 2
100
+ end
101
+ add_message "dapr.proto.runtime.v1.BulkSubscribeConfig" do
102
+ optional :enabled, :bool, 1
103
+ optional :max_messages_count, :int32, 2
104
+ optional :max_await_duration_ms, :int32, 3
105
+ end
106
+ add_message "dapr.proto.runtime.v1.ListInputBindingsResponse" do
107
+ repeated :bindings, :string, 1
108
+ end
109
+ add_message "dapr.proto.runtime.v1.HealthCheckResponse" do
110
+ end
111
+ end
112
+ end
113
+
114
+ module Dapr
115
+ module Proto
116
+ module Runtime
117
+ module V1
118
+ TopicEventRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventRequest").msgclass
119
+ TopicEventResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventResponse").msgclass
120
+ TopicEventResponse::TopicEventResponseStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus").enummodule
121
+ TopicEventCERequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventCERequest").msgclass
122
+ TopicEventBulkRequestEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventBulkRequestEntry").msgclass
123
+ TopicEventBulkRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventBulkRequest").msgclass
124
+ TopicEventBulkResponseEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventBulkResponseEntry").msgclass
125
+ TopicEventBulkResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicEventBulkResponse").msgclass
126
+ BindingEventRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.BindingEventRequest").msgclass
127
+ BindingEventResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.BindingEventResponse").msgclass
128
+ BindingEventResponse::BindingEventConcurrency = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency").enummodule
129
+ ListTopicSubscriptionsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.ListTopicSubscriptionsResponse").msgclass
130
+ TopicSubscription = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicSubscription").msgclass
131
+ TopicRoutes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicRoutes").msgclass
132
+ TopicRule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.TopicRule").msgclass
133
+ BulkSubscribeConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.BulkSubscribeConfig").msgclass
134
+ ListInputBindingsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.ListInputBindingsResponse").msgclass
135
+ HealthCheckResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("dapr.proto.runtime.v1.HealthCheckResponse").msgclass
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,90 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: dapr/proto/runtime/v1/appcallback.proto for package 'dapr.proto.runtime.v1'
3
+ # Original file comments:
4
+ #
5
+ # Copyright 2021 The Dapr Authors
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'grpc'
18
+ require 'dapr/proto/runtime/v1/appcallback_pb'
19
+
20
+ module Dapr
21
+ module Proto
22
+ module Runtime
23
+ module V1
24
+ module AppCallback
25
+ # AppCallback V1 allows user application to interact with Dapr runtime.
26
+ # User application needs to implement AppCallback service if it needs to
27
+ # receive message from dapr runtime.
28
+ class Service
29
+
30
+ include ::GRPC::GenericService
31
+
32
+ self.marshal_class_method = :encode
33
+ self.unmarshal_class_method = :decode
34
+ self.service_name = 'dapr.proto.runtime.v1.AppCallback'
35
+
36
+ # Invokes service method with InvokeRequest.
37
+ rpc :OnInvoke, ::Dapr::Proto::Common::V1::InvokeRequest, ::Dapr::Proto::Common::V1::InvokeResponse
38
+ # Lists all topics subscribed by this app.
39
+ rpc :ListTopicSubscriptions, ::Google::Protobuf::Empty, ::Dapr::Proto::Runtime::V1::ListTopicSubscriptionsResponse
40
+ # Subscribes events from Pubsub
41
+ rpc :OnTopicEvent, ::Dapr::Proto::Runtime::V1::TopicEventRequest, ::Dapr::Proto::Runtime::V1::TopicEventResponse
42
+ # Lists all input bindings subscribed by this app.
43
+ rpc :ListInputBindings, ::Google::Protobuf::Empty, ::Dapr::Proto::Runtime::V1::ListInputBindingsResponse
44
+ # Listens events from the input bindings
45
+ #
46
+ # User application can save the states or send the events to the output
47
+ # bindings optionally by returning BindingEventResponse.
48
+ rpc :OnBindingEvent, ::Dapr::Proto::Runtime::V1::BindingEventRequest, ::Dapr::Proto::Runtime::V1::BindingEventResponse
49
+ end
50
+
51
+ Stub = Service.rpc_stub_class
52
+ end
53
+ module AppCallbackHealthCheck
54
+ # AppCallbackHealthCheck V1 is an optional extension to AppCallback V1 to implement
55
+ # the HealthCheck method.
56
+ class Service
57
+
58
+ include ::GRPC::GenericService
59
+
60
+ self.marshal_class_method = :encode
61
+ self.unmarshal_class_method = :decode
62
+ self.service_name = 'dapr.proto.runtime.v1.AppCallbackHealthCheck'
63
+
64
+ # Health check.
65
+ rpc :HealthCheck, ::Google::Protobuf::Empty, ::Dapr::Proto::Runtime::V1::HealthCheckResponse
66
+ end
67
+
68
+ Stub = Service.rpc_stub_class
69
+ end
70
+ module AppCallbackAlpha
71
+ # AppCallbackAlpha V1 is an optional extension to AppCallback V1 to opt
72
+ # for Alpha RPCs.
73
+ class Service
74
+
75
+ include ::GRPC::GenericService
76
+
77
+ self.marshal_class_method = :encode
78
+ self.unmarshal_class_method = :decode
79
+ self.service_name = 'dapr.proto.runtime.v1.AppCallbackAlpha'
80
+
81
+ # Subscribes bulk events from Pubsub
82
+ rpc :OnBulkTopicEventAlpha1, ::Dapr::Proto::Runtime::V1::TopicEventBulkRequest, ::Dapr::Proto::Runtime::V1::TopicEventBulkResponse
83
+ end
84
+
85
+ Stub = Service.rpc_stub_class
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end