pred

package
v2.0.0-...-072ea80 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package pred provides predicates for basic logic operations.

Predicates with conditional jobs like run.If allows to make non-linear flow. In terms of floc predicate should return true or false depending on context.

  const idReadyFlag = 100

  testReady := func(ctx floc.Context) bool {
	if flag := ctx.Value(idReadyFlag); flag != nil {
      return flag.(bool)
	}

    return false
  }

  flow := run.Sequence(
    ..., // Some job done here
    job.If(testReady, job.Background(writeToDisk)), // Write some data ready to disk in background
    ..., // Some job more
  )

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(predicates ...floc.Predicate) floc.Predicate

And returns a predicate which chains multiple predicates into a condition with AND logic. The result predicate finishes calculation of the condition as fast as the result is known. The function panics if the number of predicates is less than 2.

The result predicate tests the condition as follows.

[PRED_1] AND ... AND [PRED_N]

func Not

func Not(predicate floc.Predicate) floc.Predicate

Not returns the negated value of the predicate.

The result predicate tests the condition as follows.

NOT [PRED]

func Or

func Or(predicates ...floc.Predicate) floc.Predicate

Or returns a predicate which chains multiple predicates into a condition with OR logic. The result predicate finishes calculation of the condition as fast as the result is known.

The result predicate tests the condition as follows.

[PRED_1] OR ... OR [PRED_N]

func Xor

func Xor(predicates ...floc.Predicate) floc.Predicate

Xor returns a predicate which chains multiple predicates into a condition with XOR logic. The result predicate finishes calculation of the condition as fast as the result is known.

The result predicate tests the condition as follows.

(([PRED_1] XOR [PRED_2]) ... XOR [PRED_N])

Types

This section is empty.

Jump to

Keyboard shortcuts

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