Code Monkey home page Code Monkey logo

play-arngin's Introduction

play-arngin

Addon rule engine playground.

Setup

First install Go v1.13 or above. We use Go modules for building the binary without relying on GOPATH. And errors are wrapped using the new %w verb(just cause).

The dependencies can be installed by running go get but this is optional since go build is module aware and will fetch dependencies if required.

Build

$ go build ./cmd/arngin

Usage

$ ./arngin
usage: arngin [<flags>] <command> [<args> ...]

Addon rule engine playground.

Flags:
  -h, --help                     Show context-sensitive help (also try --help-long and --help-man).
  -e, --engines=elastic ...      Addon rule engines to run command against. Accepted values - opa, arango, elastic, all.
      --arango-url="http://localhost:8529"
                                 Endpoint for ArangoDB instance.
      --arango-db-name="arngin"  Database name for ArangoDB.
      --arango-username=ARANGO-USERNAME
                                 Username for ArangoDB instance.
      --arango-password=ARANGO-PASSWORD
                                 Password for ArangoDB instance.
      --elastic-url="http://localhost:9200"
                                 Elasticsearch server URL.

Commands:
  help [<command>...]
    Show help.

  load [<flags>]
    Load addon rules into the rule engine(s). Addon rules are generated randomly.

  query [<flags>]
    Run queries against the rule engine(s). Queries are generated randomly.

Engines

The playground has multiple implementations of the Engine interface with the objective of comparing the performance of loading rules and running queries. with the following:

  • engine/opa: Open Policy Agent is an open source, general-purpose policy engine that unifies policy enforcement across the stack. The rules and match criteria are expressed in Rego, OPA’s policy language.
  • engine/arango: ArangoDB is a multi-model, open-source database with flexible data models for documents, graphs, and key-values. Rules are stored in ArangoDB and AQL is used to match the rules against the query.
  • engine/elasticsearch: Elasticsearch is a distributed, RESTful search and analytics engine. Rules are stored as documents and the Elasticsearch query DSL and aggregations are used to match the rules against the query.

Examples

# Load 1000 rules into all engines, use default endpoints
$ ./arngin load --engines all --count 10000 --arango-username testuser --arango-password testpass --arango-db-name arnginTest
Loaded 1000 rules into opa [took: 9.034712154s]
Loaded 1000 rules into arango [took: 109.521924ms]
Loaded 1000 rules into elastic [took: 848.229276ms]

# Run 100 queries with a concurrency of 4 against opa
$ ./arngin query --engines opa --count 100 --concurrency 4
Ran 100 queries with concurrency of 4 against opa [avg: 362.49385ms]

# Run 1000 queries with a concurrency of 10 against arango and elastic
$ ./arngin query -e arango -e elastic --count 1000 --concurrency 10 --arango-username testuser --arango-password testpass --arango-db-name arnginTest
Ran 1000 queries with concurrency of 10 against arango [avg: 82.168104ms]
Ran 1000 queries with concurrency of 10 against elastic [avg: 7.499732ms]

play-arngin's People

Contributors

dependabot[bot] avatar sudo-suhas avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.