@voxgig/sdkgen 4.51.0 → 4.52.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.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/ReadmeExplanation.js +5 -2
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeFeatures.js +20 -6
- package/dist/cmp/ReadmeFeatures.js.map +1 -1
- package/dist/helpers/optspec.js +2 -2
- package/dist/helpers/optspec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/sdkgen.aontu +1 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/audit.aontu +1 -1
- package/project/.sdk/model/feature/cache.aontu +1 -1
- package/project/.sdk/model/feature/clienttrack.aontu +1 -1
- package/project/.sdk/model/feature/cost.aontu +1 -1
- package/project/.sdk/model/feature/debug.aontu +1 -1
- package/project/.sdk/model/feature/idempotency.aontu +1 -1
- package/project/.sdk/model/feature/log.aontu +1 -1
- package/project/.sdk/model/feature/metrics.aontu +3 -1
- package/project/.sdk/model/feature/netsim.aontu +1 -1
- package/project/.sdk/model/feature/paging.aontu +4 -1
- package/project/.sdk/model/feature/proxy.aontu +1 -1
- package/project/.sdk/model/feature/ratelimit.aontu +3 -3
- package/project/.sdk/model/feature/rbac.aontu +1 -1
- package/project/.sdk/model/feature/retry.aontu +1 -1
- package/project/.sdk/model/feature/secrets.aontu +1 -1
- package/project/.sdk/model/feature/streaming.aontu +1 -1
- package/project/.sdk/model/feature/telemetry.aontu +2 -2
- package/project/.sdk/model/feature/test.aontu +1 -1
- package/project/.sdk/model/feature/timeout.aontu +1 -1
- package/project/.sdk/model/feature/validate.aontu +1 -1
- package/project/.sdk/src/cmp/c/TestClean_c.ts +12 -11
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +17 -10
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +18 -1
- package/project/.sdk/src/cmp/cpp/TestClean_cpp.ts +2 -1
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +30 -2
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +31 -12
- package/project/.sdk/src/cmp/elixir/TestClean_elixir.ts +2 -1
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +51 -15
- package/project/.sdk/src/cmp/elixir/fragment/Pipeline.fragment.ex +17 -0
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +42 -2
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +42 -14
- package/project/.sdk/src/cmp/java/TestClean_java.ts +9 -4
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +21 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +13 -8
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +26 -2
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityPatchOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +8 -0
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +12 -5
- package/project/.sdk/src/cmp/kotlin/TestClean_kotlin.ts +9 -4
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +19 -0
- package/project/.sdk/src/cmp/lua/TestClean_lua.ts +2 -1
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +42 -5
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +44 -10
- package/project/.sdk/src/cmp/lua/utility_lua.ts +2 -1
- package/project/.sdk/src/cmp/ocaml/TestClean_ocaml.ts +2 -1
- package/project/.sdk/src/cmp/ocaml/fragment/RunOp.fragment.ml +36 -21
- package/project/.sdk/src/cmp/perl/TestClean_perl.ts +1 -1
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +21 -0
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +31 -12
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +33 -4
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +13 -6
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +25 -2
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +26 -12
- package/project/.sdk/src/cmp/rb/TestClean_rb.ts +1 -1
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +23 -2
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +27 -11
- package/project/.sdk/src/cmp/rust/TestClean_rust.ts +14 -17
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +22 -2
- package/project/.sdk/src/cmp/scala/TestClean_scala.ts +11 -11
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +14 -0
- package/project/.sdk/src/cmp/swift/TestClean_swift.ts +11 -11
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +9 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +24 -10
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +13 -8
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +26 -2
- package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityPatchOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +8 -0
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +12 -5
- package/project/.sdk/src/cmp/zig/TestClean_zig.ts +11 -11
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +17 -10
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +41 -6
- package/project/.sdk/tm/c/feature/metrics.c +7 -0
- package/project/.sdk/tm/c/feature/paging.c +231 -2
- package/project/.sdk/tm/c/feature/ratelimit.c +5 -9
- package/project/.sdk/tm/c/feature/retry.c +51 -4
- package/project/.sdk/tm/c/feature/streaming.c +2 -1
- package/project/.sdk/tm/c/feature/telemetry.c +19 -18
- package/project/.sdk/tm/c/feature/test.c +78 -54
- package/project/.sdk/tm/c/tests/feature_test.c +184 -0
- package/project/.sdk/tm/c/tests/primary_utility_test.c +2 -0
- package/project/.sdk/tm/c/utility/make_options.c +80 -9
- package/project/.sdk/tm/clojure/src/sdk/core.clj +31 -11
- package/project/.sdk/tm/clojure/src/sdk/features.clj +198 -70
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +70 -1
- package/project/.sdk/tm/cpp/core/types.hpp +137 -68
- package/project/.sdk/tm/cpp/feature/audit.hpp +6 -1
- package/project/.sdk/tm/cpp/feature/metrics.hpp +19 -0
- package/project/.sdk/tm/cpp/feature/paging.hpp +160 -2
- package/project/.sdk/tm/cpp/feature/ratelimit.hpp +18 -14
- package/project/.sdk/tm/cpp/feature/retry.hpp +46 -5
- package/project/.sdk/tm/cpp/feature/streaming.hpp +2 -1
- package/project/.sdk/tm/cpp/feature/telemetry.hpp +17 -10
- package/project/.sdk/tm/cpp/feature/test.hpp +63 -53
- package/project/.sdk/tm/cpp/test/feature_test.cpp +137 -0
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +35 -5
- package/project/.sdk/tm/csharp/feature/AuditFeature.cs +8 -1
- package/project/.sdk/tm/csharp/feature/MetricsFeature.cs +23 -0
- package/project/.sdk/tm/csharp/feature/PagingFeature.cs +130 -3
- package/project/.sdk/tm/csharp/feature/RatelimitFeature.cs +26 -19
- package/project/.sdk/tm/csharp/feature/RetryFeature.cs +41 -7
- package/project/.sdk/tm/csharp/feature/StreamingFeature.cs +2 -1
- package/project/.sdk/tm/csharp/feature/TelemetryFeature.cs +11 -9
- package/project/.sdk/tm/csharp/feature/TestFeature.cs +55 -67
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +162 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +89 -12
- package/project/.sdk/tm/elixir/lib/projectname/feature/metrics.ex +13 -0
- package/project/.sdk/tm/elixir/lib/projectname/feature/paging.ex +110 -5
- package/project/.sdk/tm/elixir/lib/projectname/feature/ratelimit.ex +6 -12
- package/project/.sdk/tm/elixir/lib/projectname/feature/retry.ex +33 -9
- package/project/.sdk/tm/elixir/lib/projectname/feature/streaming.ex +2 -1
- package/project/.sdk/tm/elixir/lib/projectname/feature/telemetry.ex +7 -7
- package/project/.sdk/tm/elixir/lib/projectname/feature/test.ex +52 -48
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +59 -35
- package/project/.sdk/tm/elixir/test/feature_test.exs +137 -0
- package/project/.sdk/tm/go/feature/audit_feature.go +1 -3
- package/project/.sdk/tm/go/feature/base_feature.go +11 -0
- package/project/.sdk/tm/go/feature/metrics_feature.go +14 -0
- package/project/.sdk/tm/go/feature/paging_feature.go +108 -2
- package/project/.sdk/tm/go/feature/ratelimit_feature.go +19 -17
- package/project/.sdk/tm/go/feature/retry_feature.go +81 -9
- package/project/.sdk/tm/go/feature/streaming_feature.go +2 -1
- package/project/.sdk/tm/go/feature/telemetry_feature.go +18 -11
- package/project/.sdk/tm/go/feature/test_feature.go +65 -55
- package/project/.sdk/tm/go/test/feature_corpus_test.go +209 -28
- package/project/.sdk/tm/go/test/feature_test.go +32 -0
- package/project/.sdk/tm/go/utility/make_options.go +111 -6
- package/project/.sdk/tm/java/core/SdkClient.java +43 -14
- package/project/.sdk/tm/java/feature/AuditFeature.java +5 -1
- package/project/.sdk/tm/java/feature/MetricsFeature.java +31 -0
- package/project/.sdk/tm/java/feature/PagingFeature.java +156 -2
- package/project/.sdk/tm/java/feature/RatelimitFeature.java +15 -13
- package/project/.sdk/tm/java/feature/RetryFeature.java +33 -6
- package/project/.sdk/tm/java/feature/StreamingFeature.java +2 -1
- package/project/.sdk/tm/java/feature/TelemetryFeature.java +17 -9
- package/project/.sdk/tm/java/feature/TestFeature.java +50 -63
- package/project/.sdk/tm/java/test/FeatureCorpusTest.java +170 -17
- package/project/.sdk/tm/java/utility/MakeOptions.java +128 -14
- package/project/.sdk/tm/js/src/feature/metrics/MetricsFeature.js +8 -3
- package/project/.sdk/tm/js/src/feature/paging/PagingFeature.js +99 -1
- package/project/.sdk/tm/js/src/feature/ratelimit/RatelimitFeature.js +5 -9
- package/project/.sdk/tm/js/src/feature/retry/RetryFeature.js +25 -3
- package/project/.sdk/tm/js/src/feature/streaming/StreamingFeature.js +2 -1
- package/project/.sdk/tm/js/src/feature/telemetry/TelemetryFeature.js +11 -6
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +38 -1
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +55 -6
- package/project/.sdk/tm/js/test/feature/Corpus.test.js +95 -25
- package/project/.sdk/tm/js/test/feature.test.js +14 -1
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +23 -10
- package/project/.sdk/tm/kotlin/feature/AuditFeature.kt +5 -1
- package/project/.sdk/tm/kotlin/feature/MetricsFeature.kt +22 -0
- package/project/.sdk/tm/kotlin/feature/PagingFeature.kt +125 -2
- package/project/.sdk/tm/kotlin/feature/RatelimitFeature.kt +16 -13
- package/project/.sdk/tm/kotlin/feature/RetryFeature.kt +36 -14
- package/project/.sdk/tm/kotlin/feature/StreamingFeature.kt +4 -0
- package/project/.sdk/tm/kotlin/feature/TelemetryFeature.kt +12 -10
- package/project/.sdk/tm/kotlin/feature/TestFeature.kt +45 -48
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +114 -0
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +83 -14
- package/project/.sdk/tm/lua/feature/debug_feature.lua +2 -3
- package/project/.sdk/tm/lua/feature/metrics_feature.lua +5 -0
- package/project/.sdk/tm/lua/feature/paging_feature.lua +143 -2
- package/project/.sdk/tm/lua/feature/ratelimit_feature.lua +5 -9
- package/project/.sdk/tm/lua/feature/retry_feature.lua +43 -5
- package/project/.sdk/tm/lua/feature/streaming_feature.lua +2 -1
- package/project/.sdk/tm/lua/feature/telemetry_feature.lua +18 -7
- package/project/.sdk/tm/lua/feature/test_feature.lua +60 -62
- package/project/.sdk/tm/lua/test/feature_test.lua +100 -3
- package/project/.sdk/tm/lua/utility/make_options.lua +55 -13
- package/project/.sdk/tm/ocaml/sdk_features.ml +286 -60
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +34 -11
- package/project/.sdk/tm/ocaml/test/t_feature.ml +72 -1
- package/project/.sdk/tm/perl/feature/debug_feature.pm +2 -2
- package/project/.sdk/tm/perl/feature/metrics_feature.pm +5 -0
- package/project/.sdk/tm/perl/feature/paging_feature.pm +139 -2
- package/project/.sdk/tm/perl/feature/ratelimit_feature.pm +5 -11
- package/project/.sdk/tm/perl/feature/retry_feature.pm +22 -4
- package/project/.sdk/tm/perl/feature/streaming_feature.pm +2 -0
- package/project/.sdk/tm/perl/feature/telemetry_feature.pm +17 -8
- package/project/.sdk/tm/perl/feature/test_feature.pm +45 -50
- package/project/.sdk/tm/perl/t/feature.t +2 -2
- package/project/.sdk/tm/perl/t/feature_corpus.t +126 -23
- package/project/.sdk/tm/perl/utility/make_options.pm +33 -10
- package/project/.sdk/tm/php/feature/MetricsFeature.php +8 -0
- package/project/.sdk/tm/php/feature/PagingFeature.php +128 -1
- package/project/.sdk/tm/php/feature/RatelimitFeature.php +5 -9
- package/project/.sdk/tm/php/feature/RetryFeature.php +27 -3
- package/project/.sdk/tm/php/feature/StreamingFeature.php +2 -1
- package/project/.sdk/tm/php/feature/TelemetryFeature.php +10 -7
- package/project/.sdk/tm/php/feature/TestFeature.php +55 -47
- package/project/.sdk/tm/php/test/FeatureCorpusTest.php +151 -16
- package/project/.sdk/tm/php/utility/MakeOptions.php +40 -13
- package/project/.sdk/tm/py/pkg/feature/metrics_feature.py +7 -0
- package/project/.sdk/tm/py/pkg/feature/paging_feature.py +86 -1
- package/project/.sdk/tm/py/pkg/feature/ratelimit_feature.py +13 -16
- package/project/.sdk/tm/py/pkg/feature/retry_feature.py +31 -6
- package/project/.sdk/tm/py/pkg/feature/streaming_feature.py +2 -1
- package/project/.sdk/tm/py/pkg/feature/telemetry_feature.py +10 -6
- package/project/.sdk/tm/py/pkg/feature/test_feature.py +56 -53
- package/project/.sdk/tm/py/pkg/utility/make_options.py +68 -20
- package/project/.sdk/tm/py/test/test_feature.py +11 -1
- package/project/.sdk/tm/py/test/test_feature_corpus.py +111 -16
- package/project/.sdk/tm/py-data/pkg/fetch.py +6 -3
- package/project/.sdk/tm/py-data/test/test_fetch.py +7 -4
- package/project/.sdk/tm/rb/feature/debug_feature.rb +2 -2
- package/project/.sdk/tm/rb/feature/metrics_feature.rb +8 -0
- package/project/.sdk/tm/rb/feature/paging_feature.rb +87 -1
- package/project/.sdk/tm/rb/feature/ratelimit_feature.rb +12 -16
- package/project/.sdk/tm/rb/feature/retry_feature.rb +19 -3
- package/project/.sdk/tm/rb/feature/streaming_feature.rb +2 -1
- package/project/.sdk/tm/rb/feature/telemetry_feature.rb +11 -6
- package/project/.sdk/tm/rb/feature/test_feature.rb +42 -49
- package/project/.sdk/tm/rb/test/feature_corpus_test.rb +108 -24
- package/project/.sdk/tm/rb/test/feature_test.rb +1 -1
- package/project/.sdk/tm/rb/utility/make_options.rb +32 -11
- package/project/.sdk/tm/rust/feature/audit.rs +2 -2
- package/project/.sdk/tm/rust/feature/metrics.rs +24 -1
- package/project/.sdk/tm/rust/feature/paging.rs +189 -3
- package/project/.sdk/tm/rust/feature/ratelimit.rs +5 -10
- package/project/.sdk/tm/rust/feature/retry.rs +59 -6
- package/project/.sdk/tm/rust/feature/streaming.rs +3 -2
- package/project/.sdk/tm/rust/feature/support.rs +4 -0
- package/project/.sdk/tm/rust/feature/telemetry.rs +22 -11
- package/project/.sdk/tm/rust/feature/test.rs +63 -57
- package/project/.sdk/tm/rust/tests/feature_test.rs +174 -0
- package/project/.sdk/tm/rust/tests/primary_utility_test.rs +1 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +122 -27
- package/project/.sdk/tm/scala/core/SdkClient.scala +45 -11
- package/project/.sdk/tm/scala/feature/AuditFeature.scala +6 -1
- package/project/.sdk/tm/scala/feature/MetricsFeature.scala +31 -1
- package/project/.sdk/tm/scala/feature/PagingFeature.scala +122 -2
- package/project/.sdk/tm/scala/feature/RatelimitFeature.scala +14 -11
- package/project/.sdk/tm/scala/feature/RetryFeature.scala +29 -7
- package/project/.sdk/tm/scala/feature/StreamingFeature.scala +2 -1
- package/project/.sdk/tm/scala/feature/TelemetryFeature.scala +12 -10
- package/project/.sdk/tm/scala/feature/TestFeature.scala +44 -44
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +41 -0
- package/project/.sdk/tm/scala/utility/Make.scala +96 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/AuditFeature.swift +3 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/MetricsFeature.swift +20 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/PagingFeature.swift +102 -2
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RatelimitFeature.swift +19 -13
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/RetryFeature.swift +40 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/StreamingFeature.swift +2 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TelemetryFeature.swift +11 -9
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/TestFeature.swift +55 -49
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +51 -13
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +111 -0
- package/project/.sdk/tm/ts/src/feature/metrics/MetricsFeature.ts +5 -0
- package/project/.sdk/tm/ts/src/feature/paging/PagingFeature.ts +99 -1
- package/project/.sdk/tm/ts/src/feature/ratelimit/RatelimitFeature.ts +5 -9
- package/project/.sdk/tm/ts/src/feature/retry/RetryFeature.ts +25 -3
- package/project/.sdk/tm/ts/src/feature/streaming/StreamingFeature.ts +2 -1
- package/project/.sdk/tm/ts/src/feature/telemetry/TelemetryFeature.ts +11 -6
- package/project/.sdk/tm/ts/src/feature/test/TestFeature.ts +8 -7
- package/project/.sdk/tm/ts/src/utility/MakeOptionsUtility.ts +57 -6
- package/project/.sdk/tm/ts/test/feature/Corpus.test.ts +95 -25
- package/project/.sdk/tm/ts/test/feature.test.ts +14 -1
- package/project/.sdk/tm/zig/core/utility.zig +107 -8
- package/project/.sdk/tm/zig/feature/metrics.zig +19 -0
- package/project/.sdk/tm/zig/feature/paging.zig +172 -4
- package/project/.sdk/tm/zig/feature/ratelimit.zig +5 -11
- package/project/.sdk/tm/zig/feature/retry.zig +41 -3
- package/project/.sdk/tm/zig/feature/streaming.zig +2 -0
- package/project/.sdk/tm/zig/feature/telemetry.zig +15 -9
- package/project/.sdk/tm/zig/feature/test.zig +56 -40
- package/project/.sdk/tm/zig/test/feature_test.zig +109 -0
- package/project/.sdk/tm/zig/test/primary_utility_test.zig +2 -0
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/ReadmeExplanation.ts +5 -2
- package/src/cmp/ReadmeFeatures.ts +21 -6
- package/src/helpers/optspec.ts +2 -2
|
@@ -10,6 +10,7 @@ import Foundation
|
|
|
10
10
|
public final class RatelimitFeature: BaseFeature {
|
|
11
11
|
private var client: ProjectNameSDK?
|
|
12
12
|
private var options: VMap?
|
|
13
|
+
private let lock = NSLock()
|
|
13
14
|
private var tokens: Double = 0
|
|
14
15
|
private var last: Int64 = 0
|
|
15
16
|
|
|
@@ -47,29 +48,34 @@ public final class RatelimitFeature: BaseFeature {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
private func acquire() {
|
|
51
|
+
let wait = reserve()
|
|
52
|
+
if wait > 0 {
|
|
53
|
+
foptSleep(options)(wait)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Refill, then reserve this call's token before any wait, under the lock:
|
|
58
|
+
// a negative count is the calls already queued, so overlapping calls pace
|
|
59
|
+
// in turn.
|
|
60
|
+
private func reserve() -> Int {
|
|
50
61
|
let rate = foptNum(options, "rate", 5)
|
|
51
62
|
let burst = foptNum(options, "burst", rate)
|
|
52
63
|
|
|
53
|
-
|
|
64
|
+
lock.lock()
|
|
65
|
+
defer { lock.unlock() }
|
|
66
|
+
|
|
54
67
|
let now = foptNow(options)()
|
|
55
68
|
let elapsed = now - last
|
|
56
69
|
last = now
|
|
57
|
-
tokens = min(burst, tokens + (Double(elapsed) / 1000.0) * rate)
|
|
70
|
+
tokens = min(burst, tokens + (Double(elapsed) / 1000.0) * rate) - 1
|
|
58
71
|
|
|
59
|
-
if tokens >=
|
|
60
|
-
|
|
61
|
-
return
|
|
72
|
+
if tokens >= 0 {
|
|
73
|
+
return 0
|
|
62
74
|
}
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
let needed = 1 - tokens
|
|
66
|
-
let wait = Int(ceil((needed / rate) * 1000))
|
|
76
|
+
let wait = Int(ceil((-tokens / rate) * 1000))
|
|
67
77
|
track(wait)
|
|
68
|
-
|
|
69
|
-
foptSleep(options)(wait)
|
|
70
|
-
}
|
|
71
|
-
last = foptNow(options)()
|
|
72
|
-
tokens = 0
|
|
78
|
+
return wait
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
private func track(_ wait: Int) {
|
|
@@ -99,7 +99,7 @@ public final class RetryFeature: BaseFeature {
|
|
|
99
99
|
|
|
100
100
|
private func backoff(_ res: Value, _ attempt: Int, _ minDelay: Int, _ maxDelay: Int,
|
|
101
101
|
_ factor: Double) -> Int {
|
|
102
|
-
//
|
|
102
|
+
// A server-provided Retry-After wins over the computed backoff.
|
|
103
103
|
let (ra, has) = retryAfter(res)
|
|
104
104
|
if has {
|
|
105
105
|
return ra > maxDelay ? maxDelay : ra
|
|
@@ -118,11 +118,46 @@ public final class RetryFeature: BaseFeature {
|
|
|
118
118
|
if !has {
|
|
119
119
|
return (0, false)
|
|
120
120
|
}
|
|
121
|
-
let
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
let ms = RetryFeature.retryAfterMs(v, Int64(Date().timeIntervalSince1970 * 1000))
|
|
122
|
+
return ms < 0 ? (0, false) : (ms, true)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private static let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
126
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
|
127
|
+
|
|
128
|
+
private static let days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
|
129
|
+
|
|
130
|
+
// RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else -1.
|
|
131
|
+
static func retryAfterMs(_ value: String, _ now: Int64) -> Int {
|
|
132
|
+
let s = Array(value.trimmingCharacters(in: CharacterSet(charactersIn: " \t")).utf8)
|
|
133
|
+
let isDigit = { (c: UInt8) in c >= 48 && c <= 57 }
|
|
134
|
+
if !s.isEmpty && s.allSatisfy(isDigit) {
|
|
135
|
+
return s.count > 6 ? Int(Int32.max) : Int(String(decoding: s, as: UTF8.self))! * 1000
|
|
136
|
+
}
|
|
137
|
+
let text = { (from: Int, to: Int) in String(decoding: s[from..<to], as: UTF8.self) }
|
|
138
|
+
let num = { (from: Int, to: Int) -> Int in
|
|
139
|
+
s[from..<to].allSatisfy(isDigit) ? Int(text(from, to))! : -1
|
|
140
|
+
}
|
|
141
|
+
guard s.count == 29, text(3, 5) == ", ", s[7] == 32, s[11] == 32, s[16] == 32,
|
|
142
|
+
s[19] == 58, s[22] == 58, text(25, 29) == " GMT", days.contains(text(0, 3)),
|
|
143
|
+
let mi = months.firstIndex(of: text(8, 11)) else {
|
|
144
|
+
return -1
|
|
145
|
+
}
|
|
146
|
+
let (day, year, hour, min, sec) = (num(5, 7), num(12, 16), num(17, 19), num(20, 22), num(23, 25))
|
|
147
|
+
if day < 1 || day > 31 || year < 0 || hour < 0 || hour > 23 || min < 0 || min > 59 ||
|
|
148
|
+
sec < 0 || sec > 60 {
|
|
149
|
+
return -1
|
|
124
150
|
}
|
|
125
|
-
|
|
151
|
+
var y = year
|
|
152
|
+
let m = mi + 1
|
|
153
|
+
if m <= 2 { y -= 1 }
|
|
154
|
+
let era = (y >= 0 ? y : y - 399) / 400
|
|
155
|
+
let yoe = y - era * 400
|
|
156
|
+
let doy = (153 * ((m + 9) % 12) + 2) / 5 + day - 1
|
|
157
|
+
let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy
|
|
158
|
+
let epochDays = Int64(era * 146097 + doe - 719468)
|
|
159
|
+
let at = (((epochDays * 24 + Int64(hour)) * 60 + Int64(min)) * 60 + Int64(sec)) * 1000
|
|
160
|
+
return Int(Swift.min(Int64(Int32.max), Swift.max(0, at - now)))
|
|
126
161
|
}
|
|
127
162
|
|
|
128
163
|
private func sleepMs(_ ms: Int) {
|
|
@@ -31,7 +31,8 @@ public final class StreamingFeature: BaseFeature {
|
|
|
31
31
|
if !active || !streamable(ctx) {
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
// A failed result keeps no stream, so the entity's stream raises its error.
|
|
35
|
+
guard let result = ctx.result, result.err == nil else {
|
|
35
36
|
return
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -12,7 +12,6 @@ import Foundation
|
|
|
12
12
|
public final class TelemetryFeature: BaseFeature {
|
|
13
13
|
private var client: ProjectNameSDK?
|
|
14
14
|
private var options: VMap?
|
|
15
|
-
private var seq = 0
|
|
16
15
|
|
|
17
16
|
// Activity tracking (mirrors the ts client._telemetry record).
|
|
18
17
|
public var spans: [VMap] = []
|
|
@@ -31,7 +30,6 @@ public final class TelemetryFeature: BaseFeature {
|
|
|
31
30
|
client = ctx.client
|
|
32
31
|
self.options = options
|
|
33
32
|
active = foptBool(options, "active", false)
|
|
34
|
-
seq = 0
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
public override func prePoint(_ ctx: Context) {
|
|
@@ -111,12 +109,16 @@ public final class TelemetryFeature: BaseFeature {
|
|
|
111
109
|
if let idgen = gp(options, "idgen").asNative as? (String) -> String {
|
|
112
110
|
return idgen(kind)
|
|
113
111
|
}
|
|
114
|
-
|
|
115
|
-
seq += 1
|
|
116
|
-
var n = String(seq, radix: 16)
|
|
117
|
-
while n.count < 4 { n = "0" + n }
|
|
118
|
-
let prefix = kind == "trace" ? "t" : "s"
|
|
119
|
-
while n.count < 16 { n += "0" }
|
|
120
|
-
return prefix + n
|
|
112
|
+
return telemetryRandomHex(kind == "trace" ? 16 : 8)
|
|
121
113
|
}
|
|
122
114
|
}
|
|
115
|
+
|
|
116
|
+
// W3C trace context: lowercase hex from the platform's random source, never all zeros.
|
|
117
|
+
func telemetryRandomHex(_ bytes: Int) -> String {
|
|
118
|
+
var rng = SystemRandomNumberGenerator()
|
|
119
|
+
var buf = [UInt8](repeating: 0, count: bytes)
|
|
120
|
+
repeat {
|
|
121
|
+
for i in buf.indices { buf[i] = UInt8.random(in: 0...255, using: &rng) }
|
|
122
|
+
} while buf.allSatisfy { $0 == 0 }
|
|
123
|
+
return buf.map { String(format: "%02x", $0) }.joined()
|
|
124
|
+
}
|
|
@@ -64,19 +64,9 @@ private func testRespond(_ ctx: Context, _ status: Int, _ data: Value, _ extra:
|
|
|
64
64
|
return .map(res)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if explicitMatch.entries.count > 0 { return explicitMatch }
|
|
71
|
-
for src in [ctx2.match, ctx2.data] {
|
|
72
|
-
let v = gp(src, "id")
|
|
73
|
-
if !isNil(v) && v != .string("__UNDEFINED__") {
|
|
74
|
-
let m = VMap()
|
|
75
|
-
m.entries["id"] = v
|
|
76
|
-
return m
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return VMap()
|
|
67
|
+
private func testHeld(_ src: VMap, _ key: String) -> Bool {
|
|
68
|
+
let v = gp(src, key)
|
|
69
|
+
return !isNil(v) && v != .string("__UNDEFINED__")
|
|
80
70
|
}
|
|
81
71
|
|
|
82
72
|
// The entity's declared identity field (`entity.id.field`), where it names
|
|
@@ -146,33 +136,60 @@ private func testBuildArgs(_ ctx: Context, _ op: Operation, _ args: VMap?) -> Va
|
|
|
146
136
|
let q = VMap()
|
|
147
137
|
q.entries["`$AND`"] = .list(qand)
|
|
148
138
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
let isId = key == "id"
|
|
152
|
-
let selected = select(reqd, .string(key))
|
|
153
|
-
let isReqd = !isempty(selected)
|
|
154
|
-
|
|
155
|
-
if isId || isReqd {
|
|
156
|
-
let v = ctx.utility!.param(ctx, .string(key))
|
|
157
|
-
let ka = gp(op.alias, key)
|
|
158
|
-
|
|
159
|
-
let qor = VList()
|
|
160
|
-
let qm1 = VMap()
|
|
161
|
-
qm1.entries[key] = v
|
|
162
|
-
qor.items.append(.map(qm1))
|
|
163
|
-
if let kas = ka.asString {
|
|
164
|
-
let qm2 = VMap()
|
|
165
|
-
qm2.entries[kas] = v
|
|
166
|
-
qor.items.append(.map(qm2))
|
|
167
|
-
}
|
|
139
|
+
let entityName = ctx.entity!.getName()
|
|
140
|
+
let idfrom = getpath(cfg, jtp("entity", entityName, "id", "from"))
|
|
168
141
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
142
|
+
var names: [String] = args == nil ? [] : keysof(.map(args!))
|
|
143
|
+
|
|
144
|
+
// With no id in the call, the entity's held id (or composite parts) stands in.
|
|
145
|
+
if args == nil || isNil(gp(args!, "id")) {
|
|
146
|
+
let declared = getpath(cfg, jtp("entity", entityName, "id", "parts")).asList?.items
|
|
147
|
+
let parts: [Value] = declared ?? (opname == "list" ? [] : [.string("id")])
|
|
148
|
+
for part in parts {
|
|
149
|
+
let pname = part.asString ?? stringify(part)
|
|
150
|
+
if !names.contains(pname) && (testHeld(ctx.match, pname) || testHeld(ctx.data, pname)) {
|
|
151
|
+
names.append(pname)
|
|
172
152
|
}
|
|
173
153
|
}
|
|
174
154
|
}
|
|
175
155
|
|
|
156
|
+
for key in names {
|
|
157
|
+
let isId = key == "id"
|
|
158
|
+
let selected = select(reqd, .string(key))
|
|
159
|
+
let isReqd = !isempty(selected)
|
|
160
|
+
|
|
161
|
+
if isId || isReqd {
|
|
162
|
+
let v = ctx.utility!.param(ctx, .string(key))
|
|
163
|
+
let ka = gp(op.alias, key)
|
|
164
|
+
|
|
165
|
+
let qor = VList()
|
|
166
|
+
let qm1 = VMap()
|
|
167
|
+
qm1.entries[key] = v
|
|
168
|
+
qor.items.append(.map(qm1))
|
|
169
|
+
if let kas = ka.asString {
|
|
170
|
+
let qm2 = VMap()
|
|
171
|
+
qm2.entries[kas] = v
|
|
172
|
+
qor.items.append(.map(qm2))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// An alternative, never a replacement: a seed keeping the parameter
|
|
176
|
+
// flat is still found.
|
|
177
|
+
if let kf = getprop(idfrom, .string(key)).asString, kf != key {
|
|
178
|
+
var nest: Value = v
|
|
179
|
+
for seg in kf.split(separator: ".").reversed() {
|
|
180
|
+
let m = VMap()
|
|
181
|
+
m.entries[String(seg)] = nest
|
|
182
|
+
nest = .map(m)
|
|
183
|
+
}
|
|
184
|
+
qor.items.append(nest)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let qorm = VMap()
|
|
188
|
+
qorm.entries["`$OR`"] = .list(qor)
|
|
189
|
+
qand.items.append(.map(qorm))
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
176
193
|
if let explain = ctx.ctrl.explain {
|
|
177
194
|
let tm = VMap()
|
|
178
195
|
tm.entries["query"] = .map(q)
|
|
@@ -218,7 +235,7 @@ public final class TestFeature: BaseFeature {
|
|
|
218
235
|
let entmap = gp(entity, op.entity).asMap ?? VMap()
|
|
219
236
|
|
|
220
237
|
if op.name == "load" {
|
|
221
|
-
let args = testBuildArgs(ctx2, op,
|
|
238
|
+
let args = testBuildArgs(ctx2, op, ctx2.reqmatch)
|
|
222
239
|
let found = select(.map(entmap), args)
|
|
223
240
|
let ent = getelem(found, .int(0))
|
|
224
241
|
if isNil(ent) {
|
|
@@ -241,18 +258,7 @@ public final class TestFeature: BaseFeature {
|
|
|
241
258
|
}
|
|
242
259
|
return testRespond(ctx2, 200, clone(found), nil)
|
|
243
260
|
} else if op.name == "update" || op.name == "patch" {
|
|
244
|
-
|
|
245
|
-
if let idv = ctx2.reqdata.entries["id"] {
|
|
246
|
-
updateMatch.entries["id"] = idv
|
|
247
|
-
}
|
|
248
|
-
if let alias = op.alias, let aliasId = gp(alias, "id").asString,
|
|
249
|
-
let av = ctx2.reqdata.entries[aliasId] {
|
|
250
|
-
updateMatch.entries[aliasId] = av
|
|
251
|
-
}
|
|
252
|
-
if updateMatch.entries.count == 0 {
|
|
253
|
-
updateMatch = testResolveMatch(ctx2, VMap())
|
|
254
|
-
}
|
|
255
|
-
let args = testBuildArgs(ctx2, op, updateMatch)
|
|
261
|
+
let args = testBuildArgs(ctx2, op, testRecord(ctx2.reqdata))
|
|
256
262
|
let found = select(.map(entmap), args)
|
|
257
263
|
let ent = getelem(found, .int(0))
|
|
258
264
|
if isNil(ent) {
|
|
@@ -267,7 +273,7 @@ public final class TestFeature: BaseFeature {
|
|
|
267
273
|
_ = try? delprop(ent, .string("$KEY"))
|
|
268
274
|
return testRespond(ctx2, 200, clone(ent), nil)
|
|
269
275
|
} else if op.name == "remove" {
|
|
270
|
-
let args = testBuildArgs(ctx2, op,
|
|
276
|
+
let args = testBuildArgs(ctx2, op, ctx2.reqmatch)
|
|
271
277
|
let found = select(.map(entmap), args)
|
|
272
278
|
let ent = getelem(found, .int(0))
|
|
273
279
|
if let entm2 = ent.asMap {
|
|
@@ -97,6 +97,10 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
|
|
|
97
97
|
opts.entries["feature"] = .map(fmap)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
if let fdefaults = featureDefaults(gp(config, "feature"), opts.entries["feature"] ?? .noval) {
|
|
101
|
+
opts.entries["feature"] = .map(fdefaults)
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
// THE OPTION SPEC IS GENERATED, NOT WRITTEN HERE.
|
|
101
105
|
//
|
|
102
106
|
// Built from the model: `main.kit.optspec` for the standard options, plus
|
|
@@ -119,7 +123,16 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
|
|
|
119
123
|
// so without this one client's options (headers, server, ...) are written
|
|
120
124
|
// into the shared config and inherited by every client built afterwards.
|
|
121
125
|
let merged = merge(.list([.map(VMap()), clone(.map(cfgopts)), .map(opts)]))
|
|
122
|
-
let
|
|
126
|
+
let vinj = Injection(val: .noval, parent: .noval)
|
|
127
|
+
vinj.errs = VList()
|
|
128
|
+
let validated = (try? validate(merged, optspec, vinj)) ?? .noval
|
|
129
|
+
if !vinj.errs.items.isEmpty {
|
|
130
|
+
let verrs = vinj.errs
|
|
131
|
+
// The initializer cannot throw, so a construction error traps, as zig's panics.
|
|
132
|
+
let text = verrs.items.map { $0.asString ?? stringify($0) }.joined(separator: " | ")
|
|
133
|
+
fatalError(errMessage(ProjectNameError("options_invalid",
|
|
134
|
+
cleanUtil(cleanctx, .string("invalid options: " + text)).asString ?? "invalid options", nil)))
|
|
135
|
+
}
|
|
123
136
|
let result = validated.asMap ?? VMap()
|
|
124
137
|
|
|
125
138
|
// Restore the suppression the optspec default would otherwise erase.
|
|
@@ -148,17 +161,19 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
|
|
|
148
161
|
}
|
|
149
162
|
}
|
|
150
163
|
|
|
151
|
-
// Resolve the feature add-order: an explicit list order (above) wins
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
|
|
164
|
+
// Resolve the feature add-order: an explicit list order (above) wins, and
|
|
165
|
+
// the names it leaves out follow it test-first, then sorted, so the outcome
|
|
166
|
+
// is deterministic and `test` is the base transport of a map.
|
|
167
|
+
do {
|
|
155
168
|
let fmap = gp(result, "feature").asMap ?? VMap()
|
|
156
|
-
let
|
|
169
|
+
let given = Set(featureorder.compactMap { $0.asString })
|
|
170
|
+
let names = fmap.entries.keys.filter { !given.contains($0) }.sorted()
|
|
171
|
+
var rest: [Value] = []
|
|
157
172
|
if names.contains("test") {
|
|
158
|
-
|
|
159
|
-
for n in names where n != "test" {
|
|
173
|
+
rest.append(.string("test"))
|
|
174
|
+
for n in names where n != "test" { rest.append(.string(n)) }
|
|
160
175
|
} else {
|
|
161
|
-
for n in names {
|
|
176
|
+
for n in names { rest.append(.string(n)) }
|
|
162
177
|
}
|
|
163
178
|
|
|
164
179
|
// Station special case, mirroring test's: its transport wrap must
|
|
@@ -167,11 +182,12 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
|
|
|
167
182
|
// test - or first, when no test entry exists. Without this the
|
|
168
183
|
// sorted default would init station last and wrap OUTSIDE the
|
|
169
184
|
// recording features, turning its wire-truth events into fiction.
|
|
170
|
-
if let si =
|
|
171
|
-
|
|
172
|
-
let ti =
|
|
173
|
-
|
|
185
|
+
if let si = rest.firstIndex(where: { $0.asString == "station" }) {
|
|
186
|
+
rest.remove(at: si)
|
|
187
|
+
let ti = rest.firstIndex(where: { $0.asString == "test" })
|
|
188
|
+
rest.insert(.string("station"), at: (ti ?? -1) + 1)
|
|
174
189
|
}
|
|
190
|
+
featureorder.append(contentsOf: rest)
|
|
175
191
|
}
|
|
176
192
|
|
|
177
193
|
let derived = VMap()
|
|
@@ -187,6 +203,28 @@ func makeOptionsUtil(_ ctx: Context) -> VMap {
|
|
|
187
203
|
return result
|
|
188
204
|
}
|
|
189
205
|
|
|
206
|
+
// The model's options for a feature sit beneath the caller's, key by key: a
|
|
207
|
+
// key the caller sets replaces the default whole, so a list is never merged.
|
|
208
|
+
private func featureDefaults(_ cfgfeature: Value, _ feature: Value) -> VMap? {
|
|
209
|
+
if !isNil(feature) && feature.asMap == nil {
|
|
210
|
+
return nil
|
|
211
|
+
}
|
|
212
|
+
let out = VMap()
|
|
213
|
+
for (k, v) in feature.asMap?.entries ?? [:] { out.entries[k] = v }
|
|
214
|
+
for (name, fdef) in cfgfeature.asMap?.entries ?? [:] {
|
|
215
|
+
guard let dflt = gp(fdef, "options").asMap else { continue }
|
|
216
|
+
let given = out.entries[name] ?? .noval
|
|
217
|
+
if (isNil(given) && gp(.map(dflt), "active") != .bool(true)) ||
|
|
218
|
+
(!isNil(given) && given.asMap == nil) {
|
|
219
|
+
continue
|
|
220
|
+
}
|
|
221
|
+
let merged = clone(.map(dflt)).asMap ?? VMap()
|
|
222
|
+
for (k, v) in given.asMap?.entries ?? [:] { merged.entries[k] = v }
|
|
223
|
+
out.entries[name] = .map(merged)
|
|
224
|
+
}
|
|
225
|
+
return out
|
|
226
|
+
}
|
|
227
|
+
|
|
190
228
|
// A templated base URL takes each {name} from options.server. An empty value
|
|
191
229
|
// cannot make a working URL, so it is an error, except in test mode, where it
|
|
192
230
|
// becomes test-<name>.
|
|
@@ -1048,6 +1048,96 @@ final class FeaturePagingTest: XCTestCase {
|
|
|
1048
1048
|
XCTAssertEqual(res.result!.paging!.entries["hasMore"], .bool(true))
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
+
// The documented hasMore loop, one request per page.
|
|
1052
|
+
private func walk(_ reply: @escaping (Int) -> Value, _ options: VMap? = nil) -> ([String], VMap) {
|
|
1053
|
+
let rec = FhRecorder()
|
|
1054
|
+
rec.reply = { n, _ in reply(n) }
|
|
1055
|
+
let h = Fh.make(rec.fetch, (PagingFeature(), options))
|
|
1056
|
+
let paging = VMap()
|
|
1057
|
+
let ctrl = vm(("paging", .map(paging)))
|
|
1058
|
+
_ = h.op(FhOpSpec(op: "list", path: "/w", ctrl: ctrl))
|
|
1059
|
+
while paging.entries["hasMore"] == .bool(true) && rec.calls.count < 4 {
|
|
1060
|
+
_ = h.op(FhOpSpec(op: "list", path: "/w", ctrl: ctrl))
|
|
1061
|
+
}
|
|
1062
|
+
return ((0..<rec.calls.count).map { rec.url($0) }, paging)
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
func testBodyNextIsSentAsTheCursor() {
|
|
1066
|
+
if Fh.skipWithout("paging") { return }
|
|
1067
|
+
let pages: [Value] = [.string("c3"), .string("c6"), .null]
|
|
1068
|
+
let (urls, paging) = walk { n in Fh.response(200, mapv(("next", pages[n - 1])), nil) }
|
|
1069
|
+
XCTAssertEqual(urls, [
|
|
1070
|
+
"http://api.test/w?page=1", "http://api.test/w?cursor=c3", "http://api.test/w?cursor=c6",
|
|
1071
|
+
])
|
|
1072
|
+
XCTAssertEqual(paging.entries["hasMore"], .bool(false))
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
func testBodyNextUrlIsTheNextRequest() {
|
|
1076
|
+
if Fh.skipWithout("paging") { return }
|
|
1077
|
+
let pages: [Value] = [
|
|
1078
|
+
.string("http://api.test/v2/w?cursor=c%2F3&limit=3"), .string("/v2/w?cursor=c6"), .null,
|
|
1079
|
+
]
|
|
1080
|
+
let (urls, paging) = walk { n in Fh.response(200, mapv(("next", pages[n - 1])), nil) }
|
|
1081
|
+
XCTAssertEqual(urls, [
|
|
1082
|
+
"http://api.test/w?page=1", "http://api.test/v2/w?cursor=c%2F3&limit=3",
|
|
1083
|
+
"http://api.test/v2/w?cursor=c6",
|
|
1084
|
+
])
|
|
1085
|
+
XCTAssertEqual(paging.entries["hasMore"], .bool(false))
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
func testLinkNextUrlIsTheNextRequest() {
|
|
1089
|
+
if Fh.skipWithout("paging") { return }
|
|
1090
|
+
let links = ["<http://api.test/w?after=b3>; rel=\"next\"", "</w?after=b6>; rel=\"next\""]
|
|
1091
|
+
let (urls, paging) = walk { n in
|
|
1092
|
+
Fh.response(200, .list([]), n <= links.count ? vm(("link", .string(links[n - 1]))) : nil)
|
|
1093
|
+
}
|
|
1094
|
+
XCTAssertEqual(urls, [
|
|
1095
|
+
"http://api.test/w?page=1", "http://api.test/w?after=b3", "http://api.test/w?after=b6",
|
|
1096
|
+
])
|
|
1097
|
+
XCTAssertEqual(paging.entries["hasMore"], .bool(false))
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
func testQueryOnlyLinkKeepsThePath() {
|
|
1101
|
+
if Fh.skipWithout("paging") { return }
|
|
1102
|
+
let links = ["</v1/items?page=2>; rel=\"next\"", "<?page=3>; rel=\"next\""]
|
|
1103
|
+
let (urls, _) = walk { n in
|
|
1104
|
+
Fh.response(200, .list([]), n <= links.count ? vm(("link", .string(links[n - 1]))) : nil)
|
|
1105
|
+
}
|
|
1106
|
+
XCTAssertEqual(urls, [
|
|
1107
|
+
"http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/items?page=3",
|
|
1108
|
+
])
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
func testPathRelativeLinkResolvesAgainstTheRequest() {
|
|
1112
|
+
if Fh.skipWithout("paging") { return }
|
|
1113
|
+
let links = ["</v1/items?page=2>; rel=\"next\"", "<more?page=3>; rel=\"next\""]
|
|
1114
|
+
let (urls, _) = walk { n in
|
|
1115
|
+
Fh.response(200, .list([]), n <= links.count ? vm(("link", .string(links[n - 1]))) : nil)
|
|
1116
|
+
}
|
|
1117
|
+
XCTAssertEqual(urls, [
|
|
1118
|
+
"http://api.test/w?page=1", "http://api.test/v1/items?page=2", "http://api.test/v1/more?page=3",
|
|
1119
|
+
])
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
func testForeignLinkEndsTheWalk() {
|
|
1123
|
+
if Fh.skipWithout("paging") { return }
|
|
1124
|
+
let (urls, paging) = walk { _ in
|
|
1125
|
+
Fh.response(200, .list([]), vm(("link", .string("<https://elsewhere.test/w?after=b3>; rel=\"next\""))))
|
|
1126
|
+
}
|
|
1127
|
+
XCTAssertEqual(urls, ["http://api.test/w?page=1"])
|
|
1128
|
+
XCTAssertEqual(paging.entries["hasMore"], .bool(false))
|
|
1129
|
+
XCTAssertEqual(paging.entries["foreign"], .string("https://elsewhere.test/w?after=b3"))
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
func testCursorModeSendsASlashCursor() {
|
|
1133
|
+
if Fh.skipWithout("paging") { return }
|
|
1134
|
+
let pages: [Value] = [.string("/c3"), .null]
|
|
1135
|
+
let (urls, paging) = walk({ n in Fh.response(200, mapv(("next", pages[n - 1])), nil) },
|
|
1136
|
+
vm(("next", .string("cursor"))))
|
|
1137
|
+
XCTAssertEqual(urls, ["http://api.test/w?page=1", "http://api.test/w?cursor=%2Fc3"])
|
|
1138
|
+
XCTAssertEqual(paging.entries["hasMore"], .bool(false))
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1051
1141
|
func testNonListNotPaged() {
|
|
1052
1142
|
if Fh.skipWithout("paging") { return }
|
|
1053
1143
|
let rec = FhRecorder()
|
|
@@ -1094,6 +1184,27 @@ final class FeatureStreamingTest: XCTestCase {
|
|
|
1094
1184
|
XCTAssertTrue(SdkRunner.deepEqual(.list(batches), want))
|
|
1095
1185
|
}
|
|
1096
1186
|
|
|
1187
|
+
func testFailedResultIsNotStreamed() {
|
|
1188
|
+
if Fh.skipWithout("streaming") { return }
|
|
1189
|
+
let rec = FhRecorder()
|
|
1190
|
+
rec.reply = { _, _ in Fh.response(503, .list([]), nil) }
|
|
1191
|
+
let f = StreamingFeature()
|
|
1192
|
+
let h = Fh.make(rec.fetch, (f, nil))
|
|
1193
|
+
let res = h.op(FhOpSpec(op: "list", path: "/w"))
|
|
1194
|
+
XCTAssertFalse(res.ok)
|
|
1195
|
+
XCTAssertFalse(res.result!.streaming || res.result!.stream != nil, "a failed result must keep no stream")
|
|
1196
|
+
XCTAssertEqual(f.opened, 0)
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
func testEmptyListStreamsNothing() {
|
|
1200
|
+
if Fh.skipWithout("streaming") { return }
|
|
1201
|
+
let rec = FhRecorder()
|
|
1202
|
+
rec.reply = { _, _ in Fh.response(200, .list([]), nil) }
|
|
1203
|
+
let h = Fh.make(rec.fetch, (StreamingFeature(), nil))
|
|
1204
|
+
let res = h.op(FhOpSpec(op: "list", path: "/w"))
|
|
1205
|
+
XCTAssertEqual(res.result!.stream!().count, 0)
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1097
1208
|
func testNonListNotStreamed() {
|
|
1098
1209
|
if Fh.skipWithout("streaming") { return }
|
|
1099
1210
|
let h = Fh.make(nil, (StreamingFeature(), nil))
|
|
@@ -70,6 +70,11 @@ class MetricsFeature extends BaseFeature {
|
|
|
70
70
|
|
|
71
71
|
this._bump(m.total, ok, dur)
|
|
72
72
|
this._bump(op, ok, dur)
|
|
73
|
+
|
|
74
|
+
const sink = this._options.sink
|
|
75
|
+
if ('function' === typeof sink) {
|
|
76
|
+
try { sink(ctx.utility.clean(ctx, m)) } catch (_e) { }
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
|