filer_notify.go 849 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package filer2
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/glog"
  4. "github.com/chrislusf/seaweedfs/weed/notification"
  5. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  6. )
  7. func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool) {
  8. var key string
  9. if oldEntry != nil {
  10. key = string(oldEntry.FullPath)
  11. } else if newEntry != nil {
  12. key = string(newEntry.FullPath)
  13. } else {
  14. return
  15. }
  16. if notification.Queue != nil {
  17. glog.V(3).Infof("notifying entry update %v", key)
  18. newParentPath := ""
  19. if newEntry != nil {
  20. newParentPath, _ = newEntry.FullPath.DirAndName()
  21. }
  22. notification.Queue.SendMessage(
  23. key,
  24. &filer_pb.EventNotification{
  25. OldEntry: oldEntry.ToProtoEntry(),
  26. NewEntry: newEntry.ToProtoEntry(),
  27. DeleteChunks: deleteChunks,
  28. NewParentPath: newParentPath,
  29. },
  30. )
  31. }
  32. }