{"id":31809239,"url":"https://github.com/cwahn/kameo-persistence","last_synced_at":"2025-10-11T05:23:49.490Z","repository":{"id":304020356,"uuid":"1017566714","full_name":"cwahn/kameo-persistence","owner":"cwahn","description":"Persistence add-on for Kameo, a Rust actor framework","archived":false,"fork":false,"pushed_at":"2025-07-10T18:59:56.000Z","size":24,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-20T14:45:03.201Z","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/cwahn.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}},"created_at":"2025-07-10T18:26:05.000Z","updated_at":"2025-07-12T20:22:06.000Z","dependencies_parsed_at":"2025-07-10T23:29:21.102Z","dependency_job_id":"73c2b98a-7017-4666-a919-cbb83378904f","html_url":"https://github.com/cwahn/kameo-persistence","commit_stats":null,"previous_names":["cwahn/kameo-persistence"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cwahn/kameo-persistence","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fkameo-persistence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fkameo-persistence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fkameo-persistence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fkameo-persistence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwahn","download_url":"https://codeload.github.com/cwahn/kameo-persistence/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwahn%2Fkameo-persistence/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006351,"owners_count":26084084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"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":"2025-10-11T05:23:44.607Z","updated_at":"2025-10-11T05:23:49.478Z","avatar_url":"https://github.com/cwahn.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kameo-persistence\n\nPersistence add-on for [Kameo](https://github.com/tqwewe/kameo) providing snapshot-based backup and restore of actors.\n\n## Installation\n\n```bash\ncargo add kameo-persistence\n```\n\n## Quick Start\n\n```rust\nuse std::{\n    collections::HashMap,\n    sync::{Arc, Mutex},\n};\n\nuse kameo::prelude::*;\nuse kameo_persistence::PersistentActor;\nuse serde::{Deserialize, Serialize};\nuse url::Url;\n\n#[derive(Debug, Clone, PersistentActor)]\npub struct ManagerActor {\n    pub data: String,\n    pub sub_actors: HashMap\u003cString, ActorRef\u003cSubActor\u003e\u003e,\n}\n\n#[derive(Debug, Clone, Serialize, Deserialize)]\npub struct ManagerActorArgs {\n    pub data: String,\n    pub sub_actors: HashMap\u003cString, Url\u003e,\n}\n\nimpl From\u003c\u0026ManagerActor\u003e for ManagerActorArgs {\n    fn from(actor: \u0026ManagerActor) -\u003e Self {\n        Self {\n            data: actor.data.clone(),\n            sub_actors: actor\n                .sub_actors\n                .iter()\n                .filter_map(|(name, actor_ref)| {\n                    PersistentActor::persistence_key(actor_ref).map(|url| (name.clone(), url))\n                })\n                .collect(),\n        }\n    }\n}\n\nimpl Actor for ManagerActor {\n    type Args = ManagerActorArgs;\n    type Error = anyhow::Error;\n\n    async fn on_start(args: Self::Args, _actor_ref: ActorRef\u003cSelf\u003e) -\u003e Result\u003cSelf, Self::Error\u003e {\n        Ok(Self {\n            data: args.data,\n            sub_actors: args\n                .sub_actors\n                .into_iter()\n                .filter_map(|(name, url)| {\n                    SubActor::respawn_persistent(url)\n                        .await\n                        .ok()\n                        .map(|actor_ref| (name, actor_ref))\n                })\n                .collect()?,\n        })\n    }\n}\n\n#[derive(Debug, Clone, Actor, Serialize, Deserialize, PersistentActor)]\npub struct SubActor {\n    pub config: String,\n}\n\nimpl From\u003c\u0026SubActor\u003e for SubActor {\n    fn from(actor: \u0026SubActor) -\u003e Self {\n        actor.clone()\n    }\n}\n```\n\n## Key Methods\n\n- `PersistentActor` - A trait provides methods for persistent actors (derivable)\n  - `spawn_persistent(key, args)` - Create a new persistent actor\n  - `respawn_persistent(key)` - Restore an actor from snapshot\n  - `try_respawn_persistent(key, args)` - Restore or create a new actor if not found\n  - `save_snapshot(actor_ref)` - Save the current state of the actor\n  - `persistence_key(actor_ref)` - Get the persistence key for the actor\n\n## Storage\n\nCurrently supports file-based storage using URLs like `file:///path/to/snapshot`. However, HTTP(s), WebScockets, or Aws S3 like storages will be supported in the future.\n\n## Examples\n\nSee `examples/` directory for detailed usage including:\n- Manager actors with sub-actors\n- Custom snapshot types\n- Message handling with auto-save\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwahn%2Fkameo-persistence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwahn%2Fkameo-persistence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwahn%2Fkameo-persistence/lists"}