承接 animagram/state-engine 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

animagram/state-engine

Composer 安装命令:

composer require animagram/state-engine

包简介

README 文档

README

Declarative state data management system for a process. Structures state data on process and keeps it syncable using your store clients. It behaves as described in YAML DSL.

Version

Version Status Date description
0.1 Released 2026-2-12 initial
0.1.3 Current 2026-2-26 improve #32
0.1.4 Scheduled 2026-3-8 improve #37

Provided Functions

mod description fn
Manifest reads static YAMLs and returns processed obj get_value(), get_meta()
State operates state data following Manifest get(), set(), delete(), exists()

Why state-engine?

Before:

// Manual cache management
let cache_key = format!("user:{}", id);
let user = redis.get(&cache_key).or_else(|| {
    let user = db.query("SELECT * FROM users WHERE id=?", id)?;
    redis.set(&cache_key, &user, 3600);
    Some(user)
})?;

After:

let user = state.get("cache.user")?;
  • ✅ Multi-tenant DB without junction tables
  • ✅ Automatic KVS/DB synchronization
  • ✅ No manual cache invalidation

Installation

# Cargo.toml
[dependencies]
state-engine = "0.1"

Quick Start

  1. Write a yaml file.
# manifest/example.yml
session:
  user-key:
  _state:
    type: integer
  _store:
    client: InMemory
    key: "request-attributes-user-key"
  _load:
    client: InMemory
    key: "request-header-user-key"


user:
  _store:
    client: KVS
    key: "user:${example.session.user-key}"
  _load:
    client: Db
    table: "users"
    where: "id=${example.session.user-key}"
    map:
      name: "name"
  name:
    _state:
      type: string
case sample
cache in KVS cache.yml
database connection config connection.yml
request scope session.yml
  1. Implement some Required Ports for your stores.
Interface expected store fn sample
InMemoryClient Local Process Memory get() / set() / delete() InMemoryAdapter
KVSClient Key-Vlue Store get() / set() / delete() KVSAdapter
DbClient SQL Database fetch() DbAdapter
EnvClient Environment Variables get() EnvAdapter
  • "Db" and "Env" will be used only in Loading(Read).
  • It's not essential to implement all *Client.
  1. Initialize State with your adapters and use it.
use state_engine::{State, Load};

// Create adapter instances
let mut in_memory = InMemoryAdapter::new();
let mut kvs = KVSAdapter::new()?;
let db = DbAdapter::new()?;

// Build Load with adapters
let load = Load::new()
    .with_in_memory(&mut in_memory)
    .with_kvs_client(&mut kvs)
    .with_db_client(&db);

// Build State with adapters
let mut state = State::new("./manifest", load)
    .with_in_memory(&mut in_memory)
    .with_kvs_client(&mut kvs);

// Use state-engine
let user = state.get("example.user.name")?;

Full working example: examples/app/src/main.rs

Architecture

┌─────────────┐  ┌───────────────────┐
│ Application │  │ manifestDir/*.yml │
└──────┬──────┘  └───────────────────┘
       │ uses             ▲ read
       ▼                  │
┌─────────────────────────┴───────────┐
│     Provided Ports (Public API)     │
├─────────────────────────────────────┤
│                                     │
│      State    -->    Manifest       │
│                                     │
└───────┬─────────────────────────────┘
        │ depends on
        ▼
┌─────────────────────────────────────┐
│    Required Ports (App Adapters)    │
├─────────────────────────────────────┤
│    InMemory, Env, KVS, Db clients   │
└─────────────────────────────────────┘

see for details Architecture.md

tree

./
  README.md           # this file
  Cargo.toml
  docs/               # guide documents
    en/
      Architecture.md
      YAML-guide.md
    ja/
      README.md
      Architecture.md
      YAML-guide.md
  src/
    ports/            # library external interface traits
      provided.rs     # library provides
      required.rs     # Library requires

    common/           # library common mod
      bit.rs
      pool.rs
      parser.rs
      log_format.rs

    manifest.rs       # Manifest impl
    state.rs          # State impl
    store.rs          # Store internal mod
    load.rs           # Load internal mod

  examples/
    manifest/         # manifest YAML examples
      connection.yml  # sample 1
      cache.yml       # sample 2
      session.yml     # sample 3

    adapters/

    app/
      db/
      src/
        main.rs
        adapters.rs
        test_runner.rs   # inetegration tests 
      Cargo.toml
      Dockerfile
      docker-compose.yml

tests

unit tests, intergeration tests on example app (docker compose) passed

  1. cargo test:
cargo test --features=logging -- --nocapture
  1. example application test:
cd examples/app
docker compose up --build

Background

reimagined web architecture

  • computer: A network-capable node in the system.
  • server: A computer that serves human users.
  • orchestrator: A computer responsible for internal system coordination and maintenance. (optional)
  • database: A server that persists data without an inherent expiration and accepts CRUD operations.
  • terminal: A server that provides a direct human-facing interface.
  • conductor: A server that communicates independently with both a database and terminals, and maintains a synchronized state between them. (optional)
# terms relationship
computer:
  orchestrator:
  server:
    database:
    terminal:
    conductor:

License

MIT

animagram/state-engine 适用场景与选型建议

animagram/state-engine 是一款 基于 Rust 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 animagram/state-engine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 animagram/state-engine 我们能提供哪些服务?
定制开发 / 二次开发

基于 animagram/state-engine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Rust

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-03-03