seaweedfs/weed/filer2/filer_notify.go

40 lines
849 B
Go
Raw Permalink Normal View History

2018-08-13 08:20:49 +00:00
package filer2
import (
2018-09-21 08:56:43 +00:00
"github.com/chrislusf/seaweedfs/weed/glog"
2018-09-16 08:18:30 +00:00
"github.com/chrislusf/seaweedfs/weed/notification"
2018-08-13 08:20:49 +00:00
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
2018-09-17 07:27:56 +00:00
func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool) {
2018-08-13 08:20:49 +00:00
var key string
if oldEntry != nil {
key = string(oldEntry.FullPath)
} else if newEntry != nil {
key = string(newEntry.FullPath)
} else {
return
}
2018-09-16 08:18:30 +00:00
if notification.Queue != nil {
2018-08-13 08:33:21 +00:00
2018-09-16 18:20:36 +00:00
glog.V(3).Infof("notifying entry update %v", key)
newParentPath := ""
if newEntry != nil {
newParentPath, _ = newEntry.FullPath.DirAndName()
}
2018-09-16 08:18:30 +00:00
notification.Queue.SendMessage(
2018-08-13 08:33:21 +00:00
key,
&filer_pb.EventNotification{
OldEntry: oldEntry.ToProtoEntry(),
NewEntry: newEntry.ToProtoEntry(),
DeleteChunks: deleteChunks,
NewParentPath: newParentPath,
2018-08-13 08:33:21 +00:00
},
)
}
2018-08-13 08:20:49 +00:00
}