filter

package module
v0.0.0-...-2ed5266 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Filter

This activity allows you to filter out data in a streaming pipeline, can also be used in flows.

Installation

Flogo CLI
flogo install github.com/project-flogo/stream/activity/filter

Metadata

{
  "settings": [
    {
      "name": "type",
      "type": "string",
      "required": true,
      "allowed" : ["non-zero"]
    },
    {
      "name": "proceedOnlyOnEmit",
      "type": "boolean"
    }
  ],
  "input":[
    {
      "name": "value",
      "type": "any"
    }
  ],
  "output": [
    {
      "name": "filtered",
      "type": "boolean"
    },
    {
      "name": "value",
      "type": "any"
    }
  ]
}
Details
Settings:
Setting Required Description
type true The type of filter to apply (ex. non-zero)
proceedOnlyOnEmit false Indicates that the next activity should proceed, true by default
note : if using this activity in a flow, proceedOnlyOnEmit should be set to false
Input:
Name Description
value The input value
Output:
Name Description
filtered Indicates if the value was filtered out
value The input value, it is 0 if it was filtered out

Example

The example below filters out all zero 'movement' readings

{
  "id": "filter1",
  "name": "Filter",
  "activity": {
    "ref": "github.com/project-flogo/activity/filter",
    "settings": {
      "type": "non-zero"
    },
    "mappings": {
      "input": [
        {
          "type": "assign",
          "value": "movement",
          "mapTo": "value"
        }
      ]
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonZero

func IsNonZero(val interface{}) bool

func New

Types

type Activity

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

Activity is an Activity that is used to Filter a message to the console

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements api.Activity.Eval - Filters the Message

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata returns the activity's metadata

type Filter

type Filter interface {
	FilterOut(val interface{}) bool
}

type Input

type Input struct {
	Value interface{} `md:"value"`
}

type NonZeroFilter

type NonZeroFilter struct {
}

func (*NonZeroFilter) FilterOut

func (*NonZeroFilter) FilterOut(val interface{}) bool

type Output

type Output struct {
	Filtered bool        `md:"filtered"`
	Value    interface{} `md:"value"`
}

type Settings

type Settings struct {
	Type              string `md:"type,allowed(non-zero)"`
	ProceedOnlyOnEmit bool
}

we can generate json from this! - we could also create a "validate-able" object from this

Jump to

Keyboard shortcuts

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