Skip to content

Commit

Permalink
rename modulewatch as just watch
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Oct 2, 2024
1 parent 163d4e3 commit 7f971c1
Show file tree
Hide file tree
Showing 52 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions backend/controller/admin/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

cf "github.com/TBD54566975/ftl/internal/configuration"
"github.com/TBD54566975/ftl/internal/configuration/manager"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/projectconfig"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/watch"
)

// localClient reads and writes to local projectconfig files without making any network
Expand Down Expand Up @@ -40,7 +40,7 @@ func (s *diskSchemaRetriever) GetActiveSchema(ctx context.Context) (*schema.Sche
if err != nil {
return nil, fmt.Errorf("could not load project config: %w", err)
}
modules, err := modulewatch.DiscoverModules(ctx, projConfig.AbsModuleDirs())
modules, err := watch.DiscoverModules(ctx, projConfig.AbsModuleDirs())
if err != nil {
return nil, fmt.Errorf("could not discover modules: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/cli/cmd_schema_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/projectconfig"
"github.com/TBD54566975/ftl/internal/rpc"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/watch"
)

type schemaDiffCmd struct {
Expand Down Expand Up @@ -88,7 +88,7 @@ func localSchema(ctx context.Context, projectConfig projectconfig.Config) (*sche
pb := &schema.Schema{}
found := false
tried := ""
modules, err := modulewatch.DiscoverModules(ctx, projectConfig.AbsModuleDirs())
modules, err := watch.DiscoverModules(ctx, projectConfig.AbsModuleDirs())
if err != nil {
return nil, fmt.Errorf("failed to discover modules %w", err)
}
Expand Down
16 changes: 8 additions & 8 deletions internal/buildengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/moduleconfig"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/rpc"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/slices"
"github.com/TBD54566975/ftl/internal/terminal"
"github.com/TBD54566975/ftl/internal/watch"
)

type CompilerBuildError struct {
Expand Down Expand Up @@ -95,7 +95,7 @@ type Engine struct {
moduleMetas *xsync.MapOf[string, moduleMeta]
projectRoot string
moduleDirs []string
watcher *modulewatch.Watcher // only watches for module toml changes
watcher *watch.Watcher // only watches for module toml changes
controllerSchema *xsync.MapOf[string, *schema.Module]
schemaChanges *pubsub.Topic[schemaChange]
pluginEvents chan PluginEvent
Expand Down Expand Up @@ -157,7 +157,7 @@ func New(ctx context.Context, client DeployClient, projectRoot string, moduleDir
projectRoot: projectRoot,
moduleDirs: moduleDirs,
moduleMetas: xsync.NewMapOf[string, moduleMeta](),
watcher: modulewatch.NewWatcher("ftl.toml"),
watcher: watch.NewWatcher("ftl.toml"),
controllerSchema: xsync.NewMapOf[string, *schema.Module](),
schemaChanges: pubsub.New[schemaChange](),
pluginEvents: make(chan PluginEvent, 128),
Expand All @@ -178,7 +178,7 @@ func New(ctx context.Context, client DeployClient, projectRoot string, moduleDir

go e.listenForBuildUpdates(ctx)

configs, err := modulewatch.DiscoverModules(ctx, moduleDirs)
configs, err := watch.DiscoverModules(ctx, moduleDirs)
if err != nil {
return nil, fmt.Errorf("could not find modules: %w", err)
}
Expand Down Expand Up @@ -399,7 +399,7 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration
e.schemaChanges.Unsubscribe(schemaChanges)
}()

watchEvents := make(chan modulewatch.WatchEvent, 128)
watchEvents := make(chan watch.WatchEvent, 128)
ctx, cancel := context.WithCancel(ctx)
topic, err := e.watcher.Watch(ctx, period, e.moduleDirs)
if err != nil {
Expand Down Expand Up @@ -460,7 +460,7 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration
didUpdateDeployments = false
case event := <-watchEvents:
switch event := event.(type) {
case modulewatch.WatchEventModuleAdded:
case watch.WatchEventModuleAdded:
config := event.Config
if _, exists := e.moduleMetas.Load(config.Module); !exists {
meta, err := e.newModuleMeta(ctx, config, e.projectRoot)
Expand All @@ -479,7 +479,7 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration
didUpdateDeployments = true
}
}
case modulewatch.WatchEventModuleRemoved:
case watch.WatchEventModuleRemoved:
err := terminateModuleDeployment(ctx, e.client, event.Config.Module)
terminal.UpdateModuleState(ctx, event.Config.Module, terminal.BuildStateTerminated)

Expand All @@ -500,7 +500,7 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration
}
}
e.moduleMetas.Delete(event.Config.Module)
case modulewatch.WatchEventModuleChanged:
case watch.WatchEventModuleChanged:
// ftl.toml file has changed
meta, ok := e.moduleMetas.Load(event.Config.Module)
if !ok {
Expand Down
16 changes: 8 additions & 8 deletions internal/buildengine/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"github.com/TBD54566975/ftl/internal/errors"
"github.com/TBD54566975/ftl/internal/flock"
"github.com/TBD54566975/ftl/internal/moduleconfig"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/projectconfig"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/watch"
)

const BuildLockTimeout = time.Minute
Expand Down Expand Up @@ -120,7 +120,7 @@ type getDependenciesCommand struct {

func (getDependenciesCommand) pluginCmd() {}

type buildFunc = func(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction modulewatch.ModifyFilesTransaction) error
type buildFunc = func(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction watch.ModifyFilesTransaction) error

// internalPlugin is used by languages that have not been split off into their own external plugins yet.
// It has standard behaviours around building and watching files.
Expand Down Expand Up @@ -206,8 +206,8 @@ func (p *internalPlugin) getDependencies(ctx context.Context, d dependenciesFunc
}

func (p *internalPlugin) run(ctx context.Context) {
watcher := modulewatch.NewWatcher(p.config.Watch...)
watchChan := make(chan modulewatch.WatchEvent, 128)
watcher := watch.NewWatcher(p.config.Watch...)
watchChan := make(chan watch.WatchEvent, 128)

// State
// This is updated when given explicit build commands and used for automatic rebuilds
Expand Down Expand Up @@ -257,7 +257,7 @@ func (p *internalPlugin) run(ctx context.Context) {
}
case event := <-watchChan:
switch event.(type) {
case modulewatch.WatchEventModuleChanged:
case watch.WatchEventModuleChanged:
// automatic rebuild

p.updates.Publish(AutoRebuildStartedEvent{Module: p.config.Module})
Expand All @@ -273,10 +273,10 @@ func (p *internalPlugin) run(ctx context.Context) {
Module: p.config.Module,
Result: either.LeftOf[error](result),
})
case modulewatch.WatchEventModuleAdded:
case watch.WatchEventModuleAdded:
// ignore

case modulewatch.WatchEventModuleRemoved:
case watch.WatchEventModuleRemoved:
// ignore
}

Expand All @@ -286,7 +286,7 @@ func (p *internalPlugin) run(ctx context.Context) {
}
}

func buildAndLoadResult(ctx context.Context, projectRoot string, c moduleconfig.ModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, watcher *modulewatch.Watcher, build buildFunc) (BuildResult, error) {
func buildAndLoadResult(ctx context.Context, projectRoot string, c moduleconfig.ModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, watcher *watch.Watcher, build buildFunc) (BuildResult, error) {
config := c.Abs()
release, err := flock.Acquire(ctx, filepath.Join(config.Dir, ".ftl.lock"), BuildLockTimeout)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/buildengine/plugin_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"github.com/TBD54566975/ftl/internal/exec"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/moduleconfig"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/projectconfig"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/watch"
)

type goPlugin struct {
Expand Down Expand Up @@ -105,12 +105,12 @@ func (p *goPlugin) GetDependencies(ctx context.Context) ([]string, error) {
return p.internalPlugin.getDependencies(ctx, func() ([]string, error) {
dependencies := map[string]bool{}
fset := token.NewFileSet()
err := modulewatch.WalkDir(p.config.Abs().Dir, func(path string, d fs.DirEntry) error {
err := watch.WalkDir(p.config.Abs().Dir, func(path string, d fs.DirEntry) error {
if !d.IsDir() {
return nil
}
if strings.HasPrefix(d.Name(), "_") || d.Name() == "testdata" {
return modulewatch.ErrSkip
return watch.ErrSkip
}
pkgs, err := parser.ParseDir(fset, path, nil, parser.ImportsOnly)
if pkgs == nil {
Expand Down Expand Up @@ -145,7 +145,7 @@ func (p *goPlugin) GetDependencies(ctx context.Context) ([]string, error) {
})
}

func buildGo(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction modulewatch.ModifyFilesTransaction) error {
func buildGo(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction watch.ModifyFilesTransaction) error {
if err := compile.Build(ctx, projectRoot, config.Dir, sch, transaction, buildEnv, devMode); err != nil {
return CompilerBuildError{err: fmt.Errorf("failed to build module %q: %w", config.Module, err)}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/buildengine/plugin_java.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"github.com/TBD54566975/ftl/internal/exec"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/moduleconfig"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/projectconfig"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/watch"
"github.com/TBD54566975/ftl/jvm-runtime/java"
"github.com/TBD54566975/ftl/jvm-runtime/kotlin"
)
Expand Down Expand Up @@ -191,7 +191,7 @@ func extractKotlinFTLImports(self, dir string) ([]string, error) {
return modules, nil
}

func buildJava(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction modulewatch.ModifyFilesTransaction) error {
func buildJava(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction watch.ModifyFilesTransaction) error {
logger := log.FromContext(ctx)
if config.Java.BuildTool == moduleconfig.JavaBuildToolMaven {
if err := setPOMProperties(ctx, config.Dir); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/buildengine/plugin_rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/TBD54566975/ftl/internal/exec"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/moduleconfig"
"github.com/TBD54566975/ftl/internal/modulewatch"
"github.com/TBD54566975/ftl/internal/projectconfig"
"github.com/TBD54566975/ftl/internal/schema"
"github.com/TBD54566975/ftl/internal/watch"
)

type rustPlugin struct {
Expand Down Expand Up @@ -39,7 +39,7 @@ func (p *rustPlugin) GetDependencies(ctx context.Context) ([]string, error) {
return nil, fmt.Errorf("not implemented")
}

func buildRust(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction modulewatch.ModifyFilesTransaction) error {
func buildRust(ctx context.Context, projectRoot string, config moduleconfig.AbsModuleConfig, sch *schema.Schema, buildEnv []string, devMode bool, transaction watch.ModifyFilesTransaction) error {
logger := log.FromContext(ctx)
logger.Debugf("Using build command '%s'", config.Build)
err := exec.Command(ctx, log.Debug, config.Dir+"/_ftl", "bash", "-c", config.Build).RunBuffered(ctx)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package modulewatch
package watch

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package modulewatch
package watch

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package modulewatch
package watch

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package modulewatch
package watch

import (
"os"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/modulewatch/walk.go → internal/watch/walk.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package modulewatch
package watch

import (
"bufio"
Expand Down
2 changes: 1 addition & 1 deletion internal/modulewatch/watch.go → internal/watch/watch.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package modulewatch
package watch

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build integration

package modulewatch
package watch

import (
"context" //nolint:depguard
Expand Down

0 comments on commit 7f971c1

Please sign in to comment.