Documentation
¶
Overview ¶
Package condition provides functions for evaluating data.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operator ¶
Example ¶
package main
import (
"context"
"fmt"
"github.com/brexhq/substation/condition"
"github.com/brexhq/substation/config"
"github.com/brexhq/substation/message"
)
func main() {
ctx := context.TODO()
// Multiple inspectors can be chained together with an operator.
// This example uses the "all" operator, which requires all inspectors to
// return true for the operator to return true.
cfg := condition.Config{
Operator: "all",
Inspectors: []config.Config{
{
Type: "number_length_less_than",
Settings: map[string]interface{}{
"value": 10,
},
},
{
Type: "string_contains",
Settings: map[string]interface{}{
"value": "f",
},
},
},
}
// Operators are retrieved from the factory and
// applied to a message.
op, err := condition.New(ctx, cfg)
if err != nil {
// handle err
panic(err)
}
msg := message.New().SetData([]byte("fizzy"))
if err != nil {
// handle err
panic(err)
}
ok, err := op.Operate(ctx, msg)
if err != nil {
// handle err
panic(err)
}
fmt.Println(ok)
}
Output: true
Source Files
¶
- condition.go
- format_json.go
- format_mime.go
- meta_condition.go
- meta_for_each.go
- meta_negate.go
- network.go
- network_ip_global_unicast.go
- network_ip_link_local_multicast.go
- network_ip_link_local_unicast.go
- network_ip_loopback.go
- network_ip_multicast.go
- network_ip_private.go
- network_ip_unicast.go
- network_ip_unspecified.go
- network_ip_valid.go
- number.go
- number_bitwise_and.go
- number_bitwise_not.go
- number_bitwise_or.go
- number_bitwise_xor.go
- number_length_equal_to.go
- number_length_greater_than.go
- number_length_less_than.go
- string.go
- string_contains.go
- string_ends_with.go
- string_equal_to.go
- string_greater_than.go
- string_less_than.go
- string_match.go
- string_starts_with.go
- utility_random.go
Click to show internal directories.
Click to hide internal directories.