Conversation
src/system/SystemTypes.ts
Outdated
|
|
||
| export type ReadinessStatus = { | ||
| ready: boolean; | ||
| reason?: string; |
There was a problem hiding this comment.
Removed reason field
src/system/SystemTypes.ts
Outdated
| currentSettings: Settings; | ||
| }; | ||
|
|
||
| export const GetSystemStatusRequestType = new RequestType<void, GetSystemStatusResponse, void>('aws/cfn/system/status'); |
src/settings/SettingsManager.ts
Outdated
| return this.settingsState.toSettings(); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Is this comment required?
src/settings/SettingsManager.ts
Outdated
| @Telemetry() private readonly telemetry!: ScopedTelemetry; | ||
| private readonly settingsState = new SettingsState(); | ||
| private readonly subscriptionManager = new SubscriptionManager<Settings>(); | ||
| private isUpdatingSettings = false; |
There was a problem hiding this comment.
I think we need to know "has settings initialized or updated atleast once" - any workspace change or settings change will make this true, but that doesn't exactly say if the system is ready
There was a problem hiding this comment.
Modified isUpdatingSettings to instead be a settingsReady, it is initially set to false. If the syncConfiguration is completed successfully as part of the initializedHandler, the settings will be marked as ready. Upon making a settings update, settings readiness is set to false until the update successfully completes.
src/settings/SettingsManager.ts
Outdated
| this.settingsState.update(newSettings); | ||
| logger.info(`Settings updated: ${toString(difference)}`); | ||
| this.subscriptionManager.notify(newSettings, oldSettings); | ||
| this.isUpdatingSettings = true; |
There was a problem hiding this comment.
Even if nothing has changed if settings have been synced atleast once, then settings are ready
There was a problem hiding this comment.
Modified isUpdatingSettings to instead be a settingsReady, it is initially set to false. If the syncConfiguration is completed successfully as part of the initializedHandler, the settings will be marked as ready. Upon making a settings update, settings readiness is set to false until the update successfully completes.
src/services/guard/GuardService.ts
Outdated
| /** | ||
| * Get the readiness status of the Guard service | ||
| */ | ||
| public getReadinessStatus(): { ready: boolean; reason?: string } { |
|
For settings and lint initializations, can the initialize handler be used? |
Yes, made updates so that:
|
d77c62f to
39e76a4
Compare
src/system/SystemTypes.ts
Outdated
| import { RequestType } from 'vscode-languageserver-protocol'; | ||
| import { Settings } from '../settings/Settings'; | ||
|
|
||
| export type ReadinessStatus = { |
There was a problem hiding this comment.
We're creating a new folder src/system just for these two types. Can we move this to src/protocol or inside src/protocol/LspSystemHandlers.ts. We already have tons of directories inside src. Would be good to avoid adding another one with 1 file, 2 types.
There was a problem hiding this comment.
Deleted folder and moved types to LspSystemHandler.ts
src/protocol/LspSystemHandlers.ts
Outdated
| export class LspSystemHandlers { | ||
| constructor(private readonly connection: Connection) {} | ||
|
|
||
| onGetSystemStatus(handler: ServerRequestHandler<void, GetSystemStatusResponse, never, void>) { |
There was a problem hiding this comment.
Why not just RequestHandler? We're not using progress reporter
There was a problem hiding this comment.
Changed method to use RequestHandler
src/handlers/SystemHandler.ts
Outdated
| const reason = settingsStatus.reason ?? 'Server initializing'; | ||
| return { | ||
| settingsReady: settingsStatus, | ||
| schemasReady: { ready: false, reason, availableRegions: [] }, |
There was a problem hiding this comment.
Adding extra key to ReadinessStatus type just for schemas. Is this needed?
There was a problem hiding this comment.
Removed extra key, availableRegions is no longer supplied
src/handlers/SystemHandler.ts
Outdated
| schemasReady: { | ||
| availableRegions: [...availableRegions], | ||
| ready: availableRegions.length > 0, | ||
| ...(availableRegions.length === 0 ? { reason: 'No schemas loaded' } : {}), |
There was a problem hiding this comment.
I am not finding reason to be a helpful field. It might be simpler to keep the status response as just a ready or not flag.
There was a problem hiding this comment.
Removed reason from status response
Design Feedback: Interface-based ReadinessThe current implementation has each component (
The handler also contains aggregation logic (settings not ready → short-circuit all others as not ready), which is business logic that doesn't belong in a request handler. Proposed:
|
ba53669 to
ac8cc03
Compare
Added the ReadinessContributor interface and modified the services to implement it. I didn't add SystemReadiness because the handler was concise enough |
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.