mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 08:48:32 +02:00
refactor(watcher): rename events package to watcherEvents
- Updated import paths and references from events to watcherEvents across multiple files
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package events
|
||||
package watcherevents
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user