aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/filer_notify.go
blob: b3c215249740861444c5f4d0a23e1af24fe3bcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package filer2

import (
	"github.com/chrislusf/seaweedfs/weed/glog"
	"github.com/chrislusf/seaweedfs/weed/notification"
	"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)

func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool) {
	var key string
	if oldEntry != nil {
		key = string(oldEntry.FullPath)
	} else if newEntry != nil {
		key = string(newEntry.FullPath)
	} else {
		return
	}

	if notification.Queue != nil {

		glog.V(3).Infof("notifying entry update %v", key)

		notification.Queue.SendMessage(
			key,
			&filer_pb.EventNotification{
				OldEntry:     oldEntry.ToProtoEntry(),
				NewEntry:     newEntry.ToProtoEntry(),
				DeleteChunks: deleteChunks,
			},
		)

	}
}