All Projects → zhouzhuojie → conditions

zhouzhuojie / conditions

Licence: MIT license
Minimalist rules engine for Golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to conditions

NiFi-Rule-engine-processor
Drools processor for Apache NiFi
Stars: ✭ 34 (+17.24%)
Mutual labels:  rules-engine
Rulesengine
A Json based Rules Engine with extensive Dynamic expression support
Stars: ✭ 714 (+2362.07%)
Mutual labels:  rules-engine
Json Rules Engine
A rules engine expressed in JSON
Stars: ✭ 1,159 (+3896.55%)
Mutual labels:  rules-engine
Easy Rules
The simple, stupid rules engine for Java
Stars: ✭ 3,522 (+12044.83%)
Mutual labels:  rules-engine
Node Rules
Node-rules is a light weight forward chaining rule engine written in JavaScript.
Stars: ✭ 481 (+1558.62%)
Mutual labels:  rules-engine
Roulette
A text/template based rules engine
Stars: ✭ 32 (+10.34%)
Mutual labels:  rules-engine
rules
One Framework to build a highly declarative and customizable UI without using templates.
Stars: ✭ 38 (+31.03%)
Mutual labels:  rules-engine
Windup
Windup - Application Migration and Assessment Tool
Stars: ✭ 129 (+344.83%)
Mutual labels:  rules-engine
Rulebook
100% Java, Lambda Enabled, Lightweight Rules Engine with a Simple and Intuitive DSL
Stars: ✭ 562 (+1837.93%)
Mutual labels:  rules-engine
Grules
A simple, but expandable, rules engine for Go
Stars: ✭ 65 (+124.14%)
Mutual labels:  rules-engine
Gamification Engine
gamification-engine (gengine) is a framework for developing gamification features for your application
Stars: ✭ 286 (+886.21%)
Mutual labels:  rules-engine
Peasy.net
A business logic micro-framework for .NET and .NET Core
Stars: ✭ 406 (+1300%)
Mutual labels:  rules-engine
Nrules
Rules engine for .NET, based on the Rete matching algorithm, with internal DSL in C#.
Stars: ✭ 1,003 (+3358.62%)
Mutual labels:  rules-engine
cel-python
Pure Python implementation of the Common Expression Language
Stars: ✭ 33 (+13.79%)
Mutual labels:  rules-engine
Rules
Generic Rules engine in golang
Stars: ✭ 96 (+231.03%)
Mutual labels:  rules-engine
evrete
Evrete is a lightweight and intuitive Java rule engine.
Stars: ✭ 37 (+27.59%)
Mutual labels:  rules-engine
Rulerz
Powerful implementation of the Specification pattern in PHP
Stars: ✭ 827 (+2751.72%)
Mutual labels:  rules-engine
Actorcloud
Open-source IoT Platform
Stars: ✭ 138 (+375.86%)
Mutual labels:  rules-engine
Kogito Examples
Kogito examples - Kogito is a cloud-native business automation technology for building cloud-ready business applications.
Stars: ✭ 96 (+231.03%)
Mutual labels:  rules-engine
Nrules.language
Business rules language for NRules rules engine.
Stars: ✭ 55 (+89.66%)
Mutual labels:  rules-engine

conditions

This package offers a parser of a simple conditions specification language (reduced set of arithmetic/logical operations). The package is mainly created for Flow-Based Programming components that require configuration to perform some operations on the data received from multiple input ports. But it can be used whereever you need externally define some logical conditions on the internal variables.

Additional credits for this package go to Handwritten Parsers & Lexers in Go by Ben Johnson on Gopher Academy blog and InfluxML package from InfluxDB repository.

Usage example

package main

import (
    "fmt"
    "strings"

    "github.com/zhouzhuojie/conditions"
)

func main() {
    // Our condition to check
    s := `({foo} > 0.45) AND ({bar} == "ON" OR {baz} IN ["ACTIVE", "CLEAR"])`

    // Parse the condition language and get expression
    p := conditions.NewParser(strings.NewReader(s))
    expr, err := p.Parse()
    if err != nil {
        // ...
    }

    // Evaluate expression passing data for $vars
    data := map[string]interface{}{"foo": 0.12, "bar": "OFF", "baz": "ACTIVE"}
    r, err := conditions.Evaluate(expr, data)
    if err != nil {
        // ...
    }

    // r is false
    fmt.Println("Evaluation result:", r)
}

Credit

Forked from https://github.com/oleksandr/conditions

The main differences are

  • Changed the syntax of variables from [foo] to {foo}.
  • Added CONTAINS.
  • Added float comparison with epsilon error torlerence.
  • Optimized long array IN/CONTAINS operator.
  • Removed redundant RWMutex for better performance.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].