@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
|
@@ -61,30 +61,54 @@ public abstract class SdkClient {
|
|
|
61
61
|
if (featureOpts == null) {
|
|
62
62
|
featureOpts = new java.util.LinkedHashMap<>();
|
|
63
63
|
}
|
|
64
|
+
List<Feature> extend = new ArrayList<>();
|
|
65
|
+
Object extendRaw = Struct.getprop(this.options, "extend");
|
|
66
|
+
if (extendRaw instanceof List) {
|
|
67
|
+
for (Object f : (List<Object>) extendRaw) {
|
|
68
|
+
if (f instanceof Feature) {
|
|
69
|
+
extend.add((Feature) f);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
List<Feature> placed = new ArrayList<>();
|
|
64
74
|
Object featureOrderRaw =
|
|
65
75
|
Struct.getpath(this.options, List.of("__derived__", "featureorder"));
|
|
66
76
|
if (featureOrderRaw instanceof List) {
|
|
67
77
|
for (Object fnameObj : (List<Object>) featureOrderRaw) {
|
|
68
78
|
String fname = fnameObj instanceof String ? (String) fnameObj : null;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
if (fname == null || !featureActive(featureOpts, fname)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
Feature f = Config.makeFeature(fname);
|
|
83
|
+
// An active name with no generated class is legal when an
|
|
84
|
+
// extend-supplied instance carries that name (station's adopt
|
|
85
|
+
// path): the instance takes the slot the order gives its name.
|
|
86
|
+
Feature carried = null;
|
|
87
|
+
if (f == null || !fname.equals(f.getName())) {
|
|
88
|
+
for (Feature ef : extend) {
|
|
89
|
+
if (fname.equals(ef.getName())) {
|
|
90
|
+
carried = ef;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
}
|
|
95
|
+
if (carried != null) {
|
|
96
|
+
placed.add(carried);
|
|
97
|
+
this.utility.featureAdd.apply(this.rootctx, carried);
|
|
98
|
+
}
|
|
99
|
+
else if (f != null) {
|
|
100
|
+
this.utility.featureAdd.apply(this.rootctx, f);
|
|
101
|
+
}
|
|
78
102
|
}
|
|
79
103
|
}
|
|
80
104
|
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
105
|
+
// An extend feature is active by its option, else by its own flag.
|
|
106
|
+
for (Feature f : extend) {
|
|
107
|
+
Map<String, Object> fopts = Helpers.toMapAny(Struct.getprop(featureOpts, f.getName()));
|
|
108
|
+
Object fa = fopts == null ? null : fopts.get("active");
|
|
109
|
+
boolean on = fa instanceof Boolean ? (Boolean) fa : f.getActive();
|
|
110
|
+
if (placed.stream().noneMatch(p -> p == f) && on) {
|
|
111
|
+
this.utility.featureAdd.apply(this.rootctx, f);
|
|
88
112
|
}
|
|
89
113
|
}
|
|
90
114
|
|
|
@@ -96,6 +120,11 @@ public abstract class SdkClient {
|
|
|
96
120
|
this.utility.featureHook.apply(this.rootctx, "PostConstruct");
|
|
97
121
|
}
|
|
98
122
|
|
|
123
|
+
private static boolean featureActive(Map<String, Object> featureOpts, String fname) {
|
|
124
|
+
Map<String, Object> fopts = Helpers.toMapAny(Struct.getprop(featureOpts, fname));
|
|
125
|
+
return fopts != null && Boolean.TRUE.equals(fopts.get("active"));
|
|
126
|
+
}
|
|
127
|
+
|
|
99
128
|
public Map<String, Object> optionsMap() {
|
|
100
129
|
Object out = Struct.clone(this.options);
|
|
101
130
|
if (out instanceof Map) {
|
|
@@ -113,7 +113,11 @@ public class AuditFeature extends BaseFeature {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if (this.options.get("sink") instanceof Consumer) {
|
|
116
|
-
|
|
116
|
+
// A failing sink never changes the operation's outcome.
|
|
117
|
+
try {
|
|
118
|
+
((Consumer<Map<String, Object>>) this.options.get("sink")).accept(record);
|
|
119
|
+
} catch (RuntimeException e) {
|
|
120
|
+
}
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
}
|
|
@@ -2,6 +2,7 @@ package JAVAPACKAGE.feature;
|
|
|
2
2
|
|
|
3
3
|
import java.util.LinkedHashMap;
|
|
4
4
|
import java.util.Map;
|
|
5
|
+
import java.util.function.Consumer;
|
|
5
6
|
|
|
6
7
|
import JAVAPACKAGE.core.Context;
|
|
7
8
|
import JAVAPACKAGE.core.Helpers;
|
|
@@ -13,6 +14,7 @@ import JAVAPACKAGE.core.SdkClient;
|
|
|
13
14
|
// or fails (PreUnexpected); each operation is recorded exactly once (the
|
|
14
15
|
// per-context start marker in ctx.out is consumed on record). The clock is
|
|
15
16
|
// injectable (`now`) for deterministic tests.
|
|
17
|
+
@SuppressWarnings({"unchecked"})
|
|
16
18
|
public class MetricsFeature extends BaseFeature {
|
|
17
19
|
|
|
18
20
|
private SdkClient client;
|
|
@@ -28,6 +30,16 @@ public class MetricsFeature extends BaseFeature {
|
|
|
28
30
|
public int err = 0;
|
|
29
31
|
public long totalMs = 0;
|
|
30
32
|
public long maxMs = 0;
|
|
33
|
+
|
|
34
|
+
public Map<String, Object> record() {
|
|
35
|
+
Map<String, Object> out = new LinkedHashMap<>();
|
|
36
|
+
out.put("count", count);
|
|
37
|
+
out.put("ok", ok);
|
|
38
|
+
out.put("err", err);
|
|
39
|
+
out.put("totalMs", totalMs);
|
|
40
|
+
out.put("maxMs", maxMs);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
private static final String METRICS_START_KEY = "metrics_start";
|
|
@@ -97,6 +109,25 @@ public class MetricsFeature extends BaseFeature {
|
|
|
97
109
|
|
|
98
110
|
bump(this.total, ok, dur);
|
|
99
111
|
bump(op, ok, dur);
|
|
112
|
+
|
|
113
|
+
if (this.options.get("sink") instanceof Consumer) {
|
|
114
|
+
Map<String, Object> ops = new LinkedHashMap<>();
|
|
115
|
+
for (Map.Entry<String, MetricsBucket> e : this.ops.entrySet()) {
|
|
116
|
+
ops.put(e.getKey(), e.getValue().record());
|
|
117
|
+
}
|
|
118
|
+
Map<String, Object> counters = new LinkedHashMap<>();
|
|
119
|
+
counters.put("total", this.total.record());
|
|
120
|
+
counters.put("ops", ops);
|
|
121
|
+
if (ctx.utility != null && ctx.utility.clean != null) {
|
|
122
|
+
Map<String, Object> cleaned = Helpers.toMapAny(ctx.utility.clean.apply(ctx, counters));
|
|
123
|
+
counters = cleaned == null ? counters : cleaned;
|
|
124
|
+
}
|
|
125
|
+
// A failing sink never changes the operation's outcome.
|
|
126
|
+
try {
|
|
127
|
+
((Consumer<Map<String, Object>>) this.options.get("sink")).accept(counters);
|
|
128
|
+
} catch (RuntimeException e) {
|
|
129
|
+
}
|
|
130
|
+
}
|
|
100
131
|
}
|
|
101
132
|
|
|
102
133
|
private void bump(MetricsBucket bucket, boolean ok, long dur) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package JAVAPACKAGE.feature;
|
|
2
2
|
|
|
3
|
+
import java.net.URLDecoder;
|
|
4
|
+
import java.nio.charset.StandardCharsets;
|
|
3
5
|
import java.util.LinkedHashMap;
|
|
4
6
|
import java.util.LinkedHashSet;
|
|
5
7
|
import java.util.List;
|
|
@@ -81,6 +83,10 @@ public class PagingFeature extends BaseFeature {
|
|
|
81
83
|
if (cursor != null) {
|
|
82
84
|
spec.query.put(cursorParam, cursor);
|
|
83
85
|
}
|
|
86
|
+
else if (paging.get("next") instanceof String
|
|
87
|
+
&& !foreign((String) paging.get("next"), spec.base)) {
|
|
88
|
+
follow(spec, (String) paging.get("next"));
|
|
89
|
+
}
|
|
84
90
|
else if (spec.query.get(pageParam) == null) {
|
|
85
91
|
// A record written back by preResult holds the page just fetched as
|
|
86
92
|
// "page" and the one to fetch as "nextPage", so nextPage wins.
|
|
@@ -214,8 +220,13 @@ public class PagingFeature extends BaseFeature {
|
|
|
214
220
|
// Body-level signals; snake_case forms are read first so camelCase wins.
|
|
215
221
|
if (body instanceof Map) {
|
|
216
222
|
Map<String, Object> bm = (Map<String, Object>) body;
|
|
217
|
-
if (bm.get("next") != null
|
|
218
|
-
|
|
223
|
+
if (bm.get("next") != null) {
|
|
224
|
+
if (!isLink(bm.get("next"), FeatureOptions.foptStr(this.options, "next", "auto"))) {
|
|
225
|
+
paging.put("cursor", bm.get("next"));
|
|
226
|
+
}
|
|
227
|
+
else if (paging.get("next") == null) {
|
|
228
|
+
paging.put("next", bm.get("next"));
|
|
229
|
+
}
|
|
219
230
|
}
|
|
220
231
|
if (bm.get("next_cursor") != null) {
|
|
221
232
|
paging.put("cursor", bm.get("next_cursor"));
|
|
@@ -248,6 +259,17 @@ public class PagingFeature extends BaseFeature {
|
|
|
248
259
|
}
|
|
249
260
|
}
|
|
250
261
|
|
|
262
|
+
// A link to another origin is recorded, never followed, and ends the walk.
|
|
263
|
+
String base = ctx.spec != null ? ctx.spec.base
|
|
264
|
+
: ctx.options != null && ctx.options.get("base") instanceof String
|
|
265
|
+
? (String) ctx.options.get("base") : "";
|
|
266
|
+
if (paging.get("next") instanceof String && ctx.spec != null) {
|
|
267
|
+
paging.put("next", resolve((String) paging.get("next"), ctx.spec.url));
|
|
268
|
+
}
|
|
269
|
+
if (paging.get("next") instanceof String && foreign((String) paging.get("next"), base)) {
|
|
270
|
+
paging.put("foreign", paging.remove("next"));
|
|
271
|
+
}
|
|
272
|
+
|
|
251
273
|
// Cursor presence only INFERS another page. When the server stated the
|
|
252
274
|
// answer outright — relay's `hasNextPage: false`, or a body `hasMore` —
|
|
253
275
|
// that wins: a final page normally carries both an end cursor and
|
|
@@ -259,6 +281,11 @@ public class PagingFeature extends BaseFeature {
|
|
|
259
281
|
paging.put("hasMore", true);
|
|
260
282
|
}
|
|
261
283
|
|
|
284
|
+
if (paging.get("foreign") != null && paging.get("cursor") == null
|
|
285
|
+
&& paging.get("nextPage") == null) {
|
|
286
|
+
paging.put("hasMore", false);
|
|
287
|
+
}
|
|
288
|
+
|
|
262
289
|
result.paging = paging;
|
|
263
290
|
this.last = paging;
|
|
264
291
|
|
|
@@ -281,6 +308,133 @@ public class PagingFeature extends BaseFeature {
|
|
|
281
308
|
}
|
|
282
309
|
}
|
|
283
310
|
|
|
311
|
+
private static final Pattern ORIGIN =
|
|
312
|
+
Pattern.compile("^[a-z][a-z0-9+.-]*://[^/?#]*", Pattern.CASE_INSENSITIVE);
|
|
313
|
+
|
|
314
|
+
// Under the `next` option's default, a URL or an absolute path is a link
|
|
315
|
+
// and anything else a cursor; `cursor` and `url` pin the reading.
|
|
316
|
+
static boolean isLink(Object next, String mode) {
|
|
317
|
+
if (!(next instanceof String)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return "url".equals(mode) || (!"cursor".equals(mode)
|
|
321
|
+
&& (ORIGIN.matcher((String) next).find() || ((String) next).startsWith("/")));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
static String origin(String text) {
|
|
325
|
+
Matcher m = ORIGIN.matcher(text == null ? "" : text);
|
|
326
|
+
return m.find() ? m.group().toLowerCase(java.util.Locale.ROOT) : "";
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
static boolean foreign(String link, String base) {
|
|
330
|
+
String origin = origin(link);
|
|
331
|
+
return !origin.isEmpty() && !origin.equals(origin(base));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private static final Pattern SCHEME =
|
|
335
|
+
Pattern.compile("^[a-z][a-z0-9+.-]*:", Pattern.CASE_INSENSITIVE);
|
|
336
|
+
|
|
337
|
+
// RFC 3986 reference resolution against the URL of the request that
|
|
338
|
+
// returned the link, by hand: java.net.URI resolves a query-only reference
|
|
339
|
+
// by RFC 2396 and drops the last path segment. A link on that URL's origin
|
|
340
|
+
// comes back as its path and query; an absolute link is left as it is.
|
|
341
|
+
static String resolve(String link, String url) {
|
|
342
|
+
if (url == null || url.isEmpty() || SCHEME.matcher(link).find()) {
|
|
343
|
+
return link;
|
|
344
|
+
}
|
|
345
|
+
link = link.split("#", 2)[0];
|
|
346
|
+
Matcher om = ORIGIN.matcher(url);
|
|
347
|
+
String origin = om.find() ? om.group() : "";
|
|
348
|
+
if (link.startsWith("//")) {
|
|
349
|
+
return origin.isEmpty() ? link : origin.split(":", 2)[0] + ":" + link;
|
|
350
|
+
}
|
|
351
|
+
String[] from = url.substring(origin.length()).split("#", 2)[0].split("\\?", 2);
|
|
352
|
+
String[] ref = link.split("\\?", 2);
|
|
353
|
+
String path;
|
|
354
|
+
String query;
|
|
355
|
+
if (ref[0].isEmpty()) {
|
|
356
|
+
path = from[0];
|
|
357
|
+
query = link.contains("?") ? (ref.length > 1 ? ref[1] : "") : (from.length > 1 ? from[1] : null);
|
|
358
|
+
} else {
|
|
359
|
+
query = link.contains("?") ? (ref.length > 1 ? ref[1] : "") : null;
|
|
360
|
+
String merged = ref[0];
|
|
361
|
+
if (!merged.startsWith("/")) {
|
|
362
|
+
int k = from[0].lastIndexOf('/');
|
|
363
|
+
merged = (k < 0 ? "" : from[0].substring(0, k + 1)) + merged;
|
|
364
|
+
}
|
|
365
|
+
path = removeDots(merged);
|
|
366
|
+
}
|
|
367
|
+
if (!path.startsWith("/")) {
|
|
368
|
+
path = "/" + path;
|
|
369
|
+
}
|
|
370
|
+
return query == null ? path : path + "?" + query;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// RFC 3986 section 5.2.4.
|
|
374
|
+
static String removeDots(String path) {
|
|
375
|
+
boolean abs = path.startsWith("/");
|
|
376
|
+
String[] segs = path.split("/", -1);
|
|
377
|
+
java.util.ArrayList<String> out = new java.util.ArrayList<>();
|
|
378
|
+
for (int i = abs ? 1 : 0; i < segs.length; i++) {
|
|
379
|
+
String seg = segs[i];
|
|
380
|
+
if (".".equals(seg) || "..".equals(seg)) {
|
|
381
|
+
if ("..".equals(seg) && !out.isEmpty()) {
|
|
382
|
+
out.remove(out.size() - 1);
|
|
383
|
+
}
|
|
384
|
+
if (i == segs.length - 1) {
|
|
385
|
+
out.add("");
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
out.add(seg);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return (abs ? "/" : "") + String.join("/", out);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// The request goes to the link's path and query, on the SDK's own origin.
|
|
395
|
+
static void follow(Spec spec, String next) {
|
|
396
|
+
String rest = ORIGIN.matcher(next).replaceFirst("");
|
|
397
|
+
int hash = rest.indexOf('#');
|
|
398
|
+
if (hash >= 0) {
|
|
399
|
+
rest = rest.substring(0, hash);
|
|
400
|
+
}
|
|
401
|
+
int mark = rest.indexOf('?');
|
|
402
|
+
String path = mark < 0 ? rest : rest.substring(0, mark);
|
|
403
|
+
String rawquery = mark < 0 ? "" : rest.substring(mark + 1);
|
|
404
|
+
|
|
405
|
+
Map<String, Object> query = new LinkedHashMap<>();
|
|
406
|
+
for (String pair : rawquery.split("&")) {
|
|
407
|
+
if (pair.isEmpty()) {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
int eq = pair.indexOf('=');
|
|
411
|
+
String key = eq < 0 ? pair : pair.substring(0, eq);
|
|
412
|
+
String val = eq < 0 ? "" : pair.substring(eq + 1);
|
|
413
|
+
query.put(unescape(key), unescape(val));
|
|
414
|
+
}
|
|
415
|
+
if (spec.authquery != null) {
|
|
416
|
+
for (String key : spec.authquery) {
|
|
417
|
+
query.put(key, spec.query.get(key));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
Matcher origin = ORIGIN.matcher(spec.base == null ? "" : spec.base);
|
|
422
|
+
spec.base = origin.find() ? origin.group() : "";
|
|
423
|
+
spec.prefix = "";
|
|
424
|
+
spec.path = path;
|
|
425
|
+
spec.suffix = "";
|
|
426
|
+
spec.query = query;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
private static String unescape(String text) {
|
|
430
|
+
try {
|
|
431
|
+
return URLDecoder.decode(text, StandardCharsets.UTF_8);
|
|
432
|
+
}
|
|
433
|
+
catch (IllegalArgumentException e) {
|
|
434
|
+
return text;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
284
438
|
private boolean isList(Context ctx) {
|
|
285
439
|
String opname = "";
|
|
286
440
|
if (ctx.op != null) {
|
|
@@ -51,29 +51,31 @@ public class RatelimitFeature extends BaseFeature {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
private void acquire() {
|
|
54
|
+
int wait = reserve();
|
|
55
|
+
if (wait > 0) {
|
|
56
|
+
FeatureOptions.foptSleep(this.options).accept(wait);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Refill, then reserve this call's token before any wait, under the lock:
|
|
61
|
+
// a negative count is the calls already queued, so overlapping calls pace
|
|
62
|
+
// in turn.
|
|
63
|
+
private synchronized int reserve() {
|
|
54
64
|
double rate = FeatureOptions.foptNum(this.options, "rate", 5);
|
|
55
65
|
double burst = FeatureOptions.foptNum(this.options, "burst", rate);
|
|
56
66
|
|
|
57
|
-
// Refill according to elapsed time.
|
|
58
67
|
long now = FeatureOptions.foptNow(this.options).getAsLong();
|
|
59
68
|
long elapsed = now - this.last;
|
|
60
69
|
this.last = now;
|
|
61
|
-
this.tokens = Math.min(burst, this.tokens + (elapsed / 1000.0) * rate);
|
|
70
|
+
this.tokens = Math.min(burst, this.tokens + (elapsed / 1000.0) * rate) - 1;
|
|
62
71
|
|
|
63
|
-
if (this.tokens >=
|
|
64
|
-
|
|
65
|
-
return;
|
|
72
|
+
if (this.tokens >= 0) {
|
|
73
|
+
return 0;
|
|
66
74
|
}
|
|
67
75
|
|
|
68
|
-
|
|
69
|
-
double needed = 1 - this.tokens;
|
|
70
|
-
int wait = (int) Math.ceil((needed / rate) * 1000);
|
|
76
|
+
int wait = (int) Math.ceil((-this.tokens / rate) * 1000);
|
|
71
77
|
track(wait);
|
|
72
|
-
|
|
73
|
-
FeatureOptions.foptSleep(this.options).accept(wait);
|
|
74
|
-
}
|
|
75
|
-
this.last = FeatureOptions.foptNow(this.options).getAsLong();
|
|
76
|
-
this.tokens = 0;
|
|
78
|
+
return wait;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
private void track(int wait) {
|
|
@@ -5,6 +5,11 @@ import java.util.LinkedHashMap;
|
|
|
5
5
|
import java.util.List;
|
|
6
6
|
import java.util.Map;
|
|
7
7
|
import java.util.concurrent.ThreadLocalRandom;
|
|
8
|
+
import java.util.regex.Matcher;
|
|
9
|
+
import java.util.regex.Pattern;
|
|
10
|
+
import java.time.DateTimeException;
|
|
11
|
+
import java.time.LocalDateTime;
|
|
12
|
+
import java.time.ZoneOffset;
|
|
8
13
|
|
|
9
14
|
import JAVAPACKAGE.core.Context;
|
|
10
15
|
import JAVAPACKAGE.core.SdkClient;
|
|
@@ -105,7 +110,7 @@ public class RetryFeature extends BaseFeature {
|
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
private int backoff(Object res, int attempt, int minDelay, int maxDelay, double factor) {
|
|
108
|
-
//
|
|
113
|
+
// A server-provided Retry-After wins over the computed backoff.
|
|
109
114
|
int ra = retryAfter(res);
|
|
110
115
|
if (ra >= 0) {
|
|
111
116
|
return Math.min(ra, maxDelay);
|
|
@@ -120,15 +125,37 @@ public class RetryFeature extends BaseFeature {
|
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
private int retryAfter(Object res) {
|
|
123
|
-
|
|
124
|
-
|
|
128
|
+
return retryAfterMs(FeatureOptions.fresHeader(res, "retry-after"), System.currentTimeMillis());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private static final String MONTHS = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
|
132
|
+
|
|
133
|
+
private static final Pattern IMF_FIXDATE = Pattern.compile(
|
|
134
|
+
"(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), ([0-9]{2}) ([A-Z][a-z]{2}) ([0-9]{4}) "
|
|
135
|
+
+ "([0-9]{2}):([0-9]{2}):([0-9]{2}) GMT");
|
|
136
|
+
|
|
137
|
+
// RFC 9110 Retry-After: delay-seconds or an IMF-fixdate, else -1.
|
|
138
|
+
static int retryAfterMs(String value, long now) {
|
|
139
|
+
String s = value.replaceAll("^[ \\t]+|[ \\t]+$", "");
|
|
140
|
+
if (s.matches("[0-9]+")) {
|
|
141
|
+
return s.length() > 6 ? Integer.MAX_VALUE : Integer.parseInt(s) * 1000;
|
|
142
|
+
}
|
|
143
|
+
Matcher m = IMF_FIXDATE.matcher(s);
|
|
144
|
+
int month = m.matches() ? MONTHS.indexOf(m.group(2)) : -1;
|
|
145
|
+
if (month < 0 || month % 3 != 0) {
|
|
125
146
|
return -1;
|
|
126
147
|
}
|
|
127
|
-
int
|
|
128
|
-
|
|
148
|
+
int sec = Integer.parseInt(m.group(6));
|
|
149
|
+
try {
|
|
150
|
+
long at = LocalDateTime.of(Integer.parseInt(m.group(3)), month / 3 + 1,
|
|
151
|
+
Integer.parseInt(m.group(1)), Integer.parseInt(m.group(4)),
|
|
152
|
+
Integer.parseInt(m.group(5)), Math.min(sec, 59))
|
|
153
|
+
.toEpochSecond(ZoneOffset.UTC) * 1000 + (sec > 59 ? 1000 : 0);
|
|
154
|
+
return (int) Math.min(Integer.MAX_VALUE, Math.max(0, at - now));
|
|
155
|
+
}
|
|
156
|
+
catch (DateTimeException e) {
|
|
129
157
|
return -1;
|
|
130
158
|
}
|
|
131
|
-
return seconds * 1000;
|
|
132
159
|
}
|
|
133
160
|
|
|
134
161
|
private void sleep(int ms) {
|
|
@@ -42,8 +42,9 @@ public class StreamingFeature extends BaseFeature {
|
|
|
42
42
|
if (!this.active || !streamable(ctx)) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
+
// A failed result keeps no stream, so the entity's stream() raises its error.
|
|
45
46
|
final Result result = ctx.result;
|
|
46
|
-
if (result == null) {
|
|
47
|
+
if (result == null || result.err != null) {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package JAVAPACKAGE.feature;
|
|
2
2
|
|
|
3
|
+
import java.security.SecureRandom;
|
|
3
4
|
import java.util.ArrayList;
|
|
4
5
|
import java.util.LinkedHashMap;
|
|
5
6
|
import java.util.List;
|
|
@@ -25,7 +26,6 @@ public class TelemetryFeature extends BaseFeature {
|
|
|
25
26
|
|
|
26
27
|
private SdkClient client;
|
|
27
28
|
private Map<String, Object> options;
|
|
28
|
-
private int seq = 0;
|
|
29
29
|
|
|
30
30
|
// Activity tracking (mirrors the ts client._telemetry record).
|
|
31
31
|
public List<Map<String, Object>> spans = new ArrayList<>();
|
|
@@ -42,7 +42,6 @@ public class TelemetryFeature extends BaseFeature {
|
|
|
42
42
|
this.client = ctx.client;
|
|
43
43
|
this.options = options;
|
|
44
44
|
this.active = FeatureOptions.foptBool(options, "active", false);
|
|
45
|
-
this.seq = 0;
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
@Override
|
|
@@ -141,13 +140,22 @@ public class TelemetryFeature extends BaseFeature {
|
|
|
141
140
|
if (this.options.get("idgen") instanceof Function) {
|
|
142
141
|
return ((Function<String, String>) this.options.get("idgen")).apply(kind);
|
|
143
142
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
return randomHex("trace".equals(kind) ? 16 : 8);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private static final SecureRandom RANDOM = new SecureRandom();
|
|
147
|
+
|
|
148
|
+
// W3C trace context: lowercase hex from the platform's random source, never all zeros.
|
|
149
|
+
private static String randomHex(int bytes) {
|
|
150
|
+
byte[] buf = new byte[bytes];
|
|
151
|
+
StringBuilder out = new StringBuilder();
|
|
152
|
+
while (out.length() == 0 || out.chars().allMatch((c) -> c == '0')) {
|
|
153
|
+
RANDOM.nextBytes(buf);
|
|
154
|
+
out.setLength(0);
|
|
155
|
+
for (byte b : buf) {
|
|
156
|
+
out.append(String.format("%02x", b & 0xff));
|
|
157
|
+
}
|
|
150
158
|
}
|
|
151
|
-
return
|
|
159
|
+
return out.toString();
|
|
152
160
|
}
|
|
153
161
|
}
|