You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

  1. package s3api
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/filer"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/pb"
  6. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  7. "github.com/chrislusf/seaweedfs/weed/util"
  8. )
  9. func (s3a *S3ApiServer) subscribeMetaEvents(clientName string, prefix string, lastTsNs int64) error {
  10. processEventFn := func(resp *filer_pb.SubscribeMetadataResponse) error {
  11. message := resp.EventNotification
  12. if message.NewEntry == nil {
  13. return nil
  14. }
  15. dir := resp.Directory
  16. if message.NewParentPath != "" {
  17. dir = message.NewParentPath
  18. }
  19. if dir == filer.IamConfigDirecotry && message.NewEntry.Name == filer.IamIdentityFile {
  20. err := util.Retry("updateIamIdentity", func() error {
  21. return s3a.iam.loadS3ApiConfigurationFromBytes(message.NewEntry.Content)
  22. })
  23. if err != nil {
  24. return err
  25. }
  26. glog.V(0).Infof("updated %s/%s", filer.IamConfigDirecotry, filer.IamIdentityFile)
  27. }
  28. return nil
  29. }
  30. return util.Retry("followIamChanges", func() error {
  31. return pb.WithFilerClientFollowMetadata(s3a, clientName, prefix, lastTsNs, 0, processEventFn, true)
  32. })
  33. }