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: 404

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.

Supports Rivet, Cloudflare Workers, Bun, and Node.js.

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, RPC, 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.
  • πŸ’» RPC: Remote procedure calls 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 βœ“ βœ“
RPC βœ“ βœ“ βœ“ βœ“
Events βœ“ - βœ“ βœ“
Scheduling βœ“ - -
Edge Computing βœ“ † βœ“ βœ“
No Vendor Lock βœ“ βœ“ βœ“

- = requires significant boilerplate code or external service

† = on supported platforms

Getting Started

Step 1: Installation

# npm
npm add actor-core

# pnpm
pnpm add actor-core

# Yarn
yarn add actor-core

# Bun
bun add actor-core

Step 2: Create an Actor

import { Actor, type Rpc } from "actor-core";

export interface State {
  messages: { username: string; message: string }[];
}

export default class ChatRoom extends Actor<State> {
  // initialize this._state
  _onInitialize() {
    return { messages: [] };
  }

  // receive an remote procedure call from the client
  sendMessage(rpc: Rpc<ChatRoom>, username: string, message: string) {
    // save message to persistent storage
    this._state.messages.push({ username, message });

    // broadcast message to all clients
    this._broadcast("newMessage", username, message);
  }
}

Step 3: Connect to Actor

import { Client } from "actor-core/client";
import type ChatRoom from "../src/chat-room.ts";

const client = new Client(/* manager endpoint */);

// connect to chat room
const chatRoom = await client.get<ChatRoom>({ name: "chat" });

// 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.");

Step 4: Deploy

Deploy to your platform of choice:

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