{"id":34170899,"url":"https://github.com/hungpdn/grule-plus","last_synced_at":"2026-05-28T08:31:36.421Z","repository":{"id":308590282,"uuid":"1033382780","full_name":"hungpdn/grule-plus","owner":"hungpdn","description":"Fast, scalable and flexible rule engine for Go.","archived":false,"fork":false,"pushed_at":"2025-12-11T16:32:36.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-18T07:30:18.034Z","etag":null,"topics":["golang","rule-based","rule-engine","scalability"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hungpdn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["hungpdn"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-08-06T18:18:24.000Z","updated_at":"2025-12-11T16:32:40.000Z","dependencies_parsed_at":"2025-08-06T19:48:12.919Z","dependency_job_id":"691a7e56-6694-4345-a953-c6b8b942c7d3","html_url":"https://github.com/hungpdn/grule-plus","commit_stats":null,"previous_names":["hungpdn/grule-plus"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hungpdn/grule-plus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fgrule-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fgrule-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fgrule-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fgrule-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hungpdn","download_url":"https://codeload.github.com/hungpdn/grule-plus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fgrule-plus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33601380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","rule-based","rule-engine","scalability"],"created_at":"2025-12-15T11:03:46.235Z","updated_at":"2026-05-28T08:31:36.416Z","avatar_url":"https://github.com/hungpdn.png","language":"Go","funding_links":["https://github.com/sponsors/hungpdn"],"categories":[],"sub_categories":[],"readme":"# grule-plus\n\n[![Go Version](https://img.shields.io/badge/go-%3E%3D1.21-blue.svg)](https://golang.org/)\n[![CI](https://github.com/hungpdn/grule-plus/workflows/CI/badge.svg)](https://github.com/hungpdn/grule-plus/actions)\n[![codecov](https://codecov.io/gh/hungpdn/grule-plus/branch/main/graph/badge.svg)](https://codecov.io/gh/hungpdn/grule-plus)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hungpdn/grule-plus)](https://goreportcard.com/report/github.com/hungpdn/grule-plus)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**grule-plus** is a high-performance, extensible rule engine built on top of [Grule Rule Engine](https://github.com/hyperjumptech/grule-rule-engine). It provides advanced caching, partitioning, and flexible configuration for scalable rule evaluation in Go applications.\n\n---\n\n## Features\n\n- **Pluggable Cache Engines:** Supports LRU (Least Recently Used), LFU (Least Frequently Used), ARC (Adaptive Replacement Cache), and RANDOM cache strategies.\n- **Partitioned Rule Engine:** Scale horizontally with partitioned engines for concurrent rule evaluation.\n- **Consistent Hashing:** Efficient key distribution across partitions with minimal remapping on node changes.\n- **Flexible TTL \u0026 Cleanup:** Per-rule time-to-live and periodic cleanup for cache entries.\n- **Structured Logging:** Integrated with Go's `slog` for context-aware, structured logs.\n- **Runtime Stats:** Built-in runtime statistics for monitoring and debugging.\n- **Thread-Safe:** Safe for concurrent use in multi-goroutine environments.\n\n---\n\n## Benchmarks\n\nComprehensive benchmarks are available in the `benchmark/` directory, testing cache performance, engine throughput, and memory usage across different configurations. See [benchmark/README.md](benchmark/README.md) for detailed results and usage instructions.\n\n---\n\n## Getting Started\n\n### Installation\n\n```sh\ngo get github.com/hungpdn/grule-plus\n```\n\n### Example Usage\n\n```go\nimport (\n    \"context\"\n    \"github.com/hungpdn/grule-plus/engine\"\n)\n\nfunc main() {\n    cfg := engine.Config{\n        Type:            engine.LRU,\n        Size:            1000,\n        CleanupInterval: 10,\n        TTL:             60,\n        Partition:       1,\n        FactName:        \"DiscountFact\",\n    }\n    grule := engine.NewPartitionEngine(cfg, nil)\n\n    rule := \"DiscountRule\"\n    statement := `rule DiscountRule \"Apply discount\" salience 10 { \n                when \n                    DiscountFact.Amount \u003e 100 \n                then \n                    DiscountFact.Discount = 10; \n                    Retract(\"DiscountRule\");\n                }`\n    _ = grule.AddRule(rule, statement, 60)\n\n    fact := struct {\n        Amount   int\n        Discount int\n    }{Amount: 150}\n\n    _ = grule.Execute(context.Background(), rule, \u0026fact)\n    \n    fmt.Printf(\"fact.Discount = 10: %v\", fact.Discount)\n}\n```\n\n---\n\n## Configuration\n\nSee `engine.Config` for all available options:\n\n- `Type`: Cache type (LRU, LFU, ARC, TWOQ, RANDOM)\n- `Size`: Maximum cache size\n- `CleanupInterval`: Cache cleanup interval (seconds)\n- `TTL`: Default time-to-live for rules (seconds)\n- `Partition`: Number of partitions for parallelism\n\n---\n\n## Documentation\n\nComprehensive documentation is available in the `docs/` directory:\n\n- **[API Reference](docs/api.md)** - Complete API documentation\n- **[Architecture](docs/architecture.md)** - System design and components\n- **[Cache Types](docs/cache-types.md)** - Cache algorithm explanations\n- **[Configuration](docs/configuration.md)** - Setup and tuning guide\n- **[Benchmarks](docs/benchmarks.md)** - Performance testing and results\n- **[Examples](docs/examples.md)** - Usage patterns and code samples\n\n### Building Documentation\n\n```bash\n# Install MkDocs (optional)\npip install mkdocs mkdocs-material\n\n# Serve docs locally\ncd docs \u0026\u0026 mkdocs serve\n\n# Or use godoc for API docs\ngodoc -http=:6060\n```\n\n---\n\n## Security\n\nPlease report security vulnerabilities by LinkedIn [**hungpdn**](https://www.linkedin.com/in/hungpdn/) (not through public issues). See [SECURITY.md](SECURITY.md) for details.\n\n---\n\n## TODO\n\n- Metrics \u0026 Monitoring System (execution time, success/failure rates, cache hit/miss ratios, ...)\n\n---\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungpdn%2Fgrule-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhungpdn%2Fgrule-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungpdn%2Fgrule-plus/lists"}