google-cloud-env 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ac62dcc3131def7be6bf69813f79c3d23b6d6ce5199d0250ffad596cf3b7fcb
4
- data.tar.gz: d9eadf5f767d8225022ed9551ea3a5a2ee37e8ad5b68da9eea7c94f416333f4f
3
+ metadata.gz: 86778304c7001d745acd20f90528b22a5e03c2c048f522cedd8e99ab1f50bf24
4
+ data.tar.gz: '05291246aa4fb33c473f2fa9bceefdc921460b4424174ef357707e07c2c832bc'
5
5
  SHA512:
6
- metadata.gz: def8ccefb5d889744cb562a85cc78a9d3b718f80f2d48eab409c6fcdbcbe2dfe9adae14393f06aab3b6a6db83b6fc6d631902d11c1a932e2a77ee2f93a5ca82f
7
- data.tar.gz: 5faabdeb543a4237dd19a69a9963237e4b843f93aeeaa1f002cc08bd0269ba005da6a89baee20989076330b97de9551a41a50e658febd173847166fc29013bcb
6
+ metadata.gz: 3900d323cdddef329f2edc4b17f7098dda5edac5378bfb11fc1311b23dc0680eb83d8f18bef86ad95baeb46315c7466551e7a0c5badf31924d3f6862ff05b1f5
7
+ data.tar.gz: 5ba1b0660ab4ee0e04f34cec0cee72ef3fda2fe7aa52e14dfb159db4c0a89d9cc38cf215d2606b900c1f0c25f9fc77d942b377ab678179859ac23be23dadfc5e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 2.1.0 (2023-12-12)
4
+
5
+ #### Features
6
+
7
+ * Provide retrieval_monotonic_time on compute metadata response objects ([#62](https://github.com/googleapis/ruby-cloud-env/issues/62))
8
+
3
9
  ### 2.0.1 (2023-12-01)
4
10
 
5
11
  #### Bug Fixes
@@ -89,7 +89,8 @@ module Google
89
89
  # {ComputeMetadata#lookup_response}.
90
90
  #
91
91
  # This object duck-types the `status`, `body`, and `headers` fields of
92
- # `Faraday::Response`.
92
+ # `Faraday::Response`. It also includes the CLOCK_MONOTONIC time when
93
+ # the data was retrieved.
93
94
  #
94
95
  class Response
95
96
  ##
@@ -105,6 +106,7 @@ module Google
105
106
  @status = status
106
107
  @body = body
107
108
  @headers = headers
109
+ @retrieval_monotonic_time = Process.clock_gettime Process::CLOCK_MONOTONIC
108
110
  end
109
111
 
110
112
  ##
@@ -125,6 +127,11 @@ module Google
125
127
  #
126
128
  attr_reader :headers
127
129
 
130
+ # The CLOCK_MONOTONIC time at which this response was retrieved.
131
+ # @return [Numeric]
132
+ #
133
+ attr_reader :retrieval_monotonic_time
134
+
128
135
  ##
129
136
  # Returns true if the metadata-flavor is correct for Google Cloud
130
137
  # @return [boolean]
@@ -752,9 +759,9 @@ module Google
752
759
  end
753
760
  response = Response.new http_response.status, http_response.body, http_response.headers
754
761
  if path.nil?
755
- post_update_existence(response.status == 200 && response.google_flavor?)
762
+ post_update_existence(response.status == 200 && response.google_flavor?, response.retrieval_monotonic_time)
756
763
  elsif response.google_flavor?
757
- post_update_existence true
764
+ post_update_existence true, response.retrieval_monotonic_time
758
765
  end
759
766
  lifetime = determine_data_lifetime path, response.body.strip
760
767
  LazyValue.expiring_value lifetime, response
@@ -767,14 +774,14 @@ module Google
767
774
  # @private
768
775
  # Update existence based on a received result
769
776
  #
770
- def post_update_existence success
777
+ def post_update_existence success, current_time = nil
771
778
  return if @existence == :confirmed
772
779
  @mutex.synchronize do
773
780
  if success
774
781
  @existence = :confirmed
775
- elsif @existence != :confirmed &&
776
- Process.clock_gettime(Process::CLOCK_MONOTONIC) > @startup_time + warmup_time
777
- @existence = :no
782
+ elsif @existence != :confirmed
783
+ current_time ||= Process.clock_gettime Process::CLOCK_MONOTONIC
784
+ @existence = :no if current_time > @startup_time + warmup_time
778
785
  end
779
786
  end
780
787
  end
@@ -20,7 +20,7 @@ module Google
20
20
  # Library version
21
21
  # @return [String]
22
22
  #
23
- VERSION = "2.0.1".freeze
23
+ VERSION = "2.1.0".freeze
24
24
  end
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
11
+ date: 2023-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -59,10 +59,10 @@ homepage: https://github.com/googleapis/ruby-cloud-env
59
59
  licenses:
60
60
  - Apache-2.0
61
61
  metadata:
62
- changelog_uri: https://rubydoc.info/gems/google-cloud-env/2.0.1/CHANGELOG.md
62
+ changelog_uri: https://rubydoc.info/gems/google-cloud-env/2.1.0/CHANGELOG.md
63
63
  source_code_uri: https://github.com/googleapis/ruby-cloud-env
64
64
  bug_tracker_uri: https://github.com/googleapis/ruby-cloud-env/issues
65
- documentation_uri: https://rubydoc.info/gems/google-cloud-env/2.0.1
65
+ documentation_uri: https://rubydoc.info/gems/google-cloud-env/2.1.0
66
66
  post_install_message:
67
67
  rdoc_options: []
68
68
  require_paths: