event

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NamespaceFormat - namespace log format used in some event targets.
	NamespaceFormat = "namespace"

	// AccessFormat - access log format used in some event targets.
	AccessFormat = "access"

	// AMZTimeFormat - event time format.
	AMZTimeFormat = "2006-01-02T15:04:05.000Z"

	// StoreExtension - file extension of an event file in store
	StoreExtension = ".event"
)

Variables

This section is empty.

Functions

func IsEventError

func IsEventError(err error) bool

IsEventError - checks whether given error is event error or not.

func NewPattern

func NewPattern(prefix, suffix string) (pattern string)

NewPattern - create new pattern for prefix/suffix.

func ValidateFilterRuleValue

func ValidateFilterRuleValue(value string) error

ValidateFilterRuleValue - checks if given value is filter rule value or not.

Types

type ARN

type ARN struct {
	TargetID
	// contains filtered or unexported fields
}

ARN - SQS resource name representation.

func (ARN) MarshalXML

func (arn ARN) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML - encodes to XML data.

func (ARN) String

func (arn ARN) String() string

String - returns string representation.

func (*ARN) UnmarshalXML

func (arn *ARN) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

type Bucket

type Bucket struct {
	Name          string   `json:"name"`
	OwnerIdentity Identity `json:"ownerIdentity"`
	ARN           string   `json:"arn"`
}

Bucket represents bucket metadata of the event.

type Config

type Config struct {
	XMLNS      string   `xml:"xmlns,attr,omitempty"`
	XMLName    xml.Name `xml:"NotificationConfiguration"`
	QueueList  []Queue  `xml:"QueueConfiguration,omitempty"`
	LambdaList []lambda `xml:"CloudFunctionConfiguration,omitempty"`
	TopicList  []topic  `xml:"TopicConfiguration,omitempty"`
}

Config - notification configuration described in http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html

func ParseConfig

func ParseConfig(reader io.Reader, region string, targetList *TargetList) (*Config, error)

ParseConfig - parses data in reader to notification configuration.

func (*Config) SetRegion

func (conf *Config) SetRegion(region string)

SetRegion - sets region to all queue configuration.

func (*Config) ToRulesMap

func (conf *Config) ToRulesMap() RulesMap

ToRulesMap - converts all queue configuration to RulesMap.

func (*Config) UnmarshalXML

func (conf *Config) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

func (Config) Validate

func (conf Config) Validate(region string, targetList *TargetList) error

Validate - checks whether config has valid values or not.

type ErrARNNotFound

type ErrARNNotFound struct {
	ARN ARN
}

ErrARNNotFound - ARN not found error.

func (ErrARNNotFound) Error

func (err ErrARNNotFound) Error() string

type ErrDuplicateEventName

type ErrDuplicateEventName struct {
	EventName Name
}

ErrDuplicateEventName - duplicate event name error.

func (ErrDuplicateEventName) Error

func (err ErrDuplicateEventName) Error() string

type ErrDuplicateQueueConfiguration

type ErrDuplicateQueueConfiguration struct {
	Queue Queue
}

ErrDuplicateQueueConfiguration - duplicate queue configuration error.

func (ErrDuplicateQueueConfiguration) Error

type ErrFilterNamePrefix

type ErrFilterNamePrefix struct{}

ErrFilterNamePrefix - more than one prefix usage error.

func (ErrFilterNamePrefix) Error

func (err ErrFilterNamePrefix) Error() string

type ErrFilterNameSuffix

type ErrFilterNameSuffix struct{}

ErrFilterNameSuffix - more than one suffix usage error.

func (ErrFilterNameSuffix) Error

func (err ErrFilterNameSuffix) Error() string

type ErrInvalidARN

type ErrInvalidARN struct {
	ARN string
}

ErrInvalidARN - invalid ARN error.

func (ErrInvalidARN) Error

func (err ErrInvalidARN) Error() string

type ErrInvalidEventName

type ErrInvalidEventName struct {
	Name string
}

ErrInvalidEventName - invalid event name error.

func (ErrInvalidEventName) Error

func (err ErrInvalidEventName) Error() string

type ErrInvalidFilterName

type ErrInvalidFilterName struct {
	FilterName string
}

ErrInvalidFilterName - invalid filter name error.

func (ErrInvalidFilterName) Error

func (err ErrInvalidFilterName) Error() string

type ErrInvalidFilterValue

type ErrInvalidFilterValue struct {
	FilterValue string
}

ErrInvalidFilterValue - invalid filter value error.

func (ErrInvalidFilterValue) Error

func (err ErrInvalidFilterValue) Error() string

type ErrUnknownRegion

type ErrUnknownRegion struct {
	Region string
}

ErrUnknownRegion - unknown region error.

func (ErrUnknownRegion) Error

func (err ErrUnknownRegion) Error() string

type ErrUnsupportedConfiguration

type ErrUnsupportedConfiguration struct{}

ErrUnsupportedConfiguration - unsupported configuration error.

func (ErrUnsupportedConfiguration) Error

func (err ErrUnsupportedConfiguration) Error() string

type Event

type Event struct {
	EventVersion      string            `json:"eventVersion"`
	EventSource       string            `json:"eventSource"`
	AwsRegion         string            `json:"awsRegion"`
	EventTime         string            `json:"eventTime"`
	EventName         Name              `json:"eventName"`
	UserIdentity      Identity          `json:"userIdentity"`
	RequestParameters map[string]string `json:"requestParameters"`
	ResponseElements  map[string]string `json:"responseElements"`
	S3                Metadata          `json:"s3"`
	Source            Source            `json:"source"`
	Type              madmin.TraceType  `json:"-"`
}

Event represents event notification information defined in http://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html.

func (Event) Mask

func (e Event) Mask() uint64

Mask returns the type as mask.

type FilterRule

type FilterRule struct {
	Name  string `xml:"Name"`
	Value string `xml:"Value"`
}

FilterRule - represents elements inside <FilterRule>...</FilterRule>

func (FilterRule) MarshalXML

func (filter FilterRule) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements a custom marshaller to support `omitempty` feature.

func (*FilterRule) UnmarshalXML

func (filter *FilterRule) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

type FilterRuleList

type FilterRuleList struct {
	Rules []FilterRule `xml:"FilterRule,omitempty"`
}

FilterRuleList - represents multiple <FilterRule>...</FilterRule>

func (FilterRuleList) Pattern

func (ruleList FilterRuleList) Pattern() string

Pattern - returns pattern using prefix and suffix values.

func (*FilterRuleList) UnmarshalXML

func (ruleList *FilterRuleList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

type Identity

type Identity struct {
	PrincipalID string `json:"principalId"`
}

Identity represents access key who caused the event.

type Log

type Log struct {
	EventName Name
	Key       string
	Records   []Event
}

Log represents event information for some event targets.

type Metadata

type Metadata struct {
	SchemaVersion   string `json:"s3SchemaVersion"`
	ConfigurationID string `json:"configurationId"`
	Bucket          Bucket `json:"bucket"`
	Object          Object `json:"object"`
}

Metadata represents event metadata.

type Name

type Name int

Name - event type enum. Refer http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations for most basic values we have since extend this and its not really much applicable other than a reference point. "s3:Replication:OperationCompletedReplication" is a MinIO extension.

const (
	ObjectAccessedGet Name = 1 + iota
	ObjectAccessedGetRetention
	ObjectAccessedGetLegalHold
	ObjectAccessedHead
	ObjectCreatedCompleteMultipartUpload
	ObjectCreatedCopy
	ObjectCreatedPost
	ObjectCreatedPut
	ObjectCreatedPutRetention
	ObjectCreatedPutLegalHold
	ObjectCreatedPutTagging
	ObjectCreatedDeleteTagging
	ObjectRemovedDelete
	ObjectRemovedDeleteMarkerCreated
	BucketCreated
	BucketRemoved
	ObjectReplicationFailed
	ObjectReplicationComplete
	ObjectReplicationMissedThreshold
	ObjectReplicationReplicatedAfterThreshold
	ObjectReplicationNotTracked
	ObjectRestorePost
	ObjectRestoreCompleted
	ObjectTransitionFailed
	ObjectTransitionComplete
	ObjectManyVersions
	PrefixManyFolders

	ObjectAccessedAll
	ObjectCreatedAll
	ObjectRemovedAll
	ObjectReplicationAll
	ObjectRestoreAll
	ObjectTransitionAll
	ObjectScannerAll
	Everything
)

Values of event Name

func ParseName

func ParseName(s string) (Name, error)

ParseName - parses string to Name.

func (Name) Expand

func (name Name) Expand() []Name

Expand - returns expanded values of abbreviated event type.

func (Name) MarshalJSON

func (name Name) MarshalJSON() ([]byte, error)

MarshalJSON - encodes to JSON data.

func (Name) MarshalXML

func (name Name) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML - encodes to XML data.

func (Name) Mask

func (name Name) Mask() uint64

Mask returns the type as mask. Compound "All" types are expanded.

func (Name) String

func (name Name) String() string

String - returns string representation of event type.

func (*Name) UnmarshalJSON

func (name *Name) UnmarshalJSON(data []byte) error

UnmarshalJSON - decodes JSON data.

func (*Name) UnmarshalXML

func (name *Name) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

type Object

type Object struct {
	Key          string            `json:"key"`
	Size         int64             `json:"size,omitempty"`
	ETag         string            `json:"eTag,omitempty"`
	ContentType  string            `json:"contentType,omitempty"`
	UserMetadata map[string]string `json:"userMetadata,omitempty"`
	VersionID    string            `json:"versionId,omitempty"`
	Sequencer    string            `json:"sequencer"`
}

Object represents object metadata of the event.

type Queue

type Queue struct {
	ARN ARN `xml:"Queue"`
	// contains filtered or unexported fields
}

Queue - represents elements inside <QueueConfiguration>

func (*Queue) SetRegion

func (q *Queue) SetRegion(region string)

SetRegion - sets region value to queue's ARN.

func (Queue) ToRulesMap

func (q Queue) ToRulesMap() RulesMap

ToRulesMap - converts Queue to RulesMap

func (*Queue) UnmarshalXML

func (q *Queue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

func (Queue) Validate

func (q Queue) Validate(region string, targetList *TargetList) error

Validate - checks whether queue has valid values or not.

type Rules

type Rules map[string]TargetIDSet

Rules - event rules

func (Rules) Add

func (rules Rules) Add(pattern string, targetID TargetID)

Add - adds pattern and target ID.

func (Rules) Clone

func (rules Rules) Clone() Rules

Clone - returns copy of this rules.

func (Rules) Difference

func (rules Rules) Difference(rules2 Rules) Rules

Difference - returns diffrence with given rules as new rules.

func (Rules) Match

func (rules Rules) Match(objectName string) TargetIDSet

Match - returns TargetIDSet matching object name in rules.

func (Rules) MatchSimple

func (rules Rules) MatchSimple(objectName string) bool

MatchSimple - returns true one of the matching object name in rules.

func (Rules) Union

func (rules Rules) Union(rules2 Rules) Rules

Union - returns union with given rules as new rules.

type RulesMap

type RulesMap map[Name]Rules

RulesMap - map of rules for every event name.

func NewRulesMap

func NewRulesMap(eventNames []Name, pattern string, targetID TargetID) RulesMap

NewRulesMap - creates new rules map with given values.

func (RulesMap) Add

func (rulesMap RulesMap) Add(rulesMap2 RulesMap)

Add - adds given rules map.

func (RulesMap) Clone

func (rulesMap RulesMap) Clone() RulesMap

Clone - returns copy of this rules map.

func (RulesMap) Match

func (rulesMap RulesMap) Match(eventName Name, objectName string) TargetIDSet

Match - returns TargetIDSet matching object name and event name in rules map.

func (RulesMap) MatchSimple

func (rulesMap RulesMap) MatchSimple(eventName Name, objectName string) bool

MatchSimple - returns true if matching object name and event name in rules map.

func (RulesMap) Remove

func (rulesMap RulesMap) Remove(rulesMap2 RulesMap)

Remove - removes given rules map.

type S3Key

type S3Key struct {
	RuleList FilterRuleList `xml:"S3Key,omitempty" json:"S3Key,omitempty"`
}

S3Key - represents elements inside <S3Key>...</S3Key>

func (S3Key) MarshalXML

func (s3Key S3Key) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements a custom marshaller to support `omitempty` feature.

type Source

type Source struct {
	Host      string `json:"host"`
	Port      string `json:"port"`
	UserAgent string `json:"userAgent"`
}

Source represents client information who triggered the event.

type Target

type Target interface {
	ID() TargetID
	IsActive() (bool, error)
	Save(Event) error
	SendFromStore(store.Key) error
	Close() error
	Store() TargetStore
}

Target - event target interface

type TargetID

type TargetID struct {
	ID   string
	Name string
}

TargetID - holds identification and name strings of notification target.

func (TargetID) MarshalJSON

func (tid TargetID) MarshalJSON() ([]byte, error)

MarshalJSON - encodes to JSON data.

func (TargetID) String

func (tid TargetID) String() string

String - returns string representation.

func (TargetID) ToARN

func (tid TargetID) ToARN(region string) ARN

ToARN - converts to ARN.

func (*TargetID) UnmarshalJSON

func (tid *TargetID) UnmarshalJSON(data []byte) error

UnmarshalJSON - decodes JSON data.

type TargetIDResult

type TargetIDResult struct {
	// ID where the remove or send were initiated.
	ID TargetID
	// Stores any error while removing a target or while sending an event.
	Err error
}

TargetIDResult returns result of Remove/Send operation, sets err if any for the associated TargetID

type TargetIDSet

type TargetIDSet map[TargetID]struct{}

TargetIDSet - Set representation of TargetIDs.

func NewTargetIDSet

func NewTargetIDSet(targetIDs ...TargetID) TargetIDSet

NewTargetIDSet - creates new TargetID set with given TargetIDs.

func (TargetIDSet) Clone

func (set TargetIDSet) Clone() TargetIDSet

Clone - returns copy of this set.

func (TargetIDSet) Difference

func (set TargetIDSet) Difference(sset TargetIDSet) TargetIDSet

Difference - returns diffrence with given set as new set.

func (TargetIDSet) IsEmpty

func (set TargetIDSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (TargetIDSet) Union

func (set TargetIDSet) Union(sset TargetIDSet) TargetIDSet

Union - returns union with given set as new set.

type TargetList

type TargetList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TargetList - holds list of targets indexed by target ID.

func NewTargetList

func NewTargetList() *TargetList

NewTargetList - creates TargetList.

func (*TargetList) Add

func (list *TargetList) Add(targets ...Target) error

Add - adds unique target to target list.

func (*TargetList) Exists

func (list *TargetList) Exists(id TargetID) bool

Exists - checks whether target by target ID exists or not.

func (*TargetList) List

func (list *TargetList) List() []TargetID

List - returns available target IDs.

func (*TargetList) Remove

func (list *TargetList) Remove(targetIDSet TargetIDSet)

Remove - closes and removes targets by given target IDs.

func (*TargetList) Send

func (list *TargetList) Send(event Event, targetIDset TargetIDSet, resCh chan<- TargetIDResult, synchronous bool)

Send - sends events to targets identified by target IDs.

func (*TargetList) Stats

func (list *TargetList) Stats() TargetStats

Stats returns stats for targets.

func (*TargetList) TargetMap

func (list *TargetList) TargetMap() map[TargetID]Target

TargetMap - returns available targets.

func (*TargetList) Targets

func (list *TargetList) Targets() []Target

Targets - list all targets

type TargetStat

type TargetStat struct {
	ID           TargetID
	CurrentQueue int // Populated if target has a store.
}

TargetStat is the stats of a single target.

type TargetStats

type TargetStats struct {
	// CurrentSendCalls is the number of concurrent async Send calls to all targets
	CurrentSendCalls int64
	TotalEvents      int64
	EventsSkipped    int64

	TargetStats map[string]TargetStat
}

TargetStats is a collection of stats for multiple targets.

type TargetStore

type TargetStore interface {
	Len() int
}

TargetStore is a shallow version of a target.Store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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