{"id":51485810,"url":"https://github.com/grab/liteflags-rs","last_synced_at":"2026-07-07T06:30:31.144Z","repository":{"id":368985349,"uuid":"1262579990","full_name":"grab/liteflags-rs","owner":"grab","description":null,"archived":false,"fork":false,"pushed_at":"2026-07-03T03:20:57.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-03T05:23:04.825Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2026-06-08T05:54:49.000Z","updated_at":"2026-07-03T03:21:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/grab/liteflags-rs","commit_stats":null,"previous_names":["grab/liteflags-rs"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/grab/liteflags-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fliteflags-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fliteflags-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fliteflags-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fliteflags-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grab","download_url":"https://codeload.github.com/grab/liteflags-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grab%2Fliteflags-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35218117,"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-07-07T02:00:07.222Z","response_time":90,"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":[],"created_at":"2026-07-07T06:30:30.557Z","updated_at":"2026-07-07T06:30:31.138Z","avatar_url":"https://github.com/grab.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Liteflags-rs\n\nA lightweight Rust library for feature flag evaluation. It comes with a default flag loader for YAML type. Flag loading is decoupled and custom source (e.g., Flag config stored in JSON file, Database) can be used and then supplied to library's FlagStore.\n\n## Features\n\n- **Multiple flag types**: boolean, string, number\n- **Rule-based evaluation**: Using Rhai expressions for complex conditions\n- **Percentage rollouts**: Gradual feature releases\n- **Experiment windows**: Time-bounded experiments\n- **Namespaces**: Organize flags by context\n- **Real-time updates**: Hot-reload flag configurations\n\n## Quick Start\n\n### 1. Add to Cargo.toml\n\n```toml\n[dependencies]\nliteflags-rs = \"0.1.1\"\n```\n\n### 2. Create flag configuration (YAML)\n\n```yaml\nmy_namespace:\n  my_feature:\n    type: bool\n    variations:\n      enabled: true\n      disabled: false\n    default: disabled\n    rules:\n      - query: 'premium == true \u0026\u0026 region == \"US\"'\n        percentage:\n          enabled: 100\n          disabled: 0\n```\n\n### 3. Basic usage\n\n```rust\nuse liteflags-rs::{FlagStore, FlagEvaluator, FlagEvalEngine};\nuse std::collections::HashMap;\nuse serde_json::json;\n\n// Load flags from YAML\nlet flags = liteflags-rs::flag_loaders::yaml::load_flags(\"flags.yaml\")?;\n\n// Create store and evaluator\nlet store = FlagStore::new(flags);\nlet engine = FlagEvalEngine::new();\n\n// Evaluate flags\nlet request = liteflags-rs::dto::EvalRequest {\n    namespace: \"my_namespace\".to_string(),\n    flags: vec![\"my_feature\".to_string()],\n    data: HashMap::from([\n        (\"premium\".to_string(), json!(true)),\n        (\"region\".to_string(), json!(\"US\")),\n    ]),\n    include_reason: true,\n    rollout_target_key: Some(\"user-123\".to_string()), // For percentage-based rollouts\n};\n\nlet result = FlagEvaluator::evaluate_flags(\u0026store, request, \u0026engine)?;\n\n// Access the result\nprintln!(\"{:?}\", result.0[\"my_feature\"].value); // true\nprintln!(\"{:?}\", result.0[\"my_feature\"].reason); // Some(\"RULE_MATCH\")\n```\n\n### 4. Using Custom Functions (Advanced)\n\nLiteflags-rs supports custom functions for semantic versioning comparisons:\n\n```rust\nuse liteflags-rs::{FlagStore, FlagEvaluator, create_enhanced_engine};\nuse std::collections::HashMap;\nuse serde_json::json;\n\n// Create enhanced engine with custom functions\nlet engine = create_enhanced_engine()?;\n\n// Now you can use advanced rules like:\nlet request = liteflags-rs::dto::EvalRequest {\n    namespace: \"my_namespace\".to_string(),\n    flags: vec![\"advanced_feature\".to_string()],\n    data: HashMap::from([\n        (\"app_version\".to_string(), json!(\"2.1.0\")),\n    ]),\n    include_reason: true,\n    rollout_target_key: Some(\"user-123\".to_string()),\n};\n\nlet result = FlagEvaluator::evaluate_flags(\u0026store, request, \u0026engine)?;\n```\n\n#### Available Custom Functions\n\n**Semantic Version Function:**\n- `semver(version1, operator, version2)` - Compare versions with operator\n  - Supported operators: `\u003e`, `\u003e=`, `\u003c`, `\u003c=`, `==`, `!=`\n  - Example: `semver(app_version, \"\u003e=\", \"2.0.0\")`\n\n#### Advanced Rule Examples\n\n```yaml\nmy_namespace:\n  version_feature:\n    type: bool\n    variations:\n      enabled: true\n      disabled: false\n    default: disabled\n    rules:\n      # Enable for app version \u003e= 2.0.0\n      - query: 'semver(app_version, \"\u003e=\", \"2.0.0\")'\n        percentage:\n          enabled: 100\n```\n\n## Percentage Rollouts\n\nThe `rollout_target_key` field is used for deterministic percentage-based rollouts. This key (typically a user ID or entity ID) is hashed to consistently assign users to the same variant.\n\n**Without rollout_target_key:**\n- Rules with percentage distribution are **skipped**\n- Falls back to the default value\n\n**With rollout_target_key:**\n- Rules with percentage distribution are evaluated\n- User is consistently assigned to the same variant based on their key\n\n## Development\n\n### With Nix (Recommended)\n```bash\ncd liteflags-rs\nnix develop       # Enter development environment  \ncargo test        # Run tests (16 tests)\ncargo build       # Build library\ncargo doc --open  # Generate documentation\n```\n\n### Without Nix\n```bash\ncargo test        # Run tests\ncargo build       # Build library\n```\n\n## YAML Configuration\n\nFlag definitions support:\n- `type`: `bool`, `string`, `number`\n- `variations`: Map of variant names to values\n- `default`: Default variant name (optional in v0.1.1+)\n- `rules`: List of conditional rules with percentage rollouts\n- `experiment`: Optional time window for experiments\n\n### Optional Defaults (v0.1.1+)\nFlags can now omit the `default` field. When no default is specified and no rules match, the flag is excluded from evaluation results.\n\n\n## Maintainer\nThe package is maintained by [Md Riyadh](https://github.com/riyadhctg) and [Jialong Loh](https://github.com/jlloh)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrab%2Fliteflags-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrab%2Fliteflags-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrab%2Fliteflags-rs/lists"}