-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathServiceConfiguration.ts
More file actions
224 lines (221 loc) · 7.37 KB
/
Copy pathServiceConfiguration.ts
File metadata and controls
224 lines (221 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the
* repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { LSPRequestType } from '../queue';
import { Priority, getLogger } from '@salesforce/apex-lsp-shared';
/**
* Service configuration interface
*/
export interface ServiceConfig {
requestType: LSPRequestType;
priority: Priority;
timeout: number;
maxRetries: number;
serviceFactory: (dependencies: any) => any;
}
/**
* Default service configuration
*/
export const DEFAULT_SERVICE_CONFIG: ServiceConfig[] = [
{
requestType: 'hover',
priority: Priority.Immediate,
timeout: 5000,
maxRetries: 0,
serviceFactory: (deps) => deps.serviceFactory.createHoverService(),
},
{
requestType: 'completion',
priority: Priority.Immediate,
// Match CompletionHandler's progressive-completion budget. The
// distributed request-pool path performs cursor compilation and targeted
// dependency loading before producing a CompletionList; cancelling it at
// 100ms discarded useful work and bypassed the handler's incomplete-list
// fallback.
timeout: 2000,
maxRetries: 0,
serviceFactory: (deps) => deps.serviceFactory.createCompletionService(),
},
{
requestType: 'signatureHelp',
priority: Priority.Immediate,
timeout: 1000,
maxRetries: 0,
serviceFactory: (deps) => deps.serviceFactory.createSignatureHelpService(),
},
{
requestType: 'definition',
priority: Priority.High,
// The request-pool path loads the cursor symbol subset, resolves
// dependencies, performs strict/full enrichment, and writes enriched data
// back to the data-owner before replying. The former local-service budget
// of 1s cancelled correct distributed results while that work was still in
// progress, especially when tracing was enabled.
timeout: 5000,
maxRetries: 1,
serviceFactory: (deps) => deps.serviceFactory.createDefinitionService(),
},
{
requestType: 'documentSymbol',
priority: Priority.High,
timeout: 5000,
maxRetries: 1,
serviceFactory: (deps) => deps.serviceFactory.createDocumentSymbolService(),
},
{
requestType: 'documentOpen',
priority: Priority.High,
timeout: 1000,
maxRetries: 1,
serviceFactory: (deps) =>
deps.serviceFactory.createDocumentProcessingService(),
},
{
requestType: 'documentLoad',
priority: Priority.High,
timeout: 2000,
maxRetries: 1,
serviceFactory: (deps) => deps.serviceFactory.createDocumentLoadService(),
},
{
requestType: 'findMissingArtifact',
priority: Priority.Low,
timeout: 30000,
maxRetries: 1,
serviceFactory: (deps) =>
deps.serviceFactory.createMissingArtifactService(),
},
{
requestType: 'references',
priority: Priority.Low,
// Find All References runs a workspace-wide two-phase search: a lexical
// prefilter on the data-owner, then a FULL-detail recompile of every
// candidate file on the request-pool worker so in-body call edges resolve.
// That recompile is intrinsically heavier than the old public-api path
// (~6-10s on dreamhouse-lwc's GeocodingServiceTest, dominated by
// addSymbolTable's finalResolve/sameFileRefs phases — W-23272674). The
// former 5s budget fired mid-recompile and discarded a correct result;
// 15s matches the diagnostics budget, the comparable heavy cross-file
// operation. maxRetries is 0: a timeout here means the recompile genuinely
// needs more than the budget, and re-running the same deterministic work
// only multiplies the cost (the wasted 3x recompiles seen in traces). The
// addSymbolTable phase-trim that would let this drop back toward 5s is
// tracked separately (project-findreferences-addtable-bottleneck).
timeout: 15000,
maxRetries: 0,
// References are normally answered by the request-pool worker's two-phase
// scan. This config entry also registers the priority/timeout the worker
// dispatch derives from `getTimeout('references')`. LSPQueueManager CAN
// still fall through to this local handler on the cold-start race (worker
// not yet wired, cold-read gate not ready, or a dispatch error). This stub
// returns an empty result plus a WARN rather than running the removed local
// discovery, because that old local path silently returned incomplete
// results. The throw that used to live here never reached the user anyway
// (LCSAdapter catches it and returns null), so an empty result + warn is
// the honest equivalent without the misleading server-log error.
serviceFactory: () => ({
processReferences: async () => {
getLogger().warn(
() =>
'Local references handler was invoked, so the request-pool worker ' +
'dispatch was bypassed (cold-start race, cold-read gate not ready, ' +
'or dispatch error). References are normally served by the ' +
'request-pool worker; returning an empty result.',
);
return [];
},
}),
},
{
requestType: 'diagnostics',
priority: Priority.Normal,
timeout: 15000,
maxRetries: 2,
serviceFactory: (deps) => deps.serviceFactory.createDiagnosticService(),
},
{
requestType: 'workspaceSymbol',
priority: Priority.Normal,
timeout: 5000,
maxRetries: 2,
serviceFactory: (deps) =>
deps.serviceFactory.createWorkspaceSymbolService(),
},
{
requestType: 'documentSave',
priority: Priority.Normal,
timeout: 5000,
maxRetries: 2,
serviceFactory: (deps) =>
deps.serviceFactory.createDocumentSaveProcessingService(),
},
{
requestType: 'documentChange',
priority: Priority.Normal,
timeout: 5000,
maxRetries: 2,
serviceFactory: (deps) =>
deps.serviceFactory.createDocumentChangeProcessingService(),
},
{
requestType: 'implementation',
priority: Priority.High,
timeout: 1000,
maxRetries: 1,
serviceFactory: (deps) => deps.serviceFactory.createImplementationService(),
},
{
requestType: 'foldingRange',
priority: Priority.Low,
timeout: 5000,
maxRetries: 0,
serviceFactory: (deps) => deps.serviceFactory.createFoldingRangeService(),
},
{
requestType: 'codeLens',
priority: Priority.Low,
timeout: 5000,
maxRetries: 0,
serviceFactory: (deps) => deps.serviceFactory.createCodeLensService(),
},
{
requestType: 'codeAction',
priority: Priority.Low,
timeout: 30000,
maxRetries: 3,
serviceFactory: (deps) => deps.serviceFactory.createCodeActionService(),
},
{
requestType: 'rename',
priority: Priority.Low,
timeout: 30000,
maxRetries: 3,
serviceFactory: (deps) => deps.serviceFactory.createRenameService(),
},
{
requestType: 'documentClose',
priority: Priority.Immediate,
timeout: 100,
maxRetries: 0,
serviceFactory: (deps) => deps.serviceFactory.createDocumentSymbolService(),
},
{
requestType: 'executeCommand',
priority: Priority.Normal,
timeout: 5000,
maxRetries: 1,
serviceFactory: (deps) => deps.serviceFactory.createExecuteCommandService(),
},
{
requestType: 'prerequisiteEnrichment',
priority: Priority.Background,
timeout: 60000,
maxRetries: 0,
serviceFactory: (deps) =>
deps.serviceFactory.createPrerequisiteEnrichmentService(),
},
];