@gitkraken/core-gitlens 0.5.107 → 0.5.108
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/CHANGELOG.md +8 -1
- package/dist/plus/integrations/index.d.ts +1 -1
- package/dist/plus/integrations/index.d.ts.map +1 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +75 -0
- package/dist/plus/integrations/manager.d.ts.map +1 -1
- package/dist/plus/integrations/reads/sweeps.d.ts.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +120 -56
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/package.json +1 -1
- package/src/plus/integrations/index.ts +1 -0
- package/src/plus/integrations/manager.ts +76 -0
- package/src/plus/integrations/reads/sweeps.ts +150 -76
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.5.108] - 2026-08-07
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Adds `onTargetSettled` to both pull-request sweeps (`sweepPullRequests`, `sweepClosedPullRequests`), reporting each target as it settles with its `providerId`, `domain`, `connectionId`, row `count`, `durationMs`, `queueWaitMs`, `truncated` and an `outcome` of `ok` / `fetch-failed` / `failed-provider` / `skipped`. A sweep makes one call and distributes its targets internally, so nothing per-target crossed the package boundary: a host could see that a sweep took eight seconds but not which provider spent them, and per-target counts were only derivable because a sweep accepts at most one target per provider. `outcome` is one value rather than the underlying booleans because "the whole target is unusable" and "the target returned a slice with a gap" are facts a consumer buckets differently, and `skipped` — a target that resolved to no reachable connection — is reported even though it is deliberately absent from the aggregate result, making the event the only place a consumer counting targets can see it. What is deliberately NOT in this: any ability to influence the sweep (the return value is ignored and a synchronous throw is swallowed rather than allowed to turn a fulfilled target into a rejected one), and any cost when omitted, where no reporting exists and no clock is read. One behaviour to know rather than infer: delivery does not stop when the sweep fails, because a rejection does not cancel the siblings already in flight, so their events arrive after the returned promise has rejected. See the `ProviderSweepTargetEvent` and `onTargetSettled` docs for the per-field contract (plus/integrations)
|
|
14
|
+
|
|
9
15
|
## [0.5.107] - 2026-08-07
|
|
10
16
|
|
|
11
17
|
### Changed
|
|
@@ -207,7 +213,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|
|
207
213
|
|
|
208
214
|
- Initial release. Bundles `@gitlens/utils`, `@gitlens/git`, `@gitlens/git-cli`, `@gitlens/ai`, and `@gitlens/git-github` into a single core npm package with subpath exports.
|
|
209
215
|
|
|
210
|
-
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.5.
|
|
216
|
+
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.5.108...HEAD
|
|
217
|
+
[0.5.108]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.5.107...gitkraken:releases/core/v0.5.108
|
|
211
218
|
[0.5.107]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.5.106...gitkraken:releases/core/v0.5.107
|
|
212
219
|
[0.5.106]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.5.105...gitkraken:releases/core/v0.5.106
|
|
213
220
|
[0.5.105]: https://github.com/gitkraken/vscode-gitlens/compare/releases/core/v0.5.104...gitkraken:releases/core/v0.5.105
|
|
@@ -46,7 +46,7 @@ export interface IntegrationManagerContext {
|
|
|
46
46
|
readonly repositories: RepositoriesProvider;
|
|
47
47
|
readonly hooks?: IntegrationServiceHooks;
|
|
48
48
|
}
|
|
49
|
-
export type { ClosedPullRequestSweepOptions, IntegrationManager, ListOrgsOptions, ListProjectsOptions, ProviderBroadenOrg, ProviderRepositoriesInput, ProviderRepositoryInput, ProviderSweepTarget, PullRequestSweepOptions, } from './manager.js';
|
|
49
|
+
export type { ClosedPullRequestSweepOptions, IntegrationManager, ListOrgsOptions, ListProjectsOptions, ProviderBroadenOrg, ProviderRepositoriesInput, ProviderRepositoryInput, ProviderSweepTarget, ProviderSweepTargetEvent, PullRequestSweepOptions, } from './manager.js';
|
|
50
50
|
/**
|
|
51
51
|
* Construct an `@gitkraken/core-gitlens/plus/integrations` manager bound to the supplied runtime.
|
|
52
52
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plus/integrations/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EACX,eAAe,EACf,cAAc,EACd,YAAY,EAEZ,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,6DAA6D;AAC7D,MAAM,MAAM,6BAA6B,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;AAEtF,iDAAiD;AACjD,MAAM,MAAM,6BAA6B,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,KAAK;IAC9E,KAAK,EAAE,6BAA6B,CAAC,CAAC,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,gFAAgF;AAChF,MAAM,WAAW,iCAAiC;IACjD,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,4DAA4D;AAC5D,MAAM,WAAW,8BAA8B;IAC9C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,CAAC,E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AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,OAAO,EACN,6BAA6B,GAE7B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACN,yBAAyB,EACzB,+BAA+B,EAC/B,4BAA4B,EAC5B,eAAe,EACf,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AAwBxB,iGAAiG;AACjG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -37,6 +37,62 @@ export interface ProviderSweepTarget {
|
|
|
37
37
|
*/
|
|
38
38
|
filters?: PullRequestFilter[];
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* One target's contribution to a pull-request sweep, reported as it settles.
|
|
42
|
+
*
|
|
43
|
+
* A sweep makes a single call and distributes its targets internally, so its aggregate result carries no
|
|
44
|
+
* per-target timing at all and only derivable per-target counts. This is the boundary that exposes them, for a
|
|
45
|
+
* host attributing a slow or failing sweep to the provider responsible.
|
|
46
|
+
*
|
|
47
|
+
* `outcome` is reported as one value rather than the underlying booleans because a consumer buckets by it, and
|
|
48
|
+
* because "the whole target is unusable" and "the target returned a slice with a gap" are different facts:
|
|
49
|
+
* a `failed-provider` target contributes nothing, a `fetch-failed` one contributes `count` rows that are
|
|
50
|
+
* incomplete. `skipped` is a target that resolved to no reachable connection and is deliberately not
|
|
51
|
+
* attributed in the aggregate result — reported anyway so a consumer counting targets never loses one.
|
|
52
|
+
*
|
|
53
|
+
* A target that produced no slice at all reports `count: 0` and `truncated: false` — always for `skipped`, and
|
|
54
|
+
* for `failed-provider` as `drainPullRequests` reports it today. Read those fields rather than deriving them
|
|
55
|
+
* from `outcome`: they are the target's own values, not constants the outcome guarantees.
|
|
56
|
+
*/
|
|
57
|
+
export interface ProviderSweepTargetEvent {
|
|
58
|
+
providerId: IntegrationIds;
|
|
59
|
+
/**
|
|
60
|
+
* The self-managed host this target selects, resolved from its configured connection, its explicit domain,
|
|
61
|
+
* or the provider's primary configured host — the same rule the read itself uses, and the same one whether
|
|
62
|
+
* the target drained fully or was rejected by the first guard.
|
|
63
|
+
*
|
|
64
|
+
* Always `undefined` for a cloud provider: it has a single host, so there is nothing to disambiguate. Group
|
|
65
|
+
* by `providerId` and treat this as a label, not part of the key.
|
|
66
|
+
*/
|
|
67
|
+
domain: string | undefined;
|
|
68
|
+
connectionId: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Rows this target contributed to the aggregate result. The sweep concatenates target slices without a
|
|
71
|
+
* cross-target pass — duplicates are collapsed per target, across its own pages — so these sum to exactly
|
|
72
|
+
* `items.length`, and a sum that disagrees means a target went unreported.
|
|
73
|
+
*/
|
|
74
|
+
count: number;
|
|
75
|
+
/**
|
|
76
|
+
* Wall time from this target's worker picking it up to its slice being ready.
|
|
77
|
+
*
|
|
78
|
+
* Targets in the same sweep run concurrently, so these intervals OVERLAP and are not additive: summing them
|
|
79
|
+
* across a sweep exceeds the sweep's own duration. Compare them against each other, not against a total.
|
|
80
|
+
*/
|
|
81
|
+
durationMs: number;
|
|
82
|
+
/**
|
|
83
|
+
* Wall time between the fan-out starting and this target's worker picking the target up.
|
|
84
|
+
*
|
|
85
|
+
* Structurally 0 only while the target count fits the fan-out's concurrency limit, which a selection of a
|
|
86
|
+
* few providers does and the default sweep does NOT: with no `targets`/`providerIds` it opens one target per
|
|
87
|
+
* supported git host, more than the limit, so the last ones genuinely wait. A non-zero value there is the
|
|
88
|
+
* normal case, not an anomaly — it is the cost of the bound, and only worth acting on if it rivals
|
|
89
|
+
* `durationMs`.
|
|
90
|
+
*/
|
|
91
|
+
queueWaitMs: number;
|
|
92
|
+
outcome: 'ok' | 'failed-provider' | 'fetch-failed' | 'skipped';
|
|
93
|
+
/** Whether this target left pages unread. */
|
|
94
|
+
truncated: boolean;
|
|
95
|
+
}
|
|
40
96
|
type ProviderSweepSelection = {
|
|
41
97
|
targets: readonly ProviderSweepTarget[];
|
|
42
98
|
providerIds?: never;
|
|
@@ -79,6 +135,25 @@ type PullRequestSweepCommonOptions = {
|
|
|
79
135
|
includeReviewRequested?: boolean;
|
|
80
136
|
forceSync?: boolean;
|
|
81
137
|
maxPages?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Fired once per target as it settles, for host-side per-provider attribution.
|
|
140
|
+
*
|
|
141
|
+
* Observation only: it cannot influence the sweep, and a SYNCHRONOUS throw is swallowed rather than allowed
|
|
142
|
+
* to turn a successful target into a failed one. Return nothing and do no async work: the `void` return type
|
|
143
|
+
* admits an `async` callback, but nothing awaits it, so a rejection from one escapes that guarantee as an
|
|
144
|
+
* unhandled rejection. It is also invoked synchronously in the middle of the fan-out — do not re-enter the
|
|
145
|
+
* manager from it.
|
|
146
|
+
*
|
|
147
|
+
* Omitting it costs nothing at all, not even a clock read, so a host that only measures behind a gate can
|
|
148
|
+
* leave the gate off without paying for the option.
|
|
149
|
+
*
|
|
150
|
+
* It reports how a target SETTLED, not every way one can end, and **delivery does not stop when the sweep
|
|
151
|
+
* fails**: if a target's read throws instead of reporting failure through its slice, the sweep rejects with
|
|
152
|
+
* that error, but its sibling targets are already in flight and are not cancelled, so their events still
|
|
153
|
+
* arrive — after the returned promise has rejected. Key the accumulator to the call rather than closing it
|
|
154
|
+
* on rejection, or a late event lands in whatever bucket is current by then.
|
|
155
|
+
*/
|
|
156
|
+
onTargetSettled?: (event: ProviderSweepTargetEvent) => void;
|
|
82
157
|
};
|
|
83
158
|
export type PullRequestSweepOptions = PullRequestSweepCommonOptions & ProviderSweepSelection;
|
|
84
159
|
export type ClosedPullRequestSweepOptions = Omit<PullRequestSweepCommonOptions, 'states'> & ProviderSweepSelection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/plus/integrations/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,KAAK,EACX,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACt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K,
|
|
1
|
+
{"version":3,"file":"sweeps.d.ts","sourceRoot":"","sources":["../../../../src/plus/integrations/reads/sweeps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAI3E,OAAO,KAAK,EACX,6BAA6B,EAG7B,uBAAuB,EACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,eAAe,CAAC;AAG1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAwKxD,wBAAsB,iBAAiB,CACtC,GAAG,EAAE,mBAAmB,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAC/B,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CA8DhD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,mBAAmB,EACxB,OAAO,CAAC,EAAE,6BAA6B,GACrC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAEhD"}
|
|
@@ -6,65 +6,129 @@ import { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integr
|
|
|
6
6
|
import { drainPullRequests, getCurrentAccountId, resolvePullRequestSweepTargets } from './drains.js';
|
|
7
7
|
import { resolveAccountWidePullRequestFilters, resolvePullRequestFilters } from './filters.js';
|
|
8
8
|
import { gitHostOnlySurfaceWarning, noConnectionWarning, unsupportedAccountWidePullRequestFiltersWarning, unsupportedFiltersWarning, } from './warnings.js';
|
|
9
|
+
/**
|
|
10
|
+
* Drain ONE sweep target. Extracted from the fan-out so the fan-out callback has a single exit: every
|
|
11
|
+
* per-target observation (see `onTargetSettled`) is then reported in one place instead of at each of this
|
|
12
|
+
* function's several early returns, where a missed branch would silently drop a provider's attribution.
|
|
13
|
+
*
|
|
14
|
+
* `undefined` means the target resolved to no reachable connection and is deliberately not attributed in the
|
|
15
|
+
* aggregate result.
|
|
16
|
+
*/
|
|
17
|
+
async function sweepTarget(ctx, options, target, attributeUnavailableProviders) {
|
|
18
|
+
const { providerId: id, connectionId, domain: requestedDomain } = target;
|
|
19
|
+
const repos = options?.repos ?? [];
|
|
20
|
+
const maxPages = options?.maxPages ?? 100;
|
|
21
|
+
/** A target that never reached a drain: the provider itself failed, so its slice is empty and attributed. */
|
|
22
|
+
const rejectedTarget = (warnings) => ({
|
|
23
|
+
items: [],
|
|
24
|
+
warnings: warnings,
|
|
25
|
+
fetchFailed: true,
|
|
26
|
+
truncated: false,
|
|
27
|
+
providerId: id,
|
|
28
|
+
failedProvider: true,
|
|
29
|
+
});
|
|
30
|
+
if (isIssuesHostIntegrationId(id)) {
|
|
31
|
+
return rejectedTarget([gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps')]);
|
|
32
|
+
}
|
|
33
|
+
const integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);
|
|
34
|
+
if (integration == null) {
|
|
35
|
+
// A requested connection that can't be resolved is a broken connection — surface it as a
|
|
36
|
+
// warning + fetchFailed rather than dropping the provider's slice silently.
|
|
37
|
+
const early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);
|
|
38
|
+
if (early.warnings.length === 0 && !attributeUnavailableProviders)
|
|
39
|
+
return undefined;
|
|
40
|
+
return rejectedTarget(early.warnings.length !== 0 ? early.warnings : [noConnectionWarning(id, requestedDomain, connectionId)]);
|
|
41
|
+
}
|
|
42
|
+
if (!isGitHostIntegration(integration)) {
|
|
43
|
+
return rejectedTarget([gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps')]);
|
|
44
|
+
}
|
|
45
|
+
await ctx.forceRefreshIfRequested(integration, options?.forceSync, connectionId);
|
|
46
|
+
const domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);
|
|
47
|
+
const accountWide = repos.length === 0;
|
|
48
|
+
const requestedFilters = target.filters ?? options?.filters;
|
|
49
|
+
const resolved = accountWide
|
|
50
|
+
? resolveAccountWidePullRequestFilters(id, requestedFilters)
|
|
51
|
+
: resolvePullRequestFilters(id, requestedFilters);
|
|
52
|
+
if (resolved.unsupported) {
|
|
53
|
+
return rejectedTarget([
|
|
54
|
+
accountWide
|
|
55
|
+
? unsupportedAccountWidePullRequestFiltersWarning(id, domain, connectionId, requestedFilters ?? [])
|
|
56
|
+
: unsupportedFiltersWarning(id, domain, connectionId),
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
const drain = await drainPullRequests(integration, id, domain, repos, options?.states, resolved.filters, accountWide ? (options?.includeReviewRequested ?? false) : false, connectionId, maxPages, attributeUnavailableProviders);
|
|
60
|
+
const currentAccountId = drain.items.some(pr => pr.author != null)
|
|
61
|
+
? await getCurrentAccountId(integration, connectionId)
|
|
62
|
+
: undefined;
|
|
63
|
+
// Normalize the raw provider-apis PRs to the GitLens-owned shape here, where the per-provider
|
|
64
|
+
// `integration` (the mapper's provider reference) is in scope; the aggregation below only sees drains.
|
|
65
|
+
return {
|
|
66
|
+
...drain,
|
|
67
|
+
items: drain.items.map(pr => fromProviderPullRequest(pr, integration, { currentAccountId: currentAccountId })),
|
|
68
|
+
providerId: id,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* How a target ended, as the consumer buckets it. `failedProvider` outranks `fetchFailed` because a target
|
|
73
|
+
* whose provider failed produced no slice to be partial about, and `undefined` is the target that resolved to
|
|
74
|
+
* no reachable connection at all.
|
|
75
|
+
*/
|
|
76
|
+
function sliceOutcome(slice) {
|
|
77
|
+
if (slice == null)
|
|
78
|
+
return 'skipped';
|
|
79
|
+
if (slice.failedProvider)
|
|
80
|
+
return 'failed-provider';
|
|
81
|
+
if (slice.fetchFailed)
|
|
82
|
+
return 'fetch-failed';
|
|
83
|
+
return 'ok';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Per-target reporting for a sweep's `onTargetSettled`, opened once per sweep: this stamps the fan-out start,
|
|
87
|
+
* the returned function stamps one target's start, and the function IT returns is the only thing that can
|
|
88
|
+
* report that target. The timestamps therefore never cross a boundary, so there is no pair of interchangeable
|
|
89
|
+
* numbers for a call site to transpose, and the whole reporting concern is one value the fan-out either has or
|
|
90
|
+
* does not. That is also what keeps the option free when it is omitted: with no observer there is nothing to
|
|
91
|
+
* open, so no clock is read and no reporting object exists — do not "simplify" that into an unconditional
|
|
92
|
+
* open, because a host whose perf gate is off (the default) is entitled to pay nothing for it.
|
|
93
|
+
*
|
|
94
|
+
* The try/catch is what makes the observer observation-only: called from the fan-out's success path, a throwing
|
|
95
|
+
* callback would otherwise propagate out of the `mapBounded` task and reject the entire sweep — corrupting the
|
|
96
|
+
* read, not just the metric. Swallowed silently; the consumer owns its own aggregation.
|
|
97
|
+
*
|
|
98
|
+
* The domain is resolved here rather than carried out of {@link sweepTarget}, so every target reports it by the
|
|
99
|
+
* same rule no matter how far it got. `resolveDomainForRead` needs no integration instance, which is what makes
|
|
100
|
+
* that possible: a target rejected by the first guard resolves the same host a fully drained one does.
|
|
101
|
+
*/
|
|
102
|
+
function startSweepReporting(ctx, observe) {
|
|
103
|
+
const fanOutStartedAt = performance.now();
|
|
104
|
+
return function beginTarget(target) {
|
|
105
|
+
const startedAt = performance.now();
|
|
106
|
+
return function reportSettled(slice) {
|
|
107
|
+
try {
|
|
108
|
+
observe({
|
|
109
|
+
providerId: target.providerId,
|
|
110
|
+
domain: ctx.resolveDomainForRead(target.providerId, target.connectionId, target.domain),
|
|
111
|
+
connectionId: target.connectionId,
|
|
112
|
+
count: slice?.items.length ?? 0,
|
|
113
|
+
durationMs: performance.now() - startedAt,
|
|
114
|
+
queueWaitMs: startedAt - fanOutStartedAt,
|
|
115
|
+
outcome: sliceOutcome(slice),
|
|
116
|
+
truncated: slice?.truncated ?? false,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch { }
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
}
|
|
9
123
|
export async function sweepPullRequests(ctx, options) {
|
|
10
124
|
const { targets, attributeUnavailableProviders } = resolvePullRequestSweepTargets(options);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
125
|
+
const observe = options?.onTargetSettled;
|
|
126
|
+
const beginTarget = observe != null ? startSweepReporting(ctx, observe) : undefined;
|
|
13
127
|
const results = await mapBounded(targets, providerFanOutConcurrency, async (target) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
warnings: warnings,
|
|
19
|
-
fetchFailed: true,
|
|
20
|
-
truncated: false,
|
|
21
|
-
providerId: id,
|
|
22
|
-
failedProvider: true,
|
|
23
|
-
});
|
|
24
|
-
if (isIssuesHostIntegrationId(id)) {
|
|
25
|
-
return rejectedTarget([
|
|
26
|
-
gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps'),
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
const integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);
|
|
30
|
-
if (integration == null) {
|
|
31
|
-
// A requested connection that can't be resolved is a broken connection — surface it as a
|
|
32
|
-
// warning + fetchFailed rather than dropping the provider's slice silently.
|
|
33
|
-
const early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);
|
|
34
|
-
if (early.warnings.length === 0 && !attributeUnavailableProviders)
|
|
35
|
-
return undefined;
|
|
36
|
-
return rejectedTarget(early.warnings.length !== 0 ? early.warnings : [noConnectionWarning(id, requestedDomain, connectionId)]);
|
|
37
|
-
}
|
|
38
|
-
if (!isGitHostIntegration(integration)) {
|
|
39
|
-
return rejectedTarget([
|
|
40
|
-
gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps'),
|
|
41
|
-
]);
|
|
42
|
-
}
|
|
43
|
-
await ctx.forceRefreshIfRequested(integration, options?.forceSync, connectionId);
|
|
44
|
-
const domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);
|
|
45
|
-
const accountWide = repos.length === 0;
|
|
46
|
-
const requestedFilters = target.filters ?? options?.filters;
|
|
47
|
-
const resolved = accountWide
|
|
48
|
-
? resolveAccountWidePullRequestFilters(id, requestedFilters)
|
|
49
|
-
: resolvePullRequestFilters(id, requestedFilters);
|
|
50
|
-
if (resolved.unsupported) {
|
|
51
|
-
return rejectedTarget([
|
|
52
|
-
accountWide
|
|
53
|
-
? unsupportedAccountWidePullRequestFiltersWarning(id, domain, connectionId, requestedFilters ?? [])
|
|
54
|
-
: unsupportedFiltersWarning(id, domain, connectionId),
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
const drain = await drainPullRequests(integration, id, domain, repos, options?.states, resolved.filters, accountWide ? (options?.includeReviewRequested ?? false) : false, connectionId, maxPages, attributeUnavailableProviders);
|
|
58
|
-
const currentAccountId = drain.items.some(pr => pr.author != null)
|
|
59
|
-
? await getCurrentAccountId(integration, connectionId)
|
|
60
|
-
: undefined;
|
|
61
|
-
// Normalize the raw provider-apis PRs to the GitLens-owned shape here, where the per-provider
|
|
62
|
-
// `integration` (the mapper's provider reference) is in scope; the aggregation below only sees drains.
|
|
63
|
-
return {
|
|
64
|
-
...drain,
|
|
65
|
-
items: drain.items.map(pr => fromProviderPullRequest(pr, integration, { currentAccountId: currentAccountId })),
|
|
66
|
-
providerId: id,
|
|
67
|
-
};
|
|
128
|
+
const reportSettled = beginTarget?.(target);
|
|
129
|
+
const slice = await sweepTarget(ctx, options, target, attributeUnavailableProviders);
|
|
130
|
+
reportSettled?.(slice);
|
|
131
|
+
return slice;
|
|
68
132
|
});
|
|
69
133
|
const items = [];
|
|
70
134
|
const warnings = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sweeps.js","sourceRoot":"","sources":["../../../../src/plus/integrations/reads/sweeps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"sweeps.js","sourceRoot":"","sources":["../../../../src/pl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ACjD,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACrB,SAAS,GAAG,IAAI,CAAC;QAClB,CAAC;IACF,CAAC;IAED,OAAO;QACN,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,QAAQ;QAClB,gGAAgG;QAChG,8FAA8F;QAC9F,mFAAmF;QACnF,IAAI,EAAE;YACL,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,KAAK,CAAC,MAAM;YAC1B,QAAQ,EAAE,CAAC,SAAS,IAAI,CAAC,WAAW;YACpC,SAAS,EAAE,SAAS,IAAI,SAAS;SACjC;QACD,qGAAqG;QACrG,gGAAgG;QAChG,qGAAqG;QACrG,0EAA0E;QAC1E,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,WAAW,IAAI,SAAS;QACrC,iBAAiB,EAAE,CAAC,GAAG,iBAAiB,CAAC;QACzC,qBAAqB,EAAE,CAAC,GAAG,qBAAqB,CAAC;KACjD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAwB,EACxB,OAAuC;IAEvC,OAAO,iBAAiB,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/core-gitlens",
|
|
3
3
|
"description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.108",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|
|
@@ -59,6 +59,63 @@ export interface ProviderSweepTarget {
|
|
|
59
59
|
filters?: PullRequestFilter[];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* One target's contribution to a pull-request sweep, reported as it settles.
|
|
64
|
+
*
|
|
65
|
+
* A sweep makes a single call and distributes its targets internally, so its aggregate result carries no
|
|
66
|
+
* per-target timing at all and only derivable per-target counts. This is the boundary that exposes them, for a
|
|
67
|
+
* host attributing a slow or failing sweep to the provider responsible.
|
|
68
|
+
*
|
|
69
|
+
* `outcome` is reported as one value rather than the underlying booleans because a consumer buckets by it, and
|
|
70
|
+
* because "the whole target is unusable" and "the target returned a slice with a gap" are different facts:
|
|
71
|
+
* a `failed-provider` target contributes nothing, a `fetch-failed` one contributes `count` rows that are
|
|
72
|
+
* incomplete. `skipped` is a target that resolved to no reachable connection and is deliberately not
|
|
73
|
+
* attributed in the aggregate result — reported anyway so a consumer counting targets never loses one.
|
|
74
|
+
*
|
|
75
|
+
* A target that produced no slice at all reports `count: 0` and `truncated: false` — always for `skipped`, and
|
|
76
|
+
* for `failed-provider` as `drainPullRequests` reports it today. Read those fields rather than deriving them
|
|
77
|
+
* from `outcome`: they are the target's own values, not constants the outcome guarantees.
|
|
78
|
+
*/
|
|
79
|
+
export interface ProviderSweepTargetEvent {
|
|
80
|
+
providerId: IntegrationIds;
|
|
81
|
+
/**
|
|
82
|
+
* The self-managed host this target selects, resolved from its configured connection, its explicit domain,
|
|
83
|
+
* or the provider's primary configured host — the same rule the read itself uses, and the same one whether
|
|
84
|
+
* the target drained fully or was rejected by the first guard.
|
|
85
|
+
*
|
|
86
|
+
* Always `undefined` for a cloud provider: it has a single host, so there is nothing to disambiguate. Group
|
|
87
|
+
* by `providerId` and treat this as a label, not part of the key.
|
|
88
|
+
*/
|
|
89
|
+
domain: string | undefined;
|
|
90
|
+
connectionId: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Rows this target contributed to the aggregate result. The sweep concatenates target slices without a
|
|
93
|
+
* cross-target pass — duplicates are collapsed per target, across its own pages — so these sum to exactly
|
|
94
|
+
* `items.length`, and a sum that disagrees means a target went unreported.
|
|
95
|
+
*/
|
|
96
|
+
count: number;
|
|
97
|
+
/**
|
|
98
|
+
* Wall time from this target's worker picking it up to its slice being ready.
|
|
99
|
+
*
|
|
100
|
+
* Targets in the same sweep run concurrently, so these intervals OVERLAP and are not additive: summing them
|
|
101
|
+
* across a sweep exceeds the sweep's own duration. Compare them against each other, not against a total.
|
|
102
|
+
*/
|
|
103
|
+
durationMs: number;
|
|
104
|
+
/**
|
|
105
|
+
* Wall time between the fan-out starting and this target's worker picking the target up.
|
|
106
|
+
*
|
|
107
|
+
* Structurally 0 only while the target count fits the fan-out's concurrency limit, which a selection of a
|
|
108
|
+
* few providers does and the default sweep does NOT: with no `targets`/`providerIds` it opens one target per
|
|
109
|
+
* supported git host, more than the limit, so the last ones genuinely wait. A non-zero value there is the
|
|
110
|
+
* normal case, not an anomaly — it is the cost of the bound, and only worth acting on if it rivals
|
|
111
|
+
* `durationMs`.
|
|
112
|
+
*/
|
|
113
|
+
queueWaitMs: number;
|
|
114
|
+
outcome: 'ok' | 'failed-provider' | 'fetch-failed' | 'skipped';
|
|
115
|
+
/** Whether this target left pages unread. */
|
|
116
|
+
truncated: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
62
119
|
type ProviderSweepSelection =
|
|
63
120
|
| {
|
|
64
121
|
targets: readonly ProviderSweepTarget[];
|
|
@@ -105,6 +162,25 @@ type PullRequestSweepCommonOptions = {
|
|
|
105
162
|
includeReviewRequested?: boolean;
|
|
106
163
|
forceSync?: boolean;
|
|
107
164
|
maxPages?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Fired once per target as it settles, for host-side per-provider attribution.
|
|
167
|
+
*
|
|
168
|
+
* Observation only: it cannot influence the sweep, and a SYNCHRONOUS throw is swallowed rather than allowed
|
|
169
|
+
* to turn a successful target into a failed one. Return nothing and do no async work: the `void` return type
|
|
170
|
+
* admits an `async` callback, but nothing awaits it, so a rejection from one escapes that guarantee as an
|
|
171
|
+
* unhandled rejection. It is also invoked synchronously in the middle of the fan-out — do not re-enter the
|
|
172
|
+
* manager from it.
|
|
173
|
+
*
|
|
174
|
+
* Omitting it costs nothing at all, not even a clock read, so a host that only measures behind a gate can
|
|
175
|
+
* leave the gate off without paying for the option.
|
|
176
|
+
*
|
|
177
|
+
* It reports how a target SETTLED, not every way one can end, and **delivery does not stop when the sweep
|
|
178
|
+
* fails**: if a target's read throws instead of reporting failure through its slice, the sweep rejects with
|
|
179
|
+
* that error, but its sibling targets are already in flight and are not cancelled, so their events still
|
|
180
|
+
* arrive — after the returned promise has rejected. Key the accumulator to the call rather than closing it
|
|
181
|
+
* on rejection, or a late event lands in whatever bucket is current by then.
|
|
182
|
+
*/
|
|
183
|
+
onTargetSettled?: (event: ProviderSweepTargetEvent) => void;
|
|
108
184
|
};
|
|
109
185
|
|
|
110
186
|
export type PullRequestSweepOptions = PullRequestSweepCommonOptions & ProviderSweepSelection;
|
|
@@ -2,7 +2,12 @@ import type { PullRequestShape } from '../../../git/models/pullRequest.js';
|
|
|
2
2
|
import { mapBounded } from '../../../utils/promise.js';
|
|
3
3
|
import type { IntegrationIds } from '../constants.js';
|
|
4
4
|
import { providerFanOutConcurrency } from '../constants.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
ClosedPullRequestSweepOptions,
|
|
7
|
+
ProviderSweepTarget,
|
|
8
|
+
ProviderSweepTargetEvent,
|
|
9
|
+
PullRequestSweepOptions,
|
|
10
|
+
} from '../manager.js';
|
|
6
11
|
import { fromProviderPullRequest } from '../providers/models.js';
|
|
7
12
|
import type { ProviderSweepResult, ProviderWarning } from '../results.js';
|
|
8
13
|
import { appendDedupedWarning } from '../results.js';
|
|
@@ -37,89 +42,158 @@ interface SweepSlice {
|
|
|
37
42
|
failedProvider: boolean;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Drain ONE sweep target. Extracted from the fan-out so the fan-out callback has a single exit: every
|
|
47
|
+
* per-target observation (see `onTargetSettled`) is then reported in one place instead of at each of this
|
|
48
|
+
* function's several early returns, where a missed branch would silently drop a provider's attribution.
|
|
49
|
+
*
|
|
50
|
+
* `undefined` means the target resolved to no reachable connection and is deliberately not attributed in the
|
|
51
|
+
* aggregate result.
|
|
52
|
+
*/
|
|
53
|
+
async function sweepTarget(
|
|
41
54
|
ctx: ProviderReadContext,
|
|
42
|
-
options
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
options: PullRequestSweepOptions | undefined,
|
|
56
|
+
target: ProviderSweepTarget,
|
|
57
|
+
attributeUnavailableProviders: boolean,
|
|
58
|
+
): Promise<SweepSlice | undefined> {
|
|
59
|
+
const { providerId: id, connectionId, domain: requestedDomain } = target;
|
|
46
60
|
const repos = options?.repos ?? [];
|
|
61
|
+
const maxPages = options?.maxPages ?? 100;
|
|
62
|
+
/** A target that never reached a drain: the provider itself failed, so its slice is empty and attributed. */
|
|
63
|
+
const rejectedTarget = (warnings: ProviderWarning[]): SweepSlice => ({
|
|
64
|
+
items: [],
|
|
65
|
+
warnings: warnings,
|
|
66
|
+
fetchFailed: true,
|
|
67
|
+
truncated: false,
|
|
68
|
+
providerId: id,
|
|
69
|
+
failedProvider: true,
|
|
70
|
+
});
|
|
47
71
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const rejectedTarget = (warnings: ProviderWarning[]): SweepSlice => ({
|
|
52
|
-
items: [],
|
|
53
|
-
warnings: warnings,
|
|
54
|
-
fetchFailed: true,
|
|
55
|
-
truncated: false,
|
|
56
|
-
providerId: id,
|
|
57
|
-
failedProvider: true,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (isIssuesHostIntegrationId(id)) {
|
|
61
|
-
return rejectedTarget([
|
|
62
|
-
gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps'),
|
|
63
|
-
]);
|
|
64
|
-
}
|
|
72
|
+
if (isIssuesHostIntegrationId(id)) {
|
|
73
|
+
return rejectedTarget([gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps')]);
|
|
74
|
+
}
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
const integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);
|
|
77
|
+
if (integration == null) {
|
|
78
|
+
// A requested connection that can't be resolved is a broken connection — surface it as a
|
|
79
|
+
// warning + fetchFailed rather than dropping the provider's slice silently.
|
|
80
|
+
const early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);
|
|
81
|
+
if (early.warnings.length === 0 && !attributeUnavailableProviders) return undefined;
|
|
72
82
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
83
|
+
return rejectedTarget(
|
|
84
|
+
early.warnings.length !== 0 ? early.warnings : [noConnectionWarning(id, requestedDomain, connectionId)],
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (!isGitHostIntegration(integration)) {
|
|
88
|
+
return rejectedTarget([gitHostOnlySurfaceWarning(id, requestedDomain, connectionId, 'pull request sweeps')]);
|
|
89
|
+
}
|
|
82
90
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);
|
|
86
|
-
const accountWide = repos.length === 0;
|
|
87
|
-
const requestedFilters = target.filters ?? options?.filters;
|
|
88
|
-
const resolved = accountWide
|
|
89
|
-
? resolveAccountWidePullRequestFilters(id, requestedFilters)
|
|
90
|
-
: resolvePullRequestFilters(id, requestedFilters);
|
|
91
|
-
if (resolved.unsupported) {
|
|
92
|
-
return rejectedTarget([
|
|
93
|
-
accountWide
|
|
94
|
-
? unsupportedAccountWidePullRequestFiltersWarning(id, domain, connectionId, requestedFilters ?? [])
|
|
95
|
-
: unsupportedFiltersWarning(id, domain, connectionId),
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
91
|
+
await ctx.forceRefreshIfRequested(integration, options?.forceSync, connectionId);
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
const domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);
|
|
94
|
+
const accountWide = repos.length === 0;
|
|
95
|
+
const requestedFilters = target.filters ?? options?.filters;
|
|
96
|
+
const resolved = accountWide
|
|
97
|
+
? resolveAccountWidePullRequestFilters(id, requestedFilters)
|
|
98
|
+
: resolvePullRequestFilters(id, requestedFilters);
|
|
99
|
+
if (resolved.unsupported) {
|
|
100
|
+
return rejectedTarget([
|
|
101
|
+
accountWide
|
|
102
|
+
? unsupportedAccountWidePullRequestFiltersWarning(id, domain, connectionId, requestedFilters ?? [])
|
|
103
|
+
: unsupportedFiltersWarning(id, domain, connectionId),
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const drain = await drainPullRequests(
|
|
108
|
+
integration,
|
|
109
|
+
id,
|
|
110
|
+
domain,
|
|
111
|
+
repos,
|
|
112
|
+
options?.states,
|
|
113
|
+
resolved.filters,
|
|
114
|
+
accountWide ? (options?.includeReviewRequested ?? false) : false,
|
|
115
|
+
connectionId,
|
|
116
|
+
maxPages,
|
|
117
|
+
attributeUnavailableProviders,
|
|
118
|
+
);
|
|
119
|
+
const currentAccountId = drain.items.some(pr => pr.author != null)
|
|
120
|
+
? await getCurrentAccountId(integration, connectionId)
|
|
121
|
+
: undefined;
|
|
122
|
+
// Normalize the raw provider-apis PRs to the GitLens-owned shape here, where the per-provider
|
|
123
|
+
// `integration` (the mapper's provider reference) is in scope; the aggregation below only sees drains.
|
|
124
|
+
return {
|
|
125
|
+
...drain,
|
|
126
|
+
items: drain.items.map(pr => fromProviderPullRequest(pr, integration, { currentAccountId: currentAccountId })),
|
|
127
|
+
providerId: id,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* How a target ended, as the consumer buckets it. `failedProvider` outranks `fetchFailed` because a target
|
|
133
|
+
* whose provider failed produced no slice to be partial about, and `undefined` is the target that resolved to
|
|
134
|
+
* no reachable connection at all.
|
|
135
|
+
*/
|
|
136
|
+
function sliceOutcome(slice: SweepSlice | undefined): ProviderSweepTargetEvent['outcome'] {
|
|
137
|
+
if (slice == null) return 'skipped';
|
|
138
|
+
if (slice.failedProvider) return 'failed-provider';
|
|
139
|
+
if (slice.fetchFailed) return 'fetch-failed';
|
|
140
|
+
return 'ok';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Per-target reporting for a sweep's `onTargetSettled`, opened once per sweep: this stamps the fan-out start,
|
|
145
|
+
* the returned function stamps one target's start, and the function IT returns is the only thing that can
|
|
146
|
+
* report that target. The timestamps therefore never cross a boundary, so there is no pair of interchangeable
|
|
147
|
+
* numbers for a call site to transpose, and the whole reporting concern is one value the fan-out either has or
|
|
148
|
+
* does not. That is also what keeps the option free when it is omitted: with no observer there is nothing to
|
|
149
|
+
* open, so no clock is read and no reporting object exists — do not "simplify" that into an unconditional
|
|
150
|
+
* open, because a host whose perf gate is off (the default) is entitled to pay nothing for it.
|
|
151
|
+
*
|
|
152
|
+
* The try/catch is what makes the observer observation-only: called from the fan-out's success path, a throwing
|
|
153
|
+
* callback would otherwise propagate out of the `mapBounded` task and reject the entire sweep — corrupting the
|
|
154
|
+
* read, not just the metric. Swallowed silently; the consumer owns its own aggregation.
|
|
155
|
+
*
|
|
156
|
+
* The domain is resolved here rather than carried out of {@link sweepTarget}, so every target reports it by the
|
|
157
|
+
* same rule no matter how far it got. `resolveDomainForRead` needs no integration instance, which is what makes
|
|
158
|
+
* that possible: a target rejected by the first guard resolves the same host a fully drained one does.
|
|
159
|
+
*/
|
|
160
|
+
function startSweepReporting(ctx: ProviderReadContext, observe: (event: ProviderSweepTargetEvent) => void) {
|
|
161
|
+
const fanOutStartedAt = performance.now();
|
|
162
|
+
|
|
163
|
+
return function beginTarget(target: ProviderSweepTarget) {
|
|
164
|
+
const startedAt = performance.now();
|
|
165
|
+
|
|
166
|
+
return function reportSettled(slice: SweepSlice | undefined) {
|
|
167
|
+
try {
|
|
168
|
+
observe({
|
|
169
|
+
providerId: target.providerId,
|
|
170
|
+
domain: ctx.resolveDomainForRead(target.providerId, target.connectionId, target.domain),
|
|
171
|
+
connectionId: target.connectionId,
|
|
172
|
+
count: slice?.items.length ?? 0,
|
|
173
|
+
durationMs: performance.now() - startedAt,
|
|
174
|
+
queueWaitMs: startedAt - fanOutStartedAt,
|
|
175
|
+
outcome: sliceOutcome(slice),
|
|
176
|
+
truncated: slice?.truncated ?? false,
|
|
177
|
+
});
|
|
178
|
+
} catch {}
|
|
122
179
|
};
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export async function sweepPullRequests(
|
|
184
|
+
ctx: ProviderReadContext,
|
|
185
|
+
options?: PullRequestSweepOptions,
|
|
186
|
+
): Promise<ProviderSweepResult<PullRequestShape>> {
|
|
187
|
+
const { targets, attributeUnavailableProviders } = resolvePullRequestSweepTargets(options);
|
|
188
|
+
|
|
189
|
+
const observe = options?.onTargetSettled;
|
|
190
|
+
const beginTarget = observe != null ? startSweepReporting(ctx, observe) : undefined;
|
|
191
|
+
|
|
192
|
+
const results = await mapBounded(targets, providerFanOutConcurrency, async target => {
|
|
193
|
+
const reportSettled = beginTarget?.(target);
|
|
194
|
+
const slice = await sweepTarget(ctx, options, target, attributeUnavailableProviders);
|
|
195
|
+
reportSettled?.(slice);
|
|
196
|
+
return slice;
|
|
123
197
|
});
|
|
124
198
|
|
|
125
199
|
const items: PullRequestShape[] = [];
|