Help us shape the future of Go! Take the 2026 Go Developer Survey

filter

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Accept indicates that the message should be processed
	Accept = iota
	// Reject indicates that the message should not be processed
	Reject
	// Forward indicates that the rule could not determine the correct course of action
	Forward
)

Variables

View Source
var AcceptRule = Rule(acceptRule{})

AcceptRule always returns Accept as a result for Apply

View Source
var EmptyRejectRule = Rule(emptyRejectRule{})

EmptyRejectRule rejects empty messages

View Source
var NoopCommitter = Committer(noopCommitter{})

NoopCommitter does nothing on commit and is not isolated

Functions

This section is empty.

Types

type Action

type Action int

Action is used to express the output of a rule

type Committer

type Committer interface {
	// Commit performs whatever action should be performed upon committing of a message
	Commit()

	// Isolated returns whether this transaction should have a block to itself or may be mixed with other transactions
	Isolated() bool
}

Committer is returned by postfiltering and should be invoked once the message has been written to the blockchain

type Rule

type Rule interface {
	// Apply applies the rule to the given Envelope, replying with the Action to take for the message
	// If the filter Accepts a message, it should provide a committer to use when writing the message to the chain
	Apply(message *ab.Envelope) (Action, Committer)
}

Rule defines a filter function which accepts, rejects, or forwards (to the next rule) an Envelope

type RuleSet

type RuleSet struct {
	// contains filtered or unexported fields
}

RuleSet is used to apply a collection of rules

func NewRuleSet

func NewRuleSet(rules []Rule) *RuleSet

NewRuleSet creates a new RuleSet with the given ordered list of Rules

func (*RuleSet) Apply

func (rs *RuleSet) Apply(message *ab.Envelope) (Committer, error)

Apply applies the rules given for this set in order, returning the committer, nil on valid, or nil, err on invalid

Jump to

Keyboard shortcuts

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