tavor: github.com/zimmski/tavor/reduce/strategy Index | Files

package strategy

import "github.com/zimmski/tavor/reduce/strategy"


Package Files

linear.go reducefeedbacktype_string.go strategy.go

func List Uses

func List() []string

List returns a list of all registered reduce strategy names.

func NewLinear Uses

func NewLinear(root token.Token) (chan struct{}, chan<- ReduceFeedbackType, error)

NewLinear implements a reduce strategy that reduces the data through a linear search algorithm. Every step of the strategy generates a new valid token graph state. The generation is deterministic. The algorithm starts by deactivating all optional tokens, this includes for example reducing lists to their minimum repetition. Each step uses the feedback to determine which tokens to reactivate next.

func Register Uses

func Register(name string, strat Strategy)

Register registers a reduce strategy instance function with the given name.

type Error Uses

type Error struct {
    Message string
    Type    ErrorType

Error holds a reduce strategy error

func (*Error) Error Uses

func (err *Error) Error() string

type ErrorType Uses

type ErrorType int

ErrorType the reduce strategy error type

const (
    // ErrEndlessLoopDetected the token graph has a cycle which is not allowed.
    ErrEndlessLoopDetected ErrorType = iota

type ReduceFeedbackType Uses

type ReduceFeedbackType int

ReduceFeedbackType the reduce strategy feedback type

const (
    // Unknown the feedback is of unknown type, this is always a fatal error
    Unknown ReduceFeedbackType = iota
    // Good the reduce step produced a successful result
    // Bad the reduce step produced an unsuccessful result

go:generate stringer -type=ReduceFeedbackType

func (ReduceFeedbackType) String Uses

func (i ReduceFeedbackType) String() string

type Strategy Uses

type Strategy func(root token.Token) (chan struct{}, chan<- ReduceFeedbackType, error)

Strategy defines a reduce strategy The function starts the first step of the reduce strategy returning a channel which controls the step flow and a channel for the feedback of the step. The channel returns a value if the step is complete and waits with calculating the next step until a value is put in and feedback is given. The channels are automatically closed when there are no more steps. The error return argument is not nil if an error occurs during the initialization of the reduce strategy.

func New Uses

func New(name string) (Strategy, error)

New returns a new reduce strategy instance given the registered name of the strategy. The error return argument is not nil, if the name does not exist in the registered reduce strategy list.

Package strategy imports 5 packages (graph). Updated 2017-12-05. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).