events

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

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 Publisher

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

Publisher is the interface publishers need to fulfill

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
	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 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

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