refactor(watcher): rename events package to watcherEvents

- Updated import paths and references from events to watcherEvents across multiple files
This commit is contained in:
yusing
2026-02-15 14:35:23 +08:00
parent d619562f00
commit 1244af0e38
9 changed files with 30 additions and 30 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/yusing/godoxy/internal/watcher/events"
watcherEvents "github.com/yusing/godoxy/internal/watcher/events"
"github.com/yusing/goutils/task"
)
@@ -117,18 +117,18 @@ func (h *DirWatcher) start() {
}
msg := Event{
Type: events.EventTypeFile,
Type: watcherEvents.EventTypeFile,
ActorName: relPath,
}
switch {
case fsEvent.Has(fsnotify.Write):
msg.Action = events.ActionFileWritten
msg.Action = watcherEvents.ActionFileWritten
case fsEvent.Has(fsnotify.Create):
msg.Action = events.ActionFileCreated
msg.Action = watcherEvents.ActionFileCreated
case fsEvent.Has(fsnotify.Remove):
msg.Action = events.ActionFileDeleted
msg.Action = watcherEvents.ActionFileDeleted
case fsEvent.Has(fsnotify.Rename):
msg.Action = events.ActionFileRenamed
msg.Action = watcherEvents.ActionFileRenamed
default: // ignore other events
continue
}

View File

@@ -11,7 +11,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/yusing/godoxy/internal/docker"
"github.com/yusing/godoxy/internal/types"
"github.com/yusing/godoxy/internal/watcher/events"
watcherEvents "github.com/yusing/godoxy/internal/watcher/events"
)
type (
@@ -64,8 +64,8 @@ var (
dockerWatcherRetryInterval = 3 * time.Second
reloadTrigger = Event{
Type: events.EventTypeDocker,
Action: events.ActionForceReload,
Type: watcherEvents.EventTypeDocker,
Action: watcherEvents.ActionForceReload,
ActorAttributes: map[string]string{},
ActorName: "",
ActorID: "",
@@ -157,12 +157,12 @@ func (w DockerWatcher) parseError(err error) error {
}
func (w DockerWatcher) handleEvent(event dockerEvents.Message, ch chan<- Event) {
action, ok := events.DockerEventMap[event.Action]
action, ok := watcherEvents.DockerEventMap[event.Action]
if !ok {
return
}
ch <- Event{
Type: events.EventTypeDocker,
Type: watcherEvents.EventTypeDocker,
ActorID: event.Actor.ID,
ActorAttributes: event.Actor.Attributes, // labels
ActorName: event.Actor.Attributes["name"],

View File

@@ -1,4 +1,4 @@
package events
package watcherevents
import (
"fmt"

View File

@@ -3,10 +3,10 @@ package watcher
import (
"context"
"github.com/yusing/godoxy/internal/watcher/events"
watcherEvents "github.com/yusing/godoxy/internal/watcher/events"
)
type Event = events.Event
type Event = watcherEvents.Event
type Watcher interface {
Events(ctx context.Context) (<-chan Event, <-chan error)