events

package
v2.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: Apache-2.0 Imports: 11 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MainQueueName is the name of the main queue
	// All events will go through here as they are forwarded to the consumer via the
	// group name
	// TODO: "fan-out" so not all events go through the same queue? requires investigation
	MainQueueName = "main-queue"

	// MetadatakeyEventType is the key used for the eventtype in the metadata map of the event
	MetadatakeyEventType = "eventtype"
)

Functions

func Consume

func Consume(s Consumer, group string, evs ...Unmarshaller) (<-chan interface{}, error)

Consume returns a channel that will get all events that match the given evs group defines the service type: One group will get exactly one copy of a event that is emitted NOTE: uses reflect on initialization

func Publish

func Publish(s Publisher, ev interface{}) error

Publish publishes the ev to the MainQueue from where it is distributed to all subscribers NOTE: needs to use reflect on runtime

Types

type Consumer

type Consumer interface {
	Consume(string, ...events.ConsumeOption) (<-chan events.Event, error)
}

Consumer is the interface consumer need to fulfill

type ContainerCreated added in v2.3.0

type ContainerCreated struct {
	Executant *user.UserId
	Ref       *provider.Reference
}

ContainerCreated is emitted when a directory has been created

func (ContainerCreated) Unmarshal added in v2.3.0

func (ContainerCreated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type FileDownloaded added in v2.1.0

type FileDownloaded struct {
	Ref   *provider.Reference
	Owner *user.UserId
}

FileDownloaded is emitted when a file is downloaded

func (FileDownloaded) Unmarshal added in v2.1.0

func (FileDownloaded) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type FileUploaded added in v2.1.0

type FileUploaded struct {
	Executant *user.UserId
	Ref       *provider.Reference
	Owner     *user.UserId
}

FileUploaded is emitted when a file is uploaded

func (FileUploaded) Unmarshal added in v2.1.0

func (FileUploaded) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type FileVersionRestored added in v2.1.0

type FileVersionRestored struct {
	Executant *user.UserId
	Ref       *provider.Reference
	Owner     *user.UserId
	Key       string
}

FileVersionRestored is emitted when a file version is restored

func (FileVersionRestored) Unmarshal added in v2.1.0

func (FileVersionRestored) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type GroupCreated added in v2.2.0

type GroupCreated struct {
	GroupID string
}

GroupCreated is emitted when a group was created

func (GroupCreated) Unmarshal added in v2.2.0

func (GroupCreated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type GroupDeleted added in v2.2.0

type GroupDeleted struct {
	GroupID string
}

GroupDeleted is emitted when a group was deleted

func (GroupDeleted) Unmarshal added in v2.2.0

func (GroupDeleted) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type GroupMemberAdded added in v2.2.0

type GroupMemberAdded struct {
	GroupID string
	UserID  string
}

GroupMemberAdded is emitted when a user was added to a group

func (GroupMemberAdded) Unmarshal added in v2.2.0

func (GroupMemberAdded) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type GroupMemberRemoved added in v2.2.0

type GroupMemberRemoved struct {
	GroupID string
	UserID  string
}

GroupMemberRemoved is emitted when a user was removed from a group

func (GroupMemberRemoved) Unmarshal added in v2.2.0

func (GroupMemberRemoved) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ItemMoved added in v2.1.0

type ItemMoved struct {
	Executant    *user.UserId
	Ref          *provider.Reference
	Owner        *user.UserId
	OldReference *provider.Reference
}

ItemMoved is emitted when a file or folder is moved

func (ItemMoved) Unmarshal added in v2.1.0

func (ItemMoved) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ItemPurged added in v2.1.0

type ItemPurged struct {
	Executant *user.UserId
	ID        *provider.ResourceId
	Ref       *provider.Reference
	Owner     *user.UserId
}

ItemPurged is emitted when a file or folder is removed from trashbin

func (ItemPurged) Unmarshal added in v2.1.0

func (ItemPurged) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ItemRestored added in v2.1.0

type ItemRestored struct {
	Executant    *user.UserId
	ID           *provider.ResourceId
	Ref          *provider.Reference
	Owner        *user.UserId
	OldReference *provider.Reference
	Key          string
}

ItemRestored is emitted when a file or folder is restored from trashbin

func (ItemRestored) Unmarshal added in v2.1.0

func (ItemRestored) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ItemTrashed added in v2.1.0

type ItemTrashed struct {
	Executant *user.UserId
	ID        *provider.ResourceId
	Ref       *provider.Reference
	Owner     *user.UserId
}

ItemTrashed is emitted when a file or folder is trashed

func (ItemTrashed) Unmarshal added in v2.1.0

func (ItemTrashed) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type LinkAccessFailed added in v2.1.0

type LinkAccessFailed struct {
	ShareID *link.PublicShareId
	Token   string
	Status  rpc.Code
	Message string
}

LinkAccessFailed is emitted when an access to a public link has resulted in an error (by token)

func (LinkAccessFailed) Unmarshal added in v2.1.0

func (LinkAccessFailed) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type LinkAccessed added in v2.1.0

type LinkAccessed struct {
	ShareID           *link.PublicShareId
	Sharer            *user.UserId
	ItemID            *provider.ResourceId
	Permissions       *link.PublicSharePermissions
	DisplayName       string
	Expiration        *types.Timestamp
	PasswordProtected bool
	CTime             *types.Timestamp
	Token             string
}

LinkAccessed is emitted when a public link is accessed successfully (by token)

func (LinkAccessed) Unmarshal added in v2.1.0

func (LinkAccessed) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type LinkCreated added in v2.1.0

type LinkCreated struct {
	ShareID           *link.PublicShareId
	Sharer            *user.UserId
	ItemID            *provider.ResourceId
	Permissions       *link.PublicSharePermissions
	DisplayName       string
	Expiration        *types.Timestamp
	PasswordProtected bool
	CTime             *types.Timestamp
	Token             string
}

LinkCreated is emitted when a public link is created

func (LinkCreated) Unmarshal added in v2.1.0

func (LinkCreated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type LinkRemoved added in v2.1.0

type LinkRemoved struct {
	// split protobuf Ref
	ShareID    *link.PublicShareId
	ShareToken string
}

LinkRemoved is emitted when a share is removed

func (LinkRemoved) Unmarshal added in v2.1.0

func (LinkRemoved) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type LinkUpdated added in v2.1.0

type LinkUpdated struct {
	ShareID           *link.PublicShareId
	Sharer            *user.UserId
	ItemID            *provider.ResourceId
	Permissions       *link.PublicSharePermissions
	DisplayName       string
	Expiration        *types.Timestamp
	PasswordProtected bool
	CTime             *types.Timestamp
	Token             string

	FieldUpdated string
}

LinkUpdated is emitted when a public link is updated

func (LinkUpdated) Unmarshal added in v2.1.0

func (LinkUpdated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type Publisher

type Publisher interface {
	Publish(string, interface{}, ...events.PublishOption) error
}

Publisher is the interface publishers need to fulfill

type ReceivedShareUpdated added in v2.1.0

type ReceivedShareUpdated struct {
	ShareID        *collaboration.ShareId
	ItemID         *provider.ResourceId
	Permissions    *collaboration.SharePermissions
	GranteeUserID  *user.UserId
	GranteeGroupID *group.GroupId
	Sharer         *user.UserId
	MTime          *types.Timestamp

	State string
}

ReceivedShareUpdated is emitted when a received share is accepted or declined

func (ReceivedShareUpdated) Unmarshal added in v2.1.0

func (ReceivedShareUpdated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ShareCreated

type ShareCreated struct {
	Sharer *user.UserId
	// split the protobuf Grantee oneof so we can use stdlib encoding/json
	GranteeUserID  *user.UserId
	GranteeGroupID *group.GroupId
	Sharee         *provider.Grantee
	ItemID         *provider.ResourceId
	Permissions    *collaboration.SharePermissions
	CTime          *types.Timestamp
}

ShareCreated is emitted when a share is created

func (ShareCreated) Unmarshal

func (ShareCreated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ShareRemoved added in v2.1.0

type ShareRemoved struct {
	// split protobuf Spec
	ShareID  *collaboration.ShareId
	ShareKey *collaboration.ShareKey
}

ShareRemoved is emitted when a share is removed

func (ShareRemoved) Unmarshal added in v2.1.0

func (ShareRemoved) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type ShareUpdated added in v2.1.0

type ShareUpdated struct {
	ShareID        *collaboration.ShareId
	ItemID         *provider.ResourceId
	Permissions    *collaboration.SharePermissions
	GranteeUserID  *user.UserId
	GranteeGroupID *group.GroupId
	Sharer         *user.UserId
	MTime          *types.Timestamp

	// indicates what was updated - one of "displayname", "permissions"
	Updated string
}

ShareUpdated is emitted when a share is updated

func (ShareUpdated) Unmarshal added in v2.1.0

func (ShareUpdated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type SpaceCreated added in v2.1.0

type SpaceCreated struct {
	ID    *provider.StorageSpaceId
	Owner *user.UserId
	Root  *provider.ResourceId
	Name  string
	Type  string
	Quota *provider.Quota
	MTime *types.Timestamp
}

SpaceCreated is emitted when a space is created

func (SpaceCreated) Unmarshal added in v2.1.0

func (SpaceCreated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type SpaceDeleted added in v2.1.0

type SpaceDeleted struct {
	ID *provider.StorageSpaceId
}

SpaceDeleted is emitted when a space is deleted

func (SpaceDeleted) Unmarshal added in v2.1.0

func (SpaceDeleted) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type SpaceDisabled added in v2.1.0

type SpaceDisabled struct {
	ID *provider.StorageSpaceId
}

SpaceDisabled is emitted when a space is disabled

func (SpaceDisabled) Unmarshal added in v2.1.0

func (SpaceDisabled) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type SpaceEnabled added in v2.1.0

type SpaceEnabled struct {
	ID    *provider.StorageSpaceId
	Owner *user.UserId
}

SpaceEnabled is emitted when a space is (re-)enabled

func (SpaceEnabled) Unmarshal added in v2.1.0

func (SpaceEnabled) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type SpaceRenamed added in v2.1.0

type SpaceRenamed struct {
	ID    *provider.StorageSpaceId
	Owner *user.UserId
	Name  string
}

SpaceRenamed is emitted when a space is renamed

func (SpaceRenamed) Unmarshal added in v2.1.0

func (SpaceRenamed) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type Stream

type Stream interface {
	Publish(string, interface{}, ...events.PublishOption) error
	Consume(string, ...events.ConsumeOption) (<-chan events.Event, error)
}

Stream is the interface common to Publisher and Consumer

type Unmarshaller

type Unmarshaller interface {
	Unmarshal([]byte) (interface{}, error)
}

Unmarshaller is the interface events need to fulfill

type UserCreated added in v2.2.0

type UserCreated struct {
	UserID string
}

UserCreated is emitted when a user was created

func (UserCreated) Unmarshal added in v2.2.0

func (UserCreated) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type UserDeleted added in v2.2.0

type UserDeleted struct {
	UserID string
}

UserDeleted is emitted when a user was deleted

func (UserDeleted) Unmarshal added in v2.2.0

func (UserDeleted) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

type UserFeature added in v2.2.0

type UserFeature struct {
	Name  string
	Value string
}

UserFeature represents a user feature

type UserFeatureChanged added in v2.2.0

type UserFeatureChanged struct {
	UserID   string
	Features []UserFeature
}

UserFeatureChanged is emitted when a user feature was changed

func (UserFeatureChanged) Unmarshal added in v2.2.0

func (UserFeatureChanged) Unmarshal(v []byte) (interface{}, error)

Unmarshal to fulfill umarshaller interface

Directories

Path Synopsis
consumer
Package consumer contains an example implementation of an event consumer
Package consumer contains an example implementation of an event consumer
publisher
Package publisher contains an example implementation for a publisher
Package publisher contains an example implementation for a publisher

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL