dapr 0.3.3 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 333d5818807b0f936fb7ece35380b3ab2ba83875dd0e39efa28ca0b369c92a25
4
- data.tar.gz: 859ba4dcadb9f7b98c50b8d91226949e1e429466c1c779305bf7a505f968274b
3
+ metadata.gz: 5cef0f3267e0f07b9ccedcfb29297c49cd9c5cbc5d16e556c72c82821c1ff4c8
4
+ data.tar.gz: 23d4d7a6e7b0aa1e9482c08eae87290deb7b23508820c88bcb31f1e34432dad9
5
5
  SHA512:
6
- metadata.gz: b852cc847ff3645c78f48411ff57a39431fed239bd4760e10275411d650516f8dc509a6e7874726d35d9dfd0de9f730650811de0c74acf272604664021c885e9
7
- data.tar.gz: f787940e3cdeecb504c861f9927fd60b8377045cc8edadef080f040c56bfcc09ae0f0662b303ae18ac375f3180d7fd8c270cde32c252aa313c3e0270f26fb22f
6
+ metadata.gz: d6f5d917f97ad175316c3552f48b02e3600e585f9cc13dd38ec7f511f84004c6596edc9891e0e2d4ad84797be87b6d5a587093b79c81b83b1054bf7404aac96c
7
+ data.tar.gz: 6516a0a52f7538992c413d0fdf8e888124d5840e3f149bdd9247a191763256fdd4a4912037acadccd4bfd87d3b736de163af77f917fee3e5cedb2c1d81a5889e
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.3.3"
2
+ ".": "0.4.0"
3
3
  }
data/.version.txt CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0](https://github.com/rubyists/dapr-ruby-client/compare/v0.3.3...v0.4.0) (2024-10-23)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **state:** Adds state management component ([#74](https://github.com/rubyists/dapr-ruby-client/issues/74))
9
+
10
+ ### Features
11
+
12
+ * **state:** Adds state management component ([#74](https://github.com/rubyists/dapr-ruby-client/issues/74)) ([2fc596d](https://github.com/rubyists/dapr-ruby-client/commit/2fc596dad1439c5d52a03bdf763d8b0d38aa9bab))
13
+
3
14
  ## [0.3.3](https://github.com/rubyists/dapr-ruby-client/compare/v0.3.2...v0.3.3) (2024-10-08)
4
15
 
5
16
 
@@ -1 +1 @@
1
- {"timestamp":1728408645,"command_name":"Unit Tests","files":[{"filename":"/home/bougyman/rubyists/dapr/lib/dapr.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,null,1,1,5,null,null,null,1,1,1,1,1,null,null]},"covered_strength":1.4,"covered_lines":10,"lines_of_code":10},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,1,null,1,1,null,1,1,1,1,1,null,1,4,null,1,1,null,null,1,9,null,null,1,1,null,null,1,12,null,null,null,1,1,null,1,5,null,null,1,1,1,1,null,1,null,null,1,1,null,null,null,null,null]},"covered_strength":1.7878787878787878,"covered_lines":33,"lines_of_code":33},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client/configuration.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,null,1,1,1,null,1,null,1,1,null,null,1,null,null,1,null,1,1,null,1,1,1,null,null,null,null,null,null,null,1,1,1,1,null,null,1,1,1,null,null,null,null,null]},"covered_strength":1.0,"covered_lines":21,"lines_of_code":21},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client/lock.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,1,1,1,null,1,null,1,1,null,null,1,null,null,1,null,1,1,null,null,null,null,null,null,1,6,6,null,null,null,null,null,null,1,6,6,null,null,null,1,6,6,5,5,null,null,1,null,null,null,1,4,4,4,null,3,3,null,null,1,null,null,1,18,null,null,null,null,null,1,6,null,null,null,null,null]},"covered_strength":3.085714285714286,"covered_lines":35,"lines_of_code":35},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/version.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,1,null,null,null]},"covered_strength":1.0,"covered_lines":3,"lines_of_code":3}],"metrics":{"covered_percent":100.0,"covered_strength":2.0098039215686274,"covered_lines":102,"total_lines":102}}
1
+ {"timestamp":1729718516,"command_name":"Unit Tests","files":[{"filename":"/home/bougyman/rubyists/dapr/lib/dapr.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,null,1,1,7,null,null,null,1,1,1,1,1,null,null]},"covered_strength":1.6,"covered_lines":10,"lines_of_code":10},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,1,null,1,1,null,1,1,1,1,1,1,null,1,4,null,1,1,null,null,1,11,null,null,1,1,null,null,1,14,null,null,null,1,1,null,1,5,null,null,1,1,1,1,null,1,null,null,1,1,null,null,null,null,null]},"covered_strength":1.8823529411764706,"covered_lines":34,"lines_of_code":34},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client/configuration.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,null,1,1,1,null,1,null,1,1,null,null,1,null,null,1,null,1,1,null,1,1,1,null,null,null,null,null,null,null,1,1,1,1,null,null,1,1,1,null,null,null,null,null]},"covered_strength":1.0,"covered_lines":21,"lines_of_code":21},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client/lock.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,1,1,1,null,1,null,1,1,null,null,1,null,null,1,null,1,1,null,null,null,null,null,null,1,6,6,null,null,null,null,null,null,1,6,6,null,null,null,1,6,6,5,5,null,null,1,null,null,null,1,4,4,4,null,3,3,null,null,1,null,null,1,18,null,null,null,null,null,1,6,null,null,null,null,null]},"covered_strength":3.085714285714286,"covered_lines":35,"lines_of_code":35},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/client/state.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,null,1,1,1,null,null,1,null,1,1,null,1,null,1,1,1,1,1,1,null,null,null,null,null,null,1,1,null,null,null,null,null,null,null,1,1,null,null,null,null,null,1,2,null,null,null,null,null,null,1,1,1,1,null,null,null,null,1,3,1,1,1,null,null,null,null,null]},"covered_strength":1.103448275862069,"covered_lines":29,"lines_of_code":29},{"filename":"/home/bougyman/rubyists/dapr/lib/dapr/version.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,1,null,null,null]},"covered_strength":1.0,"covered_lines":3,"lines_of_code":3}],"metrics":{"covered_percent":100.0,"covered_strength":1.8484848484848484,"covered_lines":132,"total_lines":132}}
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../client'
4
+
5
+ module Rubyists
6
+ module Dapr
7
+ module Client
8
+ # The State class is a client for the Dapr State Management Building block
9
+ # Info here: https://docs.dapr.io/developing-applications/building-blocks/state-management/
10
+ class State
11
+ # Include the client module
12
+ include Client
13
+ include SemanticLogger::Loggable
14
+
15
+ attr_reader :store_name
16
+
17
+ Empty = Google::Protobuf::Empty
18
+ Runtime = Client::Runtime
19
+ GetBulkStateResponse = Runtime::GetBulkStateResponse
20
+ GetStateRequest = Runtime::GetBulkStateRequest
21
+ SaveStateRequest = Runtime::SaveStateRequest
22
+ DEFAULT_STORE_NAME = 'statestore'
23
+
24
+ # @param keys [Array<String>] keys to retrieve from the state store
25
+ # @param store_name [String] name of the State Management component, defaults to 'dapr-statestore'
26
+ # @param metadata [Hash] metadata to include
27
+ #
28
+ # @return [GetBulkStateResponse] The response from the Dapr State Management component
29
+ def self.get(*keys, store_name: DEFAULT_STORE_NAME, metadata: {})
30
+ new(store_name).get(keys, metadata:)
31
+ end
32
+
33
+ # @param states [Hash] states to set in the state store, key/value pairs
34
+ # @param store_name [String] name of the State Management component, defaults to 'dapr-statestore'
35
+ # @param metadata [Hash] metadata to include
36
+ #
37
+ # @return [Empty] The response from the Dapr State Management component
38
+ def self.set(states, store_name: DEFAULT_STORE_NAME, metadata: {})
39
+ new(store_name).set(states, metadata:)
40
+ end
41
+
42
+ # Initialize the State Management client
43
+ #
44
+ # @param store_name [String] name of the Dapr Configuration component to use
45
+ def initialize(store_name)
46
+ @store_name = store_name
47
+ end
48
+
49
+ # @param keys [Array<String>] keys to retrieve from the state store
50
+ # @param metadata [Hash] metadata to include
51
+ #
52
+ # @return [Array<BulkStateItem>] Array of items returned by the state store
53
+ def get(keys, metadata: {})
54
+ logger.debug('Getting state', keys:, store_name:, metadata:)
55
+ response = singleton.get_bulk_state GetStateRequest.new(store_name:, keys:, metadata:)
56
+ response.items
57
+ end
58
+
59
+ # @param states [Hash] states to set (key/values in the state store)
60
+ # @param metadata [Hash] metadata to include
61
+ def set(states, metadata: {})
62
+ states = states.map { |key, value| { key:, value:, metadata: } }
63
+ request = SaveStateRequest.new(store_name:, states:)
64
+ logger.debug('Setting state', states:, store_name:)
65
+ singleton.save_state request
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
data/lib/dapr/client.rb CHANGED
@@ -11,9 +11,10 @@ module Rubyists
11
11
  # The namespace for the Dapr client
12
12
  module Client
13
13
  include SemanticLogger::Loggable
14
+ Runtime = ::Dapr::Proto::Runtime::V1
14
15
  DAPR_PORT = ENV.fetch('DAPR_GRPC_PORT', nil)
15
16
  DAPR_URI = ENV.fetch('DAPR_GRPC_HOST', 'localhost')
16
- DAPR_STUB = ::Dapr::Proto::Runtime::V1::Dapr::Stub
17
+ DAPR_STUB = Runtime::Dapr::Stub
17
18
 
18
19
  def self.client(dapr_port: DAPR_PORT, dapr_uri: DAPR_URI)
19
20
  return DummyClient.new if dapr_port.nil?
data/lib/dapr/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Rubyists
4
4
  module Dapr
5
5
  # x-release-please-start-version
6
- VERSION = '0.3.3'
6
+ VERSION = '0.4.0'
7
7
  # x-release-please-end
8
8
  end
9
9
  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.3.3
4
+ version: 0.4.0
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-10-08 00:00:00.000000000 Z
12
+ date: 2024-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dapr-ruby
@@ -63,6 +63,7 @@ files:
63
63
  - lib/dapr/client/configuration.rb
64
64
  - lib/dapr/client/lock.rb
65
65
  - lib/dapr/client/publisher.rb
66
+ - lib/dapr/client/state.rb
66
67
  - lib/dapr/service.rb
67
68
  - lib/dapr/service/subscriber.rb
68
69
  - lib/dapr/version.rb