counter

package module
v0.0.0-...-d725791 Latest Latest
Warning

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

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

README

Counter

This activity allows you to use a global counter.

Installation

Flogo CLI
flogo install github.com/project-flogo/contrib/activity/counter

Configuration

Settings:
Name Type Description
counterName string The name of the counter - REQUIRED
op string The counter operation, 'get' is the default operation
Output:
Name Type Description
value int The result of the counter operation

Examples

Increment

The below example increments a 'messages' counter:

{
  "id": "increment_message_count",
  "name": "Increment Message Count",
  "activity": {
    "ref": "github.com/project-flogo/contrib/activity/counter",
    "settings": {
      "counterName": "messages",
      "op": "increment"
    }
  }
}
Get

The below example retrieves the last value of the 'messages' counter:

{
  "id": "get_message_count",
  "name": "Get Message Count",
  "activity": {
    "ref": "github.com/project-flogo/contrib/activity/counter",
    "settings": {
      "counterName": "messages",
      "op": "get"
    }
  }
}
Reset

The below example resets the 'messages' counter:

{
  "id": "reset_message_count",
  "name": "Reset Message Count",
  "activity": {
    "ref": "github.com/project-flogo/contrib/activity/counter",
    "settings": {
      "counterName": "messages",
      "op": "reset"
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

Types

type Activity

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

Activity is a Counter Activity implementation

func (*Activity) Eval

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

Eval implements activity.Activity.Eval

func (*Activity) Metadata

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

Metadata implements activity.Activity.Metadata

type Counter

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

func (*Counter) Get

func (c *Counter) Get() uint64

func (*Counter) Increment

func (c *Counter) Increment() uint64

func (*Counter) Reset

func (c *Counter) Reset() uint64

type CounterFunc

type CounterFunc func() uint64

type Output

type Output struct {
	Value int `md:"value"` // The result of the counter operation
}

type Settings

type Settings struct {
	CounterName string `md:"counterName,required"`            // The name of the counter
	Op          string `md:"op,allowed(get,increment,reset)"` // The counter operation, 'get' is the default operation
}

Jump to

Keyboard shortcuts

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