rule

package
v0.0.0-...-4347b6b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CriteriaConnection

type CriteriaConnection struct {
	New *connection.QueryOptions `json:"new"`
	Old *connection.QueryOptions `json:"old"`
}

func (*CriteriaConnection) Match

func (c *CriteriaConnection) Match(i interface{}) bool

type CriteriaEvent

type CriteriaEvent struct {
	New *event.QueryOptions `json:"new"`
	Old *event.QueryOptions `json:"old"`
}

func (*CriteriaEvent) Match

func (c *CriteriaEvent) Match(i interface{}) bool

type CriteriaObject

type CriteriaObject struct {
	New *object.QueryOptions `json:"new"`
	Old *object.QueryOptions `json:"old"`
}

func (*CriteriaObject) Match

func (c *CriteriaObject) Match(i interface{}) bool

type CriteriaReaction

type CriteriaReaction struct {
	New *reaction.QueryOptions `json:"new"`
	Old *reaction.QueryOptions `json:"old"`
}

func (*CriteriaReaction) Match

func (c *CriteriaReaction) Match(i interface{}) bool

type List

type List []*Rule

List is a Rule collection.

type Matcher

type Matcher interface {
	Match(c interface{}) bool
}

Matcher determines if a given state-change should trigger the Rule.

type Query

type Query map[string]string

Query is a mapping for templated Recipient lookups.

type QueryOptions

type QueryOptions struct {
	Active  *bool
	Deleted *bool
	IDs     []uint64
	Types   []Type
}

QueryOptions to narrow-down Rule queries.

type Recipient

type Recipient struct {
	Query     Query     `json:"query"`
	Templates Templates `json:"templates"`
	URN       string    `json:"urn"`
}

Recipient is an abstract description of how to lookup users and template the messaging as well as meta-information.

type Recipients

type Recipients []Recipient

Recipients is a Recipient collection.

type Rule

type Rule struct {
	Active     bool
	Criteria   Matcher
	Deleted    bool
	Ecosystem  sns.Platform
	ID         uint64
	Name       string
	Recipients Recipients
	Type       Type
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

Rule is a data container to parametrise Pipelines.

func (*Rule) Validate

func (r *Rule) Validate() error

Validate checks for semantic correctness.

type Service

type Service interface {
	service.Lifecycle

	Put(namespace string, r *Rule) (*Rule, error)
	Query(namespace string, opts QueryOptions) (List, error)
}

Service for rule interactions.

func PostgresService

func PostgresService(db *sqlx.DB) Service

PostgresService returns a Postgres based Service implementation.

type ServiceMiddleware

type ServiceMiddleware func(Service) Service

ServiceMiddleware is a chainable behaviour modifier for Service.

func InstrumentServiceMiddleware

func InstrumentServiceMiddleware(
	component, store string,
	errCount kitmetrics.Counter,
	opCount kitmetrics.Counter,
	opLatency *prometheus.HistogramVec,
) ServiceMiddleware

InstrumentServiceMiddleware observes key aspects of Service operations and exposes Prometheus metrics.

type Templates

type Templates map[string]string

Templates map languages to template strings.

type Type

type Type uint8

Type indicates for which entity the criterias are encoded in the rule.

const (
	TypeConnection Type = iota
	TypeEvent
	TypeObject
	TypeReaction
)

Type to distinct between different stored criteria.

Jump to

Keyboard shortcuts

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