event

package
v0.0.0-...-e9b145e Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

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:05Z"
)

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"`
}

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

type FilterRule

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

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

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

const (
	ObjectAccessedAll Name = 1 + iota
	ObjectAccessedGet
	ObjectAccessedHead
	ObjectCreatedAll
	ObjectCreatedCompleteMultipartUpload
	ObjectCreatedCopy
	ObjectCreatedPost
	ObjectCreatedPut
	ObjectRemovedAll
	ObjectRemovedDelete
)

Values of 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) 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) 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) 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>

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
	Send(Event) error
	Close() error
}

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 TargetIDErr

type TargetIDErr 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
}

TargetIDErr returns error associated for a 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) String

func (set TargetIDSet) String() string

String - returns string representation.

func (TargetIDSet) ToSlice

func (set TargetIDSet) ToSlice() []TargetID

ToSlice - returns TargetID slice from TargetIDSet.

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(target 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(targetids ...TargetID) <-chan TargetIDErr

Remove - closes and removes targets by given target IDs.

func (*TargetList) Send

func (list *TargetList) Send(event Event, targetIDs ...TargetID) <-chan TargetIDErr

Send - sends events to targets identified by target IDs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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