Skip to content

Commit 99e30e1

Browse files
authoredFeb 24, 2022
Refactor job scheduler to use memdb for jobs (hashicorp#782)
* internal/job: Introduce Job & related types * internal/state: Introduce new 'jobs' table * internal/scheduler: Introduce general-purpose job scheduler * internal/terraform/module(watcher+walker): Update references * internal/langserver/handlers: Update references * internal/terraform/module: Remove module manager & loader & queue * internal/terraform/module: Repurpose old mod mgr test cases In the old test we would be checking what *all* schemas are available for a given path after indexing via walker. This part of API is however being deprecated in favour of more straightforward one (see state.ProviderSchemaStore -> ProviderSchema()) which picks the single most appropriate schema from a list of candidates and retains the decision logic as an implementation detail within it, so the whole list of candidates is not really available from the outside (by design), hence not something we should test from the outside. ProviderSchemaStore itself already has plenty of tests testing the decision logic within, which is better place for testing this anyway. * jobs benchmarks
1 parent 726a5fb commit 99e30e1

File tree

68 files changed

+2532
-1538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2532
-1538
lines changed
 

‎internal/cmd/completion_command.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
ilsp "github.com/hashicorp/terraform-ls/internal/lsp"
1919
lsp "github.com/hashicorp/terraform-ls/internal/protocol"
2020
"github.com/hashicorp/terraform-ls/internal/state"
21-
"github.com/hashicorp/terraform-ls/internal/terraform/module"
2221
"github.com/mitchellh/cli"
2322
)
2423

@@ -113,9 +112,7 @@ func (c *CompletionCommand) Run(args []string) int {
113112

114113
ctx := context.Background()
115114

116-
modMgr := module.NewSyncModuleManager(ctx, fs, ss.DocumentStore, ss.Modules, ss.ProviderSchemas)
117-
118-
_, err = modMgr.AddModule(dh.Dir.Path())
115+
err = ss.Modules.Add(dh.Dir.Path())
119116
if err != nil {
120117
c.Ui.Error(err.Error())
121118
return 1

‎internal/cmd/inspect_module_command.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/hashicorp/terraform-ls/internal/logging"
1919
"github.com/hashicorp/terraform-ls/internal/state"
2020
"github.com/hashicorp/terraform-ls/internal/terraform/datadir"
21+
"github.com/hashicorp/terraform-ls/internal/terraform/exec"
2122
"github.com/hashicorp/terraform-ls/internal/terraform/module"
2223
"github.com/mitchellh/cli"
2324
)
@@ -93,10 +94,7 @@ func (c *InspectModuleCommand) inspect(rootPath string) error {
9394

9495
ctx := context.Background()
9596

96-
modMgr := module.NewSyncModuleManager(ctx, fs, ss.DocumentStore, ss.Modules, ss.ProviderSchemas)
97-
modMgr.SetLogger(c.logger)
98-
99-
walker := module.SyncWalker(fs, ss.DocumentStore, modMgr)
97+
walker := module.SyncWalker(fs, ss.DocumentStore, ss.Modules, ss.ProviderSchemas, ss.JobStore, exec.NewExecutor)
10098
walker.SetLogger(c.logger)
10199

102100
ctx, cancel := ictx.WithSignalCancel(context.Background(),
@@ -109,7 +107,7 @@ func (c *InspectModuleCommand) inspect(rootPath string) error {
109107
return err
110108
}
111109

112-
modules, err := modMgr.ListModules()
110+
modules, err := ss.Modules.List()
113111
if err != nil {
114112
return err
115113
}

0 commit comments

Comments
 (0)
Please sign in to comment.