actor-core

actor-core

🎭 Stateful serverless framework for Rivet, Cloudflare Workers, Bun, and Node.js. Build AI agents, realtime apps, game servers, and more.

Stars: 458

Visit
 screenshot

Actor-core is a lightweight and flexible library for building actor-based concurrent applications in Java. It provides a simple API for creating and managing actors, as well as handling message passing between actors. With actor-core, developers can easily implement scalable and fault-tolerant systems using the actor model.

README:

ActorCore

Stateful, Scalable, Realtime Backend Framework

GitHub Discussions Discord Rivet Twitter Rivet Bluesky License Apache-2.0

Intro

The modern way to build multiplayer, realtime, or AI agent backends.

Runs on Rivet, Cloudflare Workers, Bun, and Node.js. Integrates with Hono and Redis.

Architecture

  • 💾 Persistent, In-Memory State: Fast in-memory access with built-in durability — no external databases or caches needed.
  • Ultra-Fast State Updates: Real-time state updates with ultra-low latency, powered by co-locating compute and data.
  • 🔋 Batteries Included: Integrated support for state, actions, events, scheduling, and multiplayer — no extra boilerplate code needed.
  • 🖥️ Serverless & Scalable: Effortless scaling, scale-to-zero, and easy deployments on any serverless runtime.

Features

  • 💾 State: Fast in-memory access with built-in durability.
  • 💻 Actions: Callable functions for seamless client-server communication.
  • 📡 Events: Real-time event handling and broadcasting.
  • Scheduling: Timed tasks and operations management.
  • 🌐 Connections & Multiplayer: Manage connections and multiplayer interactions.
  • 🏷️ Metadata: Store and manage additional data attributes.

Everything you need to build realtime, stateful backends

ActorCore provides a solid foundation with the features you'd expect for modern apps.

Feature ActorCore Durable Objects Socket.io Redis AWS Lambda
In-Memory State
Persisted State
Actions (RPC)
Events (Pub/Sub) -
Scheduling - -
Edge Computing ✓ †
No Vendor Lock

- = requires significant boilerplate code or external service

† = on supported platforms

Quickstart

Run this command:

npx create-actor@latest

Supported Platforms

Overview

Create Actor

import { actor, setup } from "actor-core";

const chatRoom = actor({
  state: { messages: [] },
  actions: {
    // receive an action call from the client
    sendMessage: (c, username: string, message: string) => {
      // save message to persistent storage
      c.state.messages.push({ username, message });

      // broadcast message to all clients
      c.broadcast("newMessage", username, message);
    },
    // allow client to request message history
    getMessages: (c) => c.state.messages
  },
});

export const app = setup({
  actors: { chatRoom },
  cors: { origin: "http://localhost:8080" }
});

export type App = typeof app;

Connect to Actor

import { createClient } from "actor-core/client";
import type { App } from "../src/index";

const client = createClient<App>(/* manager endpoint */);

// connect to chat room
const chatRoom = await client.chatRoom.get({ channel: "random" });

// listen for new messages
chatRoom.on("newMessage", (username: string, message: string) =>
  console.log(`Message from ${username}: ${message}`),
);

// send message to room
await chatRoom.sendMessage("william", "All the world's a stage.");

Community & Support

License

Apache 2.0

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for actor-core

Similar Open Source Tools

For similar tasks

For similar jobs