frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Ask HN: Is this a sane way to expose distributed state in Rust?

1•asdfghjqwertyu•1mo ago
Hi HN,

I’m experimenting with a Rust runtime that exposes replicated, consensus-backed state by advertising a *procedural macro*. Client crates invoke the macro and get a typed API; the runtime owns both the protocol and the codegen.

At a high level, the DB cell:

* Handles RPC (Upsert / Get / Remove) * Coordinates macro expansion for client APIs * Stores opaque zero-copy blobs (`rkyv`)

Here’s the core of the DB side:

```rust use cell_sdk::; use cell_model::macro_coordination::; use std::pin::Pin;

#[protein] pub struct Upsert { pub key: u64, pub kind: String, pub blob: Vec<u8>, }

#[protein] pub struct Get { pub key: u64, pub kind: String }

#[protein] pub struct Row { pub blob: Option<Vec<u8>> }

#[service] #[derive(Clone)] struct DbService { state: Arc<RwLock<HashMap<(u64, String), Vec<u8>>>>, }

#[handler] impl DbService { async fn upsert(&self, u: Upsert) -> Result<bool> { self.state.write().await.insert((u.key, u.kind), u.blob); Ok(true) } async fn get(&self, g: Get) -> Result<Row> { let val = self.state.read().await.get(&(g.key, g.kind)).cloned(); Ok(Row { blob: val }) } async fn remove(&self, k: u64, kind: String) -> Result<bool> { Ok(self.state.write().await.remove(&(k, kind)).is_some()) } }

fn expand_table(ctx: &ExpansionContext) -> Pin<Box<dyn Future<Output=Result<String>> + Send + '_>> { Box::pin(async move { let struct_name = &ctx.struct_name; let pk = ctx.fields.first().unwrap().0.clone();

        Ok(format!(r#"
            pub struct {struct_name}Table {{ synapse: ::cell_sdk::Synapse }}
            impl {struct_name}Table {{
                pub async fn connect() -> ::anyhow::Result<Self> {{
                    Ok(Self {{ synapse: ::cell_sdk::Synapse::grow("db").await? }})
                }}
                pub async fn save(&self, row: {struct_name}) -> ::anyhow::Result<bool> {{
                    let bytes = ::cell_sdk::rkyv::to_bytes::<_,1024>(&row)?.into_vec();
                    let req = DbProtocol::Upsert {{
                        key: row.{pk},
                        kind: "{struct_name}".into(),
                        blob: bytes,
                    }};
                    self.synapse.fire(&req).await
                }}
            }}
        "#))
    })
}

#[tokio::main] async fn main() -> Result<()> { let db = DbService { state: Default::default() };

    const macros = vec![MacroInfo {
        name: "table".into(),
        kind: MacroKind::Attribute,
        description: "distributed table".into(),
        dependencies: vec![],
    }];

    Runtime::ignite_with_coordination(
        move |req| db.dispatch(req),
        "db",
        macros,
        expand_table,
    ).await
} ```

consumer

```rust use cell_sdk::;

#[expand("db", "table")] #[derive(Archive, Serialize, Clone, Debug)] pub struct Order { pub order_id: u64, pub user_id: u64, pub amount: u64, }

#[tokio::main] async fn main() -> anyhow::Result<()> { let orders = OrderTable::connect().await?;

    orders.save(Order { order_id: 42, user_id: 7, amount: 1000 }).await?;
    let o = orders.get(42).await?.unwrap();
    println!("loaded {o:?}");

    orders.remove(42).await?;
    Ok(())
} ```

The question: *does letting a distributed service own both its protocol and client-side macro make sense, or is this hiding too much complexity?* And: Would this actually be useful for enterprise? Would you use it?

Thanks — looking for design-level feedback, not users.

US to bankroll far-right think tanks in Europe against digital laws

https://www.brusselstimes.com/1957195/us-to-fund-far-right-forces-in-europe-tbtb
1•saubeidl•47s ago•0 comments

Ask HN: Have AI companies replaced their own SaaS usage with agents?

1•tuxpenguine•3m ago•0 comments

pi-nes

https://twitter.com/thomasmustier/status/2018362041506132205
1•tosh•5m ago•0 comments

Show HN: Crew – Multi-agent orchestration tool for AI-assisted development

https://github.com/garnetliu/crew
1•gl2334•6m ago•0 comments

New hire fixed a problem so fast, their boss left to become a yoga instructor

https://www.theregister.com/2026/02/06/on_call/
1•Brajeshwar•7m ago•0 comments

Four horsemen of the AI-pocalypse line up capex bigger than Israel's GDP

https://www.theregister.com/2026/02/06/ai_capex_plans/
1•Brajeshwar•7m ago•0 comments

A free Dynamic QR Code generator (no expiring links)

https://free-dynamic-qr-generator.com/
1•nookeshkarri7•8m ago•1 comments

nextTick but for React.js

https://suhaotian.github.io/use-next-tick/
1•jeremy_su•10m ago•0 comments

Show HN: I Built an AI-Powered Pull Request Review Tool

https://github.com/HighGarden-Studio/HighReview
1•highgarden•10m ago•0 comments

Git-am applies commit message diffs

https://lore.kernel.org/git/bcqvh7ahjjgzpgxwnr4kh3hfkksfruf54refyry3ha7qk7dldf@fij5calmscvm/
1•rkta•13m ago•0 comments

ClawEmail: 1min setup for OpenClaw agents with Gmail, Docs

https://clawemail.com
1•aleks5678•20m ago•1 comments

UnAutomating the Economy: More Labor but at What Cost?

https://www.greshm.org/blog/unautomating-the-economy/
1•Suncho•26m ago•1 comments

Show HN: Gettorr – Stream magnet links in the browser via WebRTC (no install)

https://gettorr.com/
1•BenaouidateMed•27m ago•0 comments

Statin drugs safer than previously thought

https://www.semafor.com/article/02/06/2026/statin-drugs-safer-than-previously-thought
1•stareatgoats•29m ago•0 comments

Handy when you just want to distract yourself for a moment

https://d6.h5go.life/
1•TrendSpotterPro•31m ago•0 comments

More States Are Taking Aim at a Controversial Early Reading Method

https://www.edweek.org/teaching-learning/more-states-are-taking-aim-at-a-controversial-early-read...
1•lelanthran•32m ago•0 comments

AI will not save developer productivity

https://www.infoworld.com/article/4125409/ai-will-not-save-developer-productivity.html
1•indentit•37m ago•0 comments

How I do and don't use agents

https://twitter.com/jessfraz/status/2019975917863661760
1•tosh•43m ago•0 comments

BTDUex Safe? The Back End Withdrawal Anomalies

1•aoijfoqfw•46m ago•0 comments

Show HN: Compile-Time Vibe Coding

https://github.com/Michael-JB/vibecode
6•michaelchicory•48m ago•1 comments

Show HN: Ensemble – macOS App to Manage Claude Code Skills, MCPs, and Claude.md

https://github.com/O0000-code/Ensemble
1•IO0oI•52m ago•1 comments

PR to support XMPP channels in OpenClaw

https://github.com/openclaw/openclaw/pull/9741
1•mickael•52m ago•0 comments

Twenty: A Modern Alternative to Salesforce

https://github.com/twentyhq/twenty
1•tosh•54m ago•0 comments

Raspberry Pi: More memory-driven price rises

https://www.raspberrypi.com/news/more-memory-driven-price-rises/
2•calcifer•59m ago•0 comments

Level Up Your Gaming

https://d4.h5go.life/
1•LinkLens•1h ago•1 comments

Di.day is a movement to encourage people to ditch Big Tech

https://itsfoss.com/news/di-day-celebration/
3•MilnerRoute•1h ago•0 comments

Show HN: AI generated personal affirmations playing when your phone is locked

https://MyAffirmations.Guru
4•alaserm•1h ago•3 comments

Show HN: GTM MCP Server- Let AI Manage Your Google Tag Manager Containers

https://github.com/paolobietolini/gtm-mcp-server
1•paolobietolini•1h ago•0 comments

Launch of X (Twitter) API Pay-per-Use Pricing

https://devcommunity.x.com/t/announcing-the-launch-of-x-api-pay-per-use-pricing/256476
1•thinkingemote•1h ago•0 comments

Facebook seemingly randomly bans tons of users

https://old.reddit.com/r/facebookdisabledme/
1•dirteater_•1h ago•2 comments