@utaba/deep-memory-storage-cosmosdb 0.12.1 → 0.14.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/dist/index.cjs CHANGED
@@ -1132,6 +1132,7 @@ var DEFAULT_START = 5;
1132
1132
  var DEFAULT_MAX = 32;
1133
1133
  var DEFAULT_INCREASE_AFTER = 50;
1134
1134
  var DEFAULT_COOLDOWN_MS = 1e3;
1135
+ var DEFAULT_RAMP_UP_COOLDOWN_MS = 5e3;
1135
1136
  var DEFAULT_MAX_CONSECUTIVE_THROTTLES_AT_MIN = 10;
1136
1137
  var DEFAULT_THROTTLE_CEILING_MULTIPLIER = 3;
1137
1138
  var NO_SOFT_CEILING = Number.POSITIVE_INFINITY;
@@ -1141,6 +1142,7 @@ function resolveOptions(opts) {
1141
1142
  const start = Math.min(max, Math.max(min, opts?.start ?? DEFAULT_START));
1142
1143
  const increaseAfter = Math.max(1, opts?.increaseAfter ?? DEFAULT_INCREASE_AFTER);
1143
1144
  const cooldownMs = Math.max(0, opts?.cooldownMs ?? DEFAULT_COOLDOWN_MS);
1145
+ const rampUpCooldownMs = Math.max(0, opts?.rampUpCooldownMs ?? DEFAULT_RAMP_UP_COOLDOWN_MS);
1144
1146
  const maxConsecutiveThrottlesAtMin = Math.max(
1145
1147
  1,
1146
1148
  opts?.maxConsecutiveThrottlesAtMin ?? DEFAULT_MAX_CONSECUTIVE_THROTTLES_AT_MIN
@@ -1155,6 +1157,7 @@ function resolveOptions(opts) {
1155
1157
  max,
1156
1158
  increaseAfter,
1157
1159
  cooldownMs,
1160
+ rampUpCooldownMs,
1158
1161
  maxConsecutiveThrottlesAtMin,
1159
1162
  throttleCeilingMultiplier,
1160
1163
  onAdjust: opts?.onAdjust
@@ -1175,6 +1178,7 @@ var AdaptiveConcurrencyController = class {
1175
1178
  current;
1176
1179
  streak = 0;
1177
1180
  cooldownUntil = 0;
1181
+ rampFrozenUntil = 0;
1178
1182
  completed = 0;
1179
1183
  throttled = 0;
1180
1184
  startEmitted = false;
@@ -1225,10 +1229,11 @@ var AdaptiveConcurrencyController = class {
1225
1229
  this.notify("start", this.current);
1226
1230
  }
1227
1231
  /** Record a throttle-free task completion. May trigger ramp-up. */
1228
- noteSuccess() {
1232
+ noteSuccess(now = Date.now()) {
1229
1233
  this.completed++;
1230
- this.streak++;
1231
1234
  this.consecutiveThrottlesAtMin = 0;
1235
+ if (now < this.rampFrozenUntil) return;
1236
+ this.streak++;
1232
1237
  if (this.current >= this.opts.max) return;
1233
1238
  const target = this.current + 1;
1234
1239
  const needed = target >= this.softCeiling ? this.opts.increaseAfter * this.opts.throttleCeilingMultiplier : this.opts.increaseAfter;
@@ -1250,6 +1255,7 @@ var AdaptiveConcurrencyController = class {
1250
1255
  const previous = this.current;
1251
1256
  const next = Math.max(this.opts.min, Math.floor(this.current / 2));
1252
1257
  this.cooldownUntil = now + this.opts.cooldownMs;
1258
+ this.rampFrozenUntil = now + this.opts.rampUpCooldownMs;
1253
1259
  if (next !== previous) {
1254
1260
  this.current = next;
1255
1261
  this.softCeiling = previous;
@@ -2215,35 +2221,9 @@ var CosmosDbProvider = class {
2215
2221
  return this.track("executeNativeQuery", void 0, () => this.executeNativeQueryImpl(query, params));
2216
2222
  }
2217
2223
  async executeNativeQueryImpl(query, params) {
2218
- const startTime = Date.now();
2219
2224
  try {
2220
2225
  const result = await this.conn.submit(query, params);
2221
- const executionTimeMs = Date.now() - startTime;
2222
- const entities = [];
2223
- for (const item of result.items) {
2224
- try {
2225
- const entity = entityFromGremlin(item);
2226
- if (entity.id) {
2227
- entities.push(entity);
2228
- }
2229
- } catch {
2230
- }
2231
- }
2232
- const queryMetadata = {
2233
- executionTimeMs,
2234
- resourceCost: result.requestCharge != null ? { units: "RU", value: result.requestCharge } : void 0,
2235
- compiledQuery: query,
2236
- compiledQueryLanguage: "gremlin",
2237
- appliedLimits: { maxResults: entities.length },
2238
- truncated: false
2239
- };
2240
- return {
2241
- entities,
2242
- total: entities.length,
2243
- returned: entities.length,
2244
- hasMore: false,
2245
- queryMetadata
2246
- };
2226
+ return result.items;
2247
2227
  } catch (err) {
2248
2228
  throw new import_deep_memory6.ProviderError(
2249
2229
  `Native Gremlin query failed: ${err instanceof Error ? err.message : String(err)}`,