Documentation ¶
Overview ¶
Package filter provides a parser and evaluator for the subscription filter syntax. See https://cloud.google.com/pubsub/docs/filtering for details on this syntax. The syntax supported is that as was documented as of 2021-03-19.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultParserOptions = []participle.Option{
participle.UseLookahead(50),
participle.Unquote("String"),
}
View Source
var Parser = participle.MustBuild[Filter]( DefaultParserOptions..., )
Functions ¶
This section is empty.
Types ¶
type AttributeOperator ¶
type AttributeOperator string
const ( OpEqual AttributeOperator = "=" OpNotEqual AttributeOperator = "!=" )
type AttributePredicate ¶
type AttributePredicate string
const (
PredicateHasPrefix AttributePredicate = "hasPrefix"
)
type BasicExpression ¶
type BasicExpression struct { Has *HasAttribute `parser:"@@" json:",omitempty"` Value *HasAttributeValue `parser:"| @@" json:",omitempty"` Predicate *HasAttributePredicate `parser:"| @@" json:",omitempty"` }
func (*BasicExpression) AsFilter ¶
func (e *BasicExpression) AsFilter(w Writer) error
func (*BasicExpression) Evaluate ¶
func (e *BasicExpression) Evaluate(attrs map[string]string) (bool, error)
func (*BasicExpression) Nil ¶
func (e *BasicExpression) Nil() bool
type BooleanOperator ¶
type BooleanOperator string
const ( OpAND BooleanOperator = "AND" OpOR BooleanOperator = "OR" )
type Condition ¶
type Condition struct { Term *Term `parser:"@@" json:",omitempty"` And []*Term `parser:"( (\"AND\" @@ )+" json:",omitempty"` Or []*Term `parser:"| (\"OR\" @@)+ )?" json:",omitempty"` }
type HasAttribute ¶
type HasAttribute struct {
Name string `parser:"\"attributes\" \":\" @(Ident|String)"`
}
func (*HasAttribute) AsFilter ¶
func (e *HasAttribute) AsFilter(w Writer) error
func (*HasAttribute) Evaluate ¶
func (e *HasAttribute) Evaluate(attrs map[string]string) (bool, error)
func (*HasAttribute) Nil ¶
func (e *HasAttribute) Nil() bool
type HasAttributePredicate ¶
type HasAttributePredicate struct { Predicate AttributePredicate `parser:"@(\"hasPrefix\")\"(\""` Name string `parser:"\"attributes\" \".\" @(Ident|String) \",\""` Value string `parser:"@String \")\""` }
func (*HasAttributePredicate) AsFilter ¶
func (e *HasAttributePredicate) AsFilter(w Writer) error
func (*HasAttributePredicate) Evaluate ¶
func (e *HasAttributePredicate) Evaluate(attrs map[string]string) (bool, error)
func (*HasAttributePredicate) Nil ¶
func (e *HasAttributePredicate) Nil() bool
type HasAttributeValue ¶
type HasAttributeValue struct { Name string `parser:"\"attributes\" \".\" @(Ident|String)"` Op AttributeOperator `parser:"@(\"=\" | \"!\" \"=\")"` Value string `parser:"@String"` }
func (*HasAttributeValue) AsFilter ¶
func (e *HasAttributeValue) AsFilter(w Writer) error
func (*HasAttributeValue) Evaluate ¶
func (e *HasAttributeValue) Evaluate(attrs map[string]string) (bool, error)
func (*HasAttributeValue) Nil ¶
func (e *HasAttributeValue) Nil() bool
type NillableEvaluator ¶
type Term ¶
type Term struct { Not bool `parser:"@(\"NOT\"|\"-\")?"` Basic *BasicExpression `parser:"( @@" json:",omitempty"` Sub *Condition `parser:"| \"(\" @@ \")\" )" json:",omitempty"` }
Click to show internal directories.
Click to hide internal directories.