Allow subscribing to updates of module.calls
data
#722
Labels
enhancement
New feature or request
good first issue
Good for newcomers
modules
Functionality related to the module block and modules generally
workspace/executeCommand
Milestone
Depends on #723
Use-cases
#632 introduced a custom command to allow clients obtain data about module calls. Clients may call this command repeatedly at any time and it's relatively cheap to do so. However the client may not necessarily know when is the right time to do so.
Clients should be able to "subscribe" to receive data updates whenever this data changes.
Attempted Solutions
Clients ask repeatedly - can lead to either excessive amount of requests and/or outdated info.
Proposal
The server already has mechanisms allowing it to detect state changes which affect the data returned from
module.calls
via hooksterraform-ls/internal/state/hooks.go
Lines 3 to 11 in 2027413
We can introduce additional optional argument
update-command-id
alongsideuri
terraform-ls/internal/langserver/handlers/command/module_calls.go
Line 32 in 2027413
which clients can use to register a particular client-side command ID which the server will call and pass updated data that way.
Alternatively we could follow the LSP spec a bit more closely and use that command just to trigger client-side re-reading of data, i.e. have client call
module.calls
again. This does require another RPC roundtrip, but aligns more with e.g. semantic tokens or code lens refresh.Implementation Notes
We can try to calculate the response before sending and compare hash that client could also calculate, to avoid sending the duplicate data repeatedly.
The text was updated successfully, but these errors were encountered: