zk_recipes 0.2.0.pre2 → 0.2.0.pre3

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
  SHA1:
3
- metadata.gz: 0b8809248fbdaf59b179335291fb0dbd4c720a5d
4
- data.tar.gz: 94272b92ac88c8f58370d3d6e9f4a8d8ce2df2c3
3
+ metadata.gz: 2179e521a73b7b5dddd99f2a71b59d1e0e45f7ab
4
+ data.tar.gz: 57eb0dd89e3dfdaff8686685c5c817a1488bcc68
5
5
  SHA512:
6
- metadata.gz: efb4cd174c22e51ea51258de0e25a3b34b97ac9ae1e779798f38023bd326fdd314571c95e7b3bbd0caaede333d2e77018c9f8be1f4b16dd3d678d6fc50501707
7
- data.tar.gz: ada75f39f7481da1daa5fed9dcd5b9e2de7615befc8c59045e11893bb7bc690097452f5ae5b788a65ce87789a25690888764d07cfa8df6c71ed42bdf98001dfb
6
+ metadata.gz: d0b8037e3b1db1c3439a1a4fd59d8fa0c8b420251529cd4325ce24c4d8bbcce0449e7c665828260369378fb3ef3f2144a24d500e8a79196107f998d9264d5675
7
+ data.tar.gz: f03676a91ab7fec0127054bf9e6e13ee180e5869fe65687907cae72113491d4f626f33f6694609591312cceeb527cff9e4d9213ae5d785eabdcd0324c701a7c9
data/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  This version includes BREAKING CHANGES. See below
6
6
 
7
+ - BREAKING CHANGE: rename fetch_existing to fetch_valid, it checks the path
8
+ exists AND the value successfully deserialized.
7
9
  - cleanup logging
8
10
  - Make `on_connected` lighter: `on_connected` gets called for every watch when
9
11
  a connection flaps. Make the happy path `on_connected` faster.
@@ -123,9 +123,9 @@ module ZkRecipes
123
123
  end
124
124
  alias_method :[], :fetch
125
125
 
126
- def fetch_existing(path)
126
+ def fetch_valid(path)
127
127
  cached = @cache.fetch(path)
128
- cached.value if cached.stat&.exists?
128
+ cached.value if cached.valid?
129
129
  rescue KeyError
130
130
  raise PathError, "no registered path=#{path.inspect}"
131
131
  end
@@ -149,7 +149,7 @@ module ZkRecipes
149
149
 
150
150
  unless stat.exists?
151
151
  value = @registered_values.fetch(path).default_value
152
- @cache[path] = CachedPath.new(value, stat)
152
+ @cache[path] = CachedPath.new(value, stat: stat)
153
153
  debug("no node, setting watch path=#{path}")
154
154
  instrument_params[:value] = value
155
155
  ActiveSupport::Notifications.instrument(AS_NOTIFICATION, instrument_params)
@@ -162,6 +162,7 @@ module ZkRecipes
162
162
  instrument_params[:version] = stat.version
163
163
  instrument_params[:data_length] = stat.data_length
164
164
 
165
+ valid = true
165
166
  value = begin
166
167
  registered_value = @registered_values.fetch(path)
167
168
  instrument_params[:value] = registered_value.deserialize(raw_value)
@@ -169,11 +170,11 @@ module ZkRecipes
169
170
  error("deserialization error path=#{path} stat=#{stat.inspect} exception=#{e.inspect} #{e.backtrace.inspect}")
170
171
  instrument_params[:error] = e
171
172
  instrument_params[:raw_value] = raw_value
173
+ valid = false
172
174
  registered_value.default_value
173
175
  end
174
176
 
175
- # TODO if there is a deserialization error, do we want to indicate that on the CachedPath?
176
- @cache[path] = CachedPath.new(value, stat)
177
+ @cache[path] = CachedPath.new(value, stat: stat, valid: valid)
177
178
 
178
179
  ActiveSupport::Notifications.instrument(AS_NOTIFICATION, instrument_params)
179
180
  debug { "update_cache path=#{path} raw_value=#{raw_value.inspect} value=#{value.inspect} stat=#{stat.inspect}" }
@@ -203,7 +204,18 @@ module ZkRecipes
203
204
  EOM
204
205
  end
205
206
 
206
- CachedPath = Struct.new(:value, :stat)
207
+ class CachedPath
208
+ attr_reader :value, :stat
209
+ def initialize(value, stat: nil, valid: false)
210
+ @value = value
211
+ @stat = stat
212
+ @valid = valid
213
+ end
214
+
215
+ def valid?
216
+ @valid
217
+ end
218
+ end
207
219
 
208
220
  class RegisteredPath < Struct.new(:default_value, :deserializer)
209
221
  def deserialize(raw)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZkRecipes
4
- VERSION = "0.2.0.pre2"
4
+ VERSION = "0.2.0.pre3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zk_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre2
4
+ version: 0.2.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Lazarus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport