dapr-ruby 0.4.2
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +69 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/regen_client.sh +21 -0
- data/bin/setup +8 -0
- data/dapr/proto/common/v1/common.proto +160 -0
- data/dapr/proto/runtime/v1/appcallback.proto +313 -0
- data/dapr/proto/runtime/v1/dapr.proto +1044 -0
- data/dapr.gemspec +46 -0
- data/example.rb +25 -0
- data/examples/app-callback/README.md +25 -0
- data/examples/app-callback/app_callback_example.rb +15 -0
- data/examples/app-callback/app_callback_service.rb +53 -0
- data/examples/invoke-simple/README.md +17 -0
- data/examples/invoke-simple/invoke-caller.rb +19 -0
- data/examples/invoke-simple/invoke-receiver.rb +27 -0
- data/examples/pubsub-simple/README.md +13 -0
- data/examples/pubsub-simple/publisher.rb +19 -0
- data/examples/pubsub-simple/subscriber.rb +32 -0
- data/examples/state-store/README.md +7 -0
- data/examples/state-store/state-store.rb +29 -0
- data/lib/dapr/proto/common/v1/common_pb.rb +90 -0
- data/lib/dapr/proto/runtime/v1/appcallback_pb.rb +139 -0
- data/lib/dapr/proto/runtime/v1/appcallback_services_pb.rb +90 -0
- data/lib/dapr/proto/runtime/v1/dapr_pb.rb +526 -0
- data/lib/dapr/proto/runtime/v1/dapr_services_pb.rb +138 -0
- data/lib/dapr/version.rb +3 -0
- data/lib/dapr-client.rb +3 -0
- data/lib/dapr.rb +1 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c99a2a4013428ec577a3414e5a879cd6fe47ba41a746e27ba4a568318c7b2688
|
4
|
+
data.tar.gz: 014e7b29879bc9da02eff98d9aaf3e86272b5c862a67e656ca6527715f9d2d01
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dbb1a81b96bba3f0e0d3c1dba8ac08fbc40a3e36962343174481bdb223bd43f7125a95723c3681e6f0834b8cd13b2f434bd2d4e6a50c1e5e547acfbb4e3b0ed4
|
7
|
+
data.tar.gz: ef1bdbf13dac588b2f24c5b2079d99ff8c55db661f6d9bec14ff6d00fbb7fdc6c4340a5b884c556af12b3a3e96ca8be8b577e056dff6292c1ba5be5e7d3f4824
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
dapr
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.0
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# dapr-client
|
2
|
+
|
3
|
+
## v0.4.0
|
4
|
+
- Auto-generated client based on Dapr v1.1.1.
|
5
|
+
|
6
|
+
## v0.3.0
|
7
|
+
- Auto-generated client based on Dapr v1.0.0.
|
8
|
+
|
9
|
+
## v0.2.0
|
10
|
+
- Auto-generated client based on Dapr v0.8.0.
|
11
|
+
|
12
|
+
## v0.1.0 (initial release)
|
13
|
+
- Auto-generated client based on Dapr v0.6.0.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dapr-client (0.4.0)
|
5
|
+
google-protobuf
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.5.1)
|
11
|
+
google-protobuf (3.25.3)
|
12
|
+
google-protobuf (3.25.3-aarch64-linux)
|
13
|
+
google-protobuf (3.25.3-arm64-darwin)
|
14
|
+
google-protobuf (3.25.3-x86-linux)
|
15
|
+
google-protobuf (3.25.3-x86_64-darwin)
|
16
|
+
google-protobuf (3.25.3-x86_64-linux)
|
17
|
+
googleapis-common-protos-types (1.14.0)
|
18
|
+
google-protobuf (~> 3.18)
|
19
|
+
grpc (1.62.0)
|
20
|
+
google-protobuf (~> 3.25)
|
21
|
+
googleapis-common-protos-types (~> 1.0)
|
22
|
+
grpc (1.62.0-aarch64-linux)
|
23
|
+
google-protobuf (~> 3.25)
|
24
|
+
googleapis-common-protos-types (~> 1.0)
|
25
|
+
grpc (1.62.0-arm64-darwin)
|
26
|
+
google-protobuf (~> 3.25)
|
27
|
+
googleapis-common-protos-types (~> 1.0)
|
28
|
+
grpc (1.62.0-x86-linux)
|
29
|
+
google-protobuf (~> 3.25)
|
30
|
+
googleapis-common-protos-types (~> 1.0)
|
31
|
+
grpc (1.62.0-x86_64-darwin)
|
32
|
+
google-protobuf (~> 3.25)
|
33
|
+
googleapis-common-protos-types (~> 1.0)
|
34
|
+
grpc (1.62.0-x86_64-linux)
|
35
|
+
google-protobuf (~> 3.25)
|
36
|
+
googleapis-common-protos-types (~> 1.0)
|
37
|
+
grpc-tools (1.62.0)
|
38
|
+
rake (13.2.1)
|
39
|
+
rspec (3.13.0)
|
40
|
+
rspec-core (~> 3.13.0)
|
41
|
+
rspec-expectations (~> 3.13.0)
|
42
|
+
rspec-mocks (~> 3.13.0)
|
43
|
+
rspec-core (3.13.0)
|
44
|
+
rspec-support (~> 3.13.0)
|
45
|
+
rspec-expectations (3.13.0)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.13.0)
|
48
|
+
rspec-mocks (3.13.0)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.13.0)
|
51
|
+
rspec-support (3.13.1)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
aarch64-linux
|
55
|
+
arm64-darwin
|
56
|
+
ruby
|
57
|
+
x86-linux
|
58
|
+
x86_64-darwin
|
59
|
+
x86_64-linux
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
dapr-client!
|
63
|
+
grpc
|
64
|
+
grpc-tools
|
65
|
+
rake
|
66
|
+
rspec
|
67
|
+
|
68
|
+
BUNDLED WITH
|
69
|
+
2.5.9
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Tim Perkins
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Dapr SDK for Ruby
|
2
|
+
|
3
|
+
This is a Dapr SDK for Ruby, based on the auto-generated proto client.<br>
|
4
|
+
|
5
|
+
For more infomation on Dapr and gRPC see the [getting started guides](https://docs.dapr.io/getting-started/).
|
6
|
+
|
7
|
+
The repository generates the following package
|
8
|
+
- dapr-client
|
9
|
+
|
10
|
+
## Supported Versions
|
11
|
+
|
12
|
+
The auto-generated proto client and the examples is this repo are based on Dapr v1.1.1.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'dapr-client'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install dapr-client
|
29
|
+
|
30
|
+
## Example Code
|
31
|
+
|
32
|
+
A client can be created as follows:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require "dapr/proto/runtime/v1/dapr_services_pb"
|
36
|
+
|
37
|
+
client = Dapr::Proto::Runtime::V1::Dapr::Stub.new("localhost:#{ENV['DAPR_GRPC_PORT']}", :this_channel_is_insecure)
|
38
|
+
```
|
39
|
+
|
40
|
+
You can find a complete example [here](https://github.com/tjwp/dapr-ruby-sdk/blob/master/example.rb)
|
41
|
+
|
42
|
+
### Running the example code locally
|
43
|
+
|
44
|
+
You can execute this code using the local dapr runtime:
|
45
|
+
|
46
|
+
```sh
|
47
|
+
dapr run --app-id ruby-example -- bundle exec ruby example.rb
|
48
|
+
```
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
### Setup
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
55
|
+
Then, run `rake spec` to run the tests. You can also run `bin/console`
|
56
|
+
for an interactive prompt that will allow you to experiment.
|
57
|
+
|
58
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
59
|
+
To release a new version, update the version number in `version.rb`, and then
|
60
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
61
|
+
push git commits and tags, and push the `.gem` file to
|
62
|
+
[rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
### GRPC Client
|
65
|
+
|
66
|
+
Protobuf definitions are stored in the `dapr/proto` directory of this repo.
|
67
|
+
|
68
|
+
There is a script, `bin/regen_client.sh`, that can be used to regenerate the Ruby client
|
69
|
+
from the protocol definitions. The generated code can be found in `lib/dapr/proto` and is
|
70
|
+
added to the lib path.
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tjwp/dapr-ruby-sdk.
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
The gem is available as open source under the terms of the
|
79
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dapr"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/regen_client.sh
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env zsh
|
2
|
+
|
3
|
+
bindir="$(dirname "$0")"
|
4
|
+
|
5
|
+
cd "$bindir/.."
|
6
|
+
|
7
|
+
echo "Regenerating from protos ... "
|
8
|
+
set -ex
|
9
|
+
|
10
|
+
bundle exec grpc_tools_ruby_protoc -I . --ruby_out=lib --grpc_out=lib dapr/proto/common/v1/common.proto
|
11
|
+
bundle exec grpc_tools_ruby_protoc -I . --ruby_out=lib --grpc_out=lib dapr/proto/runtime/v1/dapr.proto
|
12
|
+
bundle exec grpc_tools_ruby_protoc -I . --ruby_out=lib --grpc_out=lib dapr/proto/runtime/v1/appcallback.proto
|
13
|
+
|
14
|
+
# Prefix top-level Dapr constant in dapr_services_pb
|
15
|
+
dapr_services="lib/dapr/proto/runtime/v1/dapr_services_pb.rb"
|
16
|
+
mv $dapr_services ${dapr_services}.tmp
|
17
|
+
cat ${dapr_services}.tmp | sed -e "s/ Dapr::Proto/ ::Dapr::Proto/" > $dapr_services
|
18
|
+
rm ${dapr_services}.tmp
|
19
|
+
|
20
|
+
set +x
|
21
|
+
echo "Done."
|
data/bin/setup
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2021 The Dapr Authors
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
12
|
+
*/
|
13
|
+
|
14
|
+
syntax = "proto3";
|
15
|
+
|
16
|
+
package dapr.proto.common.v1;
|
17
|
+
|
18
|
+
import "google/protobuf/any.proto";
|
19
|
+
|
20
|
+
option csharp_namespace = "Dapr.Client.Autogen.Grpc.v1";
|
21
|
+
option java_outer_classname = "CommonProtos";
|
22
|
+
option java_package = "io.dapr.v1";
|
23
|
+
option go_package = "github.com/dapr/dapr/pkg/proto/common/v1;common";
|
24
|
+
|
25
|
+
// HTTPExtension includes HTTP verb and querystring
|
26
|
+
// when Dapr runtime delivers HTTP content.
|
27
|
+
//
|
28
|
+
// For example, when callers calls http invoke api
|
29
|
+
// POST http://localhost:3500/v1.0/invoke/<app_id>/method/<method>?query1=value1&query2=value2
|
30
|
+
//
|
31
|
+
// Dapr runtime will parse POST as a verb and extract querystring to quersytring map.
|
32
|
+
message HTTPExtension {
|
33
|
+
// Type of HTTP 1.1 Methods
|
34
|
+
// RFC 7231: https://tools.ietf.org/html/rfc7231#page-24
|
35
|
+
// RFC 5789: https://datatracker.ietf.org/doc/html/rfc5789
|
36
|
+
enum Verb {
|
37
|
+
NONE = 0;
|
38
|
+
GET = 1;
|
39
|
+
HEAD = 2;
|
40
|
+
POST = 3;
|
41
|
+
PUT = 4;
|
42
|
+
DELETE = 5;
|
43
|
+
CONNECT = 6;
|
44
|
+
OPTIONS = 7;
|
45
|
+
TRACE = 8;
|
46
|
+
PATCH = 9;
|
47
|
+
}
|
48
|
+
|
49
|
+
// Required. HTTP verb.
|
50
|
+
Verb verb = 1;
|
51
|
+
|
52
|
+
// Optional. querystring represents an encoded HTTP url query string in the following format: name=value&name2=value2
|
53
|
+
string querystring = 2;
|
54
|
+
}
|
55
|
+
|
56
|
+
// InvokeRequest is the message to invoke a method with the data.
|
57
|
+
// This message is used in InvokeService of Dapr gRPC Service and OnInvoke
|
58
|
+
// of AppCallback gRPC service.
|
59
|
+
message InvokeRequest {
|
60
|
+
// Required. method is a method name which will be invoked by caller.
|
61
|
+
string method = 1;
|
62
|
+
|
63
|
+
// Required in unary RPCs. Bytes value or Protobuf message which caller sent.
|
64
|
+
// Dapr treats Any.value as bytes type if Any.type_url is unset.
|
65
|
+
google.protobuf.Any data = 2;
|
66
|
+
|
67
|
+
// The type of data content.
|
68
|
+
//
|
69
|
+
// This field is required if data delivers http request body
|
70
|
+
// Otherwise, this is optional.
|
71
|
+
string content_type = 3;
|
72
|
+
|
73
|
+
// HTTP specific fields if request conveys http-compatible request.
|
74
|
+
//
|
75
|
+
// This field is required for http-compatible request. Otherwise,
|
76
|
+
// this field is optional.
|
77
|
+
HTTPExtension http_extension = 4;
|
78
|
+
}
|
79
|
+
|
80
|
+
// InvokeResponse is the response message inclduing data and its content type
|
81
|
+
// from app callback.
|
82
|
+
// This message is used in InvokeService of Dapr gRPC Service and OnInvoke
|
83
|
+
// of AppCallback gRPC service.
|
84
|
+
message InvokeResponse {
|
85
|
+
// Required in unary RPCs. The content body of InvokeService response.
|
86
|
+
google.protobuf.Any data = 1;
|
87
|
+
|
88
|
+
// Required. The type of data content.
|
89
|
+
string content_type = 2;
|
90
|
+
}
|
91
|
+
|
92
|
+
// Chunk of data sent in a streaming request or response.
|
93
|
+
// This is used in requests including InternalInvokeRequestStream.
|
94
|
+
message StreamPayload {
|
95
|
+
// Data sent in the chunk.
|
96
|
+
// The amount of data included in each chunk is up to the discretion of the sender, and can be empty.
|
97
|
+
// Additionally, the amount of data doesn't need to be fixed and subsequent messages can send more, or less, data.
|
98
|
+
// Receivers must not make assumptions about the number of bytes they'll receive in each chunk.
|
99
|
+
bytes data = 1;
|
100
|
+
|
101
|
+
// Sequence number. This is a counter that starts from 0 and increments by 1 on each chunk sent.
|
102
|
+
uint64 seq = 2;
|
103
|
+
}
|
104
|
+
|
105
|
+
// StateItem represents state key, value, and additional options to save state.
|
106
|
+
message StateItem {
|
107
|
+
// Required. The state key
|
108
|
+
string key = 1;
|
109
|
+
|
110
|
+
// Required. The state data for key
|
111
|
+
bytes value = 2;
|
112
|
+
|
113
|
+
// The entity tag which represents the specific version of data.
|
114
|
+
// The exact ETag format is defined by the corresponding data store.
|
115
|
+
Etag etag = 3;
|
116
|
+
|
117
|
+
// The metadata which will be passed to state store component.
|
118
|
+
map<string,string> metadata = 4;
|
119
|
+
|
120
|
+
// Options for concurrency and consistency to save the state.
|
121
|
+
StateOptions options = 5;
|
122
|
+
}
|
123
|
+
|
124
|
+
// Etag represents a state item version
|
125
|
+
message Etag {
|
126
|
+
// value sets the etag value
|
127
|
+
string value = 1;
|
128
|
+
}
|
129
|
+
|
130
|
+
// StateOptions configures concurrency and consistency for state operations
|
131
|
+
message StateOptions {
|
132
|
+
// Enum describing the supported concurrency for state.
|
133
|
+
enum StateConcurrency {
|
134
|
+
CONCURRENCY_UNSPECIFIED = 0;
|
135
|
+
CONCURRENCY_FIRST_WRITE = 1;
|
136
|
+
CONCURRENCY_LAST_WRITE = 2;
|
137
|
+
}
|
138
|
+
|
139
|
+
// Enum describing the supported consistency for state.
|
140
|
+
enum StateConsistency {
|
141
|
+
CONSISTENCY_UNSPECIFIED = 0;
|
142
|
+
CONSISTENCY_EVENTUAL = 1;
|
143
|
+
CONSISTENCY_STRONG = 2;
|
144
|
+
}
|
145
|
+
|
146
|
+
StateConcurrency concurrency = 1;
|
147
|
+
StateConsistency consistency = 2;
|
148
|
+
}
|
149
|
+
|
150
|
+
// ConfigurationItem represents all the configuration with its name(key).
|
151
|
+
message ConfigurationItem {
|
152
|
+
// Required. The value of configuration item.
|
153
|
+
string value = 1;
|
154
|
+
|
155
|
+
// Version is response only and cannot be fetched. Store is not expected to keep all versions available
|
156
|
+
string version = 2;
|
157
|
+
|
158
|
+
// the metadata which will be passed to/from configuration store component.
|
159
|
+
map<string,string> metadata = 3;
|
160
|
+
}
|