models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

func GetCache() *redis.Client

func GetDB

func GetDB() *gorm.DB

func GetElasticsearch

func GetElasticsearch() *elastic.Client

func Migrate

func Migrate()

func NewPattern

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

NewPattern - create new pattern for prefix/suffix.

func SetCache

func SetCache()

func SetCelery

func SetCelery()

func SetDB

func SetDB()

func SetElasticsearch

func SetElasticsearch()

Types

type Config

type Config struct {
	Model
	Bucket  string   `xml:"-" gorm:"unique;not null"`
	XMLName xml.Name `xml:"NotificationConfiguration"`
	Queues  []Queue  `xml:"QueueConfiguration,omitempty"`
	Topics  []Topic  `xml:"TopicConfiguration,omitempty"`
}

func (Config) ToRulesMap

func (conf Config) ToRulesMap() RulesMap

func (*Config) UnmarshalXML

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

UnmarshalXML - decodes XML data.

type Endpoint

type Endpoint struct {
	gorm.Model
	Protocol   string
	URI        string
	Name       string
	ResourceID uint
}

func ParseSubscription

func ParseSubscription(s string) (*Endpoint, error)

type Event

type Event struct {
	Model
	Name    event.Name
	QueueID uint `xml:"-"`
	TopicID uint `xml:"-"`
}

func (*Event) MarshalXML

func (event *Event) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML - encodes to XML data.

func (*Event) UnmarshalXML

func (e *Event) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type FilterRule

type FilterRule struct {
	Model
	Name             string `xml:"Name"`
	Value            string `xml:"Value"`
	FilterRuleListID uint   `xml:"-"`
}

func (*FilterRule) UnmarshalXML

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

UnmarshalXML - decodes XML data.

type FilterRuleList

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

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 Model

type Model struct {
	ID        uint       `gorm:"primary_key" xml:"-"`
	CreatedAt time.Time  `xml:"-"`
	UpdatedAt time.Time  `xml:"-"`
	DeletedAt *time.Time `xml:"-" sql:"index"`
}

type Queue

type Queue struct {
	Model
	QueueIdentifier string   `xml:"Id"`
	Filter          S3Key    `xml:"Filter"`
	Events          []Event  `xml:"Event"`
	ARN             string   `xml:"Queue"`
	Resource        Resource `xml:"-"`
	ResourceID      uint     `xml:"-"`
	ConfigID        uint     `xml:"-"`
}

func (Queue) ToRulesMap

func (q Queue) ToRulesMap() RulesMap

func (*Queue) UnmarshalXML

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

UnmarshalXML - decodes XML data.

type Resource

type Resource struct {
	Model
	Service   Service
	AccountID string
	Type      string
	Name      string
	Endpoints []Endpoint
	Queues    []Queue
	Topics    []Topic
}

func ParseARN

func ParseARN(s string) (*Resource, error)

func (Resource) ARN

func (r Resource) ARN() string

func (Resource) URL

func (r Resource) URL() string

type Rules

type Rules map[string][]Resource

func (Rules) Clone

func (rules Rules) Clone() Rules

Clone - returns copy of this rules.

func (Rules) Match

func (rules Rules) Match(objectName string) []Resource

Match - returns []Resource 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[event.Name]Rules

func NewRulesMap

func NewRulesMap(eventNames []event.Name, pattern string, resource Resource) RulesMap

NewRulesMap - creates new rules map with given values.

func (RulesMap) Add

func (rulesMap RulesMap) Add(rulesMap2 RulesMap)

Add - adds given rules map.

type S3Key

type S3Key struct {
	Model
	RuleList FilterRuleList `xml:"S3Key,omitempty"`
	QueueID  uint
	TopicID  uint
}

type Service

type Service int
const (
	SQS Service = iota + 1
	SNS
)

func ParseService

func ParseService(s string) Service

func (*Service) Scan

func (s *Service) Scan(src interface{}) error

func (Service) String

func (s Service) String() string

func (Service) Value

func (s Service) Value() (driver.Value, error)

type Topic

type Topic struct {
	Model
	TopicIdentifier string   `xml:"Id"`
	Filter          S3Key    `xml:"Filter"`
	Events          []Event  `xml:"Event"`
	ARN             string   `xml:"Topic"`
	Resource        Resource `xml:"-"`
	ResourceID      uint     `xml:"-"`
	ConfigID        uint     `xml:"-"`
}

func (Topic) ToRulesMap

func (t Topic) ToRulesMap() RulesMap

Jump to

Keyboard shortcuts

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