volcano-sdk 0.9.3 → 0.9.4
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 +4 -4
- data/lib/volcano/function_resolution.rb +13 -4
- data/lib/volcano/functions.rb +4 -2
- data/lib/volcano/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4fdce577eb0f97e2359db37774f29986e40c24d7d8b4bf64b67ccca4c96ea85
|
|
4
|
+
data.tar.gz: 5bb422eb1a068e899aa6de617f2bfc4bf78128698009f384c37254c753ae3ea1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0cd140b083357a515a32e3f0dccbc5280519cbaa6f08f1881f745675b979193dd6bd1ddb9e6b415ac55cdabbdcfda44a1b157e97bc2c9f0f1370292ff377922
|
|
7
|
+
data.tar.gz: 711a49849712a130ac0da5256bef2297428fd3fa2e69e91853842be89752b0e2406e66dc88c88fea78dea29bdfdfd6146701b4aa6a564638a24dad8c42904aab
|
|
@@ -14,7 +14,14 @@ module Volcano
|
|
|
14
14
|
Resolution = Data.define(:function_id, :invoke_url)
|
|
15
15
|
|
|
16
16
|
# A cached resolve result. A nil resolution is a remembered miss.
|
|
17
|
-
Outcome = Data.define(:resolution)
|
|
17
|
+
Outcome = Data.define(:resolution, :failure)
|
|
18
|
+
|
|
19
|
+
Failure = Data.define(:message, :code, :retry_after) do
|
|
20
|
+
def exception
|
|
21
|
+
Error::NotFoundError.new(message.dup, status: 404, code: code&.dup, retry_after: retry_after)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
private_constant :Failure
|
|
18
25
|
|
|
19
26
|
Entry = Data.define(:outcome, :expires_at)
|
|
20
27
|
private_constant :Entry
|
|
@@ -72,13 +79,15 @@ module Volcano
|
|
|
72
79
|
|
|
73
80
|
# Caches a resolution for the server-advertised lifetime.
|
|
74
81
|
def store(api_url, authorization, name, resolution, ttl_seconds)
|
|
75
|
-
write([api_url, authorization, name], Outcome.new(resolution: resolution), ttl_seconds)
|
|
82
|
+
write([api_url, authorization, name], Outcome.new(resolution: resolution, failure: nil), ttl_seconds)
|
|
76
83
|
end
|
|
77
84
|
|
|
78
85
|
# Remembers briefly that a name does not resolve, so a caller retrying an
|
|
79
86
|
# unknown name in a loop does not re-ask the server on every attempt.
|
|
80
|
-
def store_missing(api_url, authorization, name)
|
|
81
|
-
|
|
87
|
+
def store_missing(api_url, authorization, name, error)
|
|
88
|
+
failure = Failure.new(message: error.message.dup.freeze, code: error.code&.dup&.freeze,
|
|
89
|
+
retry_after: error.retry_after)
|
|
90
|
+
write([api_url, authorization, name], Outcome.new(resolution: nil, failure: failure), NEGATIVE_TTL_SECONDS)
|
|
82
91
|
end
|
|
83
92
|
|
|
84
93
|
# Drops one cached resolution that turned out to be stale.
|
data/lib/volcano/functions.rb
CHANGED
|
@@ -88,15 +88,17 @@ module Volcano
|
|
|
88
88
|
resolved = Transport.invoke do
|
|
89
89
|
@transport.resolve_function_for_invocation(authorization: authorization, name: name)
|
|
90
90
|
end
|
|
91
|
-
FunctionResolution.store_missing(@api_url, authorization, name) if resolved.status == 404
|
|
92
91
|
payload = Transport.body(resolved, 200)
|
|
93
92
|
resolution = resolved_resolution(payload)
|
|
94
93
|
FunctionResolution.store(@api_url, authorization, name, resolution, cache_ttl(payload))
|
|
95
94
|
resolution
|
|
95
|
+
rescue Error::NotFoundError => e
|
|
96
|
+
FunctionResolution.store_missing(@api_url, authorization, name, e)
|
|
97
|
+
raise
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
def cached_resolution(cached)
|
|
99
|
-
cached.resolution || raise(
|
|
101
|
+
cached.resolution || raise(cached.failure.exception)
|
|
100
102
|
end
|
|
101
103
|
|
|
102
104
|
def validate_invocation(name, payload)
|
data/lib/volcano/version.rb
CHANGED