constraint

package
v0.0.0-...-335d32b Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package constraint provides functions for building session constraints for use with rinq.Session.NotifyMany().

Index

Constants

This section is empty.

Variables

View Source
var None = Constraint{Op: noneOp}

None is a Constraint that always evaluates to true, and hence provides "no constraint" on the sessions that receive the notification.

Functions

This section is empty.

Types

type Constraint

type Constraint struct {
	Op    op           `json:"o,omitempty"`
	Terms []Constraint `json:"t,omitempty"`
	Key   string       `json:"k,omitempty"`
	Value string       `json:"v,omitempty"`
}

Constraint is a boolean expression evaluated against session attribute values to determine which sessions receive a multicast notification.

See Session.NotifyMany() to send a multicast notification.

func And

func And(cons ...Constraint) Constraint

And returns a Constraint that evaluates to true when all constraints in cons evaluate to true.

func Empty

func Empty(k string) Constraint

Empty returns a Constraint that evaluates to true when the attribute k has a value equal to the empty string.

func Equal

func Equal(k, v string) Constraint

Equal returns a Constraint that evaluates to true when the attribute k is equal to v.

func Not

func Not(con Constraint) Constraint

Not returns a Constraint that evaluates to true when e evaluates to false, and vice-versa.

func NotEmpty

func NotEmpty(k string) Constraint

NotEmpty returns a Constraint that evaluates to true when the attribute k has a value not equal to the empty string.

func NotEqual

func NotEqual(k, v string) Constraint

NotEqual returns a Constraint that evaluates to true when the attribute k is not equal to v.

func Or

func Or(cons ...Constraint) Constraint

Or returns a Constraint that evaluates to true when one or more of the constraints in cons evaluate to true.

func Within

func Within(ns string, cons ...Constraint) Constraint

Within returns a Constraint that evaluates to true when each constraint in cons evaluates to true within the ns namespace.

func (Constraint) Accept

func (c Constraint) Accept(v Visitor, args ...interface{}) (interface{}, error)

Accept calls the method on v that corresponds to the operation type of c.

func (Constraint) And

func (c Constraint) And(con Constraint) Constraint

And returns a Constraint that evaluates to true if both c and con evaluate to true.

func (Constraint) Or

func (c Constraint) Or(con Constraint) Constraint

Or returns a Constraint that evaluates to true if at least one of c and con evaluate to true.

func (Constraint) String

func (c Constraint) String() string

func (Constraint) Validate

func (c Constraint) Validate() error

Validate returns nil if c is a valid constraint.

type Visitor

type Visitor interface {
	None(args ...interface{}) (interface{}, error)
	Within(ns string, cons []Constraint, args ...interface{}) (interface{}, error)
	Equal(k, v string, args ...interface{}) (interface{}, error)
	NotEqual(k, v string, args ...interface{}) (interface{}, error)
	Not(con Constraint, args ...interface{}) (interface{}, error)
	And(cons []Constraint, args ...interface{}) (interface{}, error)
	Or(cons []Constraint, args ...interface{}) (interface{}, error)
}

Visitor is used to walk a constraint hierarchy.

Jump to

Keyboard shortcuts

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