examples/

directory
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT

README ΒΆ

πŸš€ Go Rules Engine Examples

This directory contains various examples to help you get started with the rules engine. Each example illustrates a specific feature of the engine.

πŸ“‚ List of Examples

Folder Description
basic Fundamental usage: simple age check with static facts.
advanced Advanced usage: dynamic facts, priorities, and complex logic.
json Loading rules and facts from JSON files or strings.
builder Using RuleBuilder to construct rules elegantly (fluent API).
audit-trace New: Extraction and JSON serialization of the full evaluation history (Audit Trace).
hot-reload New: Real-time rule updates via a remote source (HTTP).
parallel New: Parallel rule execution to optimize performance with slow facts.
metrics New: How to implement monitoring and observability (Prometheus).
api New: Wrapping the engine in a stateless REST API with net/http.
custom-operator How to extend the engine by adding your own custom operators.

πŸ›  How to run the examples

You can run any example using the go run command from the root of the project or directly within the example's folder.

From the root:

go run docs/examples/basic/main.go

From the example folder:

cd docs/examples/builder
go run main.go

πŸ’‘ Which example to choose?

  • Beginner? Start with basic. It's the simplest way to understand the "Fact / Condition / Rule" workflow.
  • Need to load configurations? Check out json or hot-reload for dynamic loading.
  • Need performance or complex business logic? See advanced to discover dynamic facts (callbacks) and parallel for concurrent execution.
  • Observability is a priority? Look at metrics to see how to connect Prometheus.
  • Don't like writing JSON by hand? The builder is for you.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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