model

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskSecret

func MaskSecret(secret string) string

MaskSecret mask secret string

Types

type Article

type Article struct {
	FeedTitle       string                 `json:"feedTitle,omitempty"`
	Title           string                 `json:"title,omitempty"`
	Text            string                 `json:"text,omitempty"`
	Content         string                 `json:"content,omitempty"`
	Link            string                 `json:"link,omitempty"`
	Updated         string                 `json:"updated,omitempty"`
	UpdatedParsed   *time.Time             `json:"updatedParsed,omitempty"`
	Published       string                 `json:"published,omitempty"`
	PublishedParsed *time.Time             `json:"publishedParsed,omitempty"`
	GUID            string                 `json:"guid,omitempty"`
	Meta            map[string]interface{} `json:"meta,omitempty"`
	Tags            []string               `json:"tags,omitempty"`
}

Article model structure.

func (*Article) Hash

func (a *Article) Hash() string

Hash computes article hash

func (*Article) IsValid

func (a *Article) IsValid(maxAge time.Time) error

IsValid test if the article can be pushed

func (*Article) Match

func (a *Article) Match(tags []string) bool

Match test if articles tags matches other tags

func (*Article) Merge

func (a *Article) Merge(other Article)

Merge an article with an other

func (*Article) RefDate

func (a *Article) RefDate() *time.Time

RefDate get article reference date (published or updated date)

func (*Article) String

func (a *Article) String() string

type CacheItem

type CacheItem struct {
	Value string    `json:"value"`
	Date  time.Time `json:"date"`
}

CacheItem stored into the cache.

type FeedDef

type FeedDef struct {
	// ID of feed (MD5 of the xmlUrl)
	ID string `json:"id"`
	// URL of the XML feed
	XMLURL string `json:"xmlUrl"`
	// URL of the feed website
	HTMLURL *string `json:"htmlUrl,omitempty"`
	// URL of the PubSubHubbud hub
	HubURL *string `json:"hubUrl,omitempty"`
	// Title of the Feed
	Title string `json:"title"`
	// Aggregation status
	Status *string `json:"status,omitempty"`
	// List of tags
	Tags []string `json:"tags,omitempty"`
	// Date of creation
	Cdate time.Time `json:"cdate"`
	// Date of modification
	Mdate time.Time `json:"mdate"`
}

FeedDef object structure

type FeedDefCollection

type FeedDefCollection []FeedDef

FeedDefCollection is a list of feed definition

type FeedDefPage

type FeedDefPage struct {
	Total int
	Page  int
	Size  int
	Feeds FeedDefCollection
}

FeedDefPage is a page of feed definition

type Filter

type Filter interface {
	// DoFilter apply filter on the article.
	// Returns true if the filter was applied
	DoFilter(article *Article) (bool, error)
	// Match test if article match with filter condition
	Match(article *Article) bool
	// GetDef returns filter definition
	GetDef() FilterDef
}

Filter is the filter interface

type FilterDef

type FilterDef struct {
	ID    string `json:"id"`
	Alias string `json:"alias"`
	Spec
	Condition string      `json:"condition"`
	Props     FilterProps `json:"props:omitempty"`
	Enabled   bool        `json:"enabled"`
	NbSuccess uint32      `json:"nbSuccess"`
	NbError   uint32      `json:"nbError"`
}

FilterDef contains filter definition

type FilterDefCollection

type FilterDefCollection []*FilterDef

FilterDefCollection is an array of filter definition

type FilterPlugin

type FilterPlugin interface {
	// Build a filter
	Build(def *FilterDef) (Filter, error)
	// Spec returns plugin specs
	Spec() Spec
}

FilterPlugin is the interface of an filter plugin

type FilterProps

type FilterProps map[string]interface{}

FilterProps constain properties of a filter

func (FilterProps) Get

func (p FilterProps) Get(key string) string

Get property string value

type Output

type Output interface {
	// Send article to the output.
	// Returns true if the article was sent
	Send(article *Article) (bool, error)
	// GetDef returns output definition
	GetDef() OutputDef
}

Output is the output interface

type OutputDef

type OutputDef struct {
	ID    string `json:"id"`
	Alias string `json:"alias"`
	Spec
	Condition string              `json:"condition"`
	Props     OutputProps         `json:"props:omitempty"`
	Filters   FilterDefCollection `json:"filters"`
	Enabled   bool                `json:"enabled"`
	NbSuccess uint32              `json:"nbSuccess"`
	NbError   uint32              `json:"nbError"`
}

OutputDef contains output definition

func (OutputDef) Hash

func (def OutputDef) Hash() string

Hash computes spec hash

type OutputDefCollection

type OutputDefCollection []*OutputDef

OutputDefCollection is an array of output definition

type OutputPlugin

type OutputPlugin interface {
	// Build an output plugin
	Build(def *OutputDef) (Output, error)
	// Spec returns plugin specs
	Spec() Spec
}

OutputPlugin is the interface of an output plugin

type OutputProps

type OutputProps map[string]interface{}

OutputProps contains properties of an output

func (OutputProps) Get

func (p OutputProps) Get(key string) string

Get property string value

type PluginSpec

type PluginSpec struct {
	Type PluginType
	Spec
}

PluginSpec contains plugins specifications

type PluginType

type PluginType int

PluginType is the plugin type qualifier

const (
	// OutputPluginType output plugin type
	OutputPluginType PluginType = iota
	// FilterPluginType filter plugin type
	FilterPluginType
)

type PropSpec

type PropSpec struct {
	Desc    string
	Name    string
	Type    PropType
	Options map[string]string
}

PropSpec contains property specification

type PropType

type PropType int

PropType is a enum to specify a property type

const (
	// Email type
	Email PropType = iota
	// Number type
	Number
	// Password type
	Password
	// Text type
	Text
	// URL type
	URL
	// Select type
	Select
	// Textarea type
	Textarea
)

func (PropType) String

func (p PropType) String() string

type Quota added in v3.1.1

type Quota struct {
	MaxNbFeeds   int
	MaxNbOutputs int
}

Quota contains quota values

type Spec

type Spec struct {
	Name      string     `json:"name"`
	Desc      string     `json:"-"`
	PropsSpec []PropSpec `json:"-"`
}

Spec describe specifications of a processor

Jump to

Keyboard shortcuts

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