{"id":19332157,"url":"https://github.com/4t145/moonbase","last_synced_at":"2026-06-15T03:32:10.158Z","repository":{"id":245730731,"uuid":"818209304","full_name":"4t145/moonbase","owner":"4t145","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-02T09:46:19.000Z","size":108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-06T08:44:06.342Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4t145.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-06-21T10:36:02.000Z","updated_at":"2024-07-02T09:46:23.000Z","dependencies_parsed_at":"2024-06-23T18:59:29.458Z","dependency_job_id":"3a549d41-061a-4a24-9427-ebf60943a12f","html_url":"https://github.com/4t145/moonbase","commit_stats":null,"previous_names":["4t145/moonbase"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4t145%2Fmoonbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4t145%2Fmoonbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4t145%2Fmoonbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4t145%2Fmoonbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4t145","download_url":"https://codeload.github.com/4t145/moonbase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240434297,"owners_count":19800550,"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","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":"2024-11-10T02:44:13.174Z","updated_at":"2026-06-15T03:32:05.129Z","avatar_url":"https://github.com/4t145.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moonbase\n\n\u003e Fly me to the moon, and let me play among the stars.\n\n**Moonbase** is a meta framework which provides a **easy** way to create a **maintainable** service.\n\n## What can Moonbase Provide?\n\nIt's basically a easy-to-use **state** for your web framework. And you can build your own business context based on a `AppContext` aka `Moonbase`.\n\n\n### A way to get **RESOURCE**\n\nIf you are addicted to global static resource, moonbase can provide a alterative way to get app-wise unique resource by `MoonbaseResource` from anywhere in your program.\n\n```rust\nlet AppName(app_name) = app.get_resource::\u003cAppName\u003e();\n```\n### A way to get **COMPONENT**\n\nOk, your resource may be a module-wise resource, a temporary state, or some random thing you want to share between tasks. You can store them as a `MoonbaseComponent`. And you can get the resource by a 2-tuple of `Type` and `\u0026str`.\n\n\n```rust\nlet mail_config = app.get_component::\u003cMailConfig\u003e(\u0026module_name);\n```\n\n### A way to use **CONTEXT**\n\nGet anything you want from a certain context in your code, as long as the thing can be **EXTRACTED** from the context.\n\n\nYou may handler request like this:\n```rust\nasync fn handle_some_request(redis_client: RedisClient, http_client: HttpClient, config: Arc\u003cMyModuleConfig\u003e, db_connection: Db, ...) -\u003e Result\u003c(), Error\u003e {\n    ...\n}\n```\n\nJust pass this handler to a certain context after you implemented `Extract\u003cMyContext\u003e` for them!\n```rust\nrequest_context.fallible_call(handle_some_request).await?;\n```\n\n### A way to manage **DAEMON**\n\nDon't spawn your task **everywhere**, and then you don't know their status at all. Instead, let them be managed by our engineers in the **Moonbase**.\n\n```rust\nasync fn run(app: \u0026Moonbase) {\n    // do some initializations\n    app.run_daemon::\u003cAxumWebService\u003e().await?;\n    app.run_daemon::\u003cListenConfigChangeService\u003e().await?;\n    app.run_daemon::\u003cRunCronBotService\u003e().await?;\n    app.run_daemon::\u003cDoSomeRandomThingService\u003e().await?;\n    let handle = app.run_daemon::\u003cListenShutdownSignal\u003e().await?;\n    handle.wait().await;\n}\n```\n\n### A way to share **SIGNAL**\n```rust\npub struct MySignalSymbol;\nasync fn async_main() -\u003e anyhow::Result\u003c()\u003e {\n    moonbase.set_signal(SignalKey::from_type::\u003cMySignalSymbol\u003e(), Signal::new());\n    let signal = moonbase.get_signal(\u0026SignalKey::symbol::\u003cMySignalSymbol\u003e()).unwrap();\n    signal.get_sender().send();\n    signal.recv().await;\n    Ok(())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4t145%2Fmoonbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4t145%2Fmoonbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4t145%2Fmoonbase/lists"}