You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@actor-system/cluster

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@actor-system/cluster - npm Package Compare versions

Comparing version
0.0.18
to
0.1.0
+1
-1
dist/__bundle__/shared/dist/non-nullable.js
function assertNonNullable(value, error) {
if (value === null || value === undefined) {
throw typeof error === "string" ? new TypeError(error) : error;
throw error;
}

@@ -5,0 +5,0 @@ }

@@ -1,2 +0,2 @@

import { $system, LocalActorRef, systemMessage } from '@actor-system/core';
import { $systemLookup, LocalActorRef, systemMessage } from '@actor-system/core';
import { routeMessage } from './mail/command.js';

@@ -6,2 +6,3 @@

#state;
#system;
path;

@@ -13,3 +14,3 @@ /**

/** @internal */
[$system];
[$systemLookup] = true;
/** @internal */

@@ -21,6 +22,8 @@ __typename = "ActorRef";

static hydrator = (state) => {
const localHydrator = LocalActorRef.hydrator(state.self[$system]);
const system = state.self._getSystem();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const localHydrator = LocalActorRef.hydrator(system);
return {
__typename: ClusterActorRef.__typename,
hydrate: (json, rehydrate) => json.path.startsWith(state.self[$system].path)
hydrate: (json, rehydrate) => json.path.startsWith(system.path)
? localHydrator.hydrate(json, rehydrate)

@@ -32,5 +35,6 @@ : (state.remoteActorRegistry.get(json.path) ??

constructor({ path, state, }) {
const system = state.self._getSystem();
this.path = path;
this.#state = state;
this[$system] = state.self[$system];
this.#system = system;
state.remoteActorRegistry.set(path, this);

@@ -40,2 +44,12 @@ }

this.#state.self.tell(routeMessage({ to: this.path, payload: message }));
}
/** @internal */
_getSystem() {
return this.#system;
}
/** @internal */
_sendSystemMessage(message) {
// Route system messages through the cluster messaging system
this.#state.self.tell(routeMessage({ to: this.path, payload: message }));
// Track watchers for death watch notifications
if (systemMessage.isWatch(message)) {

@@ -42,0 +56,0 @@ this.#watchers.add(message.watcher);

@@ -33,3 +33,3 @@ import * as behaviors from '@actor-system/behaviors';

const state = {
self,
self: self,
clusterState,

@@ -52,2 +52,7 @@ selfNode,

}
// TODO: a new node letter for error messages?
else if (event.data instanceof Error) {
console.error(`Error from pending port`);
console.error(event.data);
}
});

@@ -54,0 +59,0 @@ NodePort.onMessageError(port, (event) => console.error(event.data));

@@ -7,2 +7,3 @@ import * as behaviors from '@actor-system/behaviors';

import { error, isGetClusterState, isError, $joinTimeout, joinTimeout, $actorRegistryUpdate, $routeMessage as $routeMessage$1, $error, isActorRegistryUpdate as isActorRegistryUpdate$1, actorRegistryUpdate as actorRegistryUpdate$1 } from '../mail/command.js';
import { clusterStateSync as clusterStateSync$1, isCommand } from '../receptionist/command.js';
import { $name } from '../receptionist/index.js';

@@ -16,3 +17,2 @@ import { ensureConfig } from '../ensureClusterConfig.js';

import { behavior as receptionistBehavior } from '../receptionist/behavior.js';
import { clusterStateSync as clusterStateSync$1 } from '../receptionist/command.js';

@@ -37,3 +37,3 @@ const nodeBehavior = (coordinatorPort) => behaviors.setup(({ system, self, spawn }) => {

const state = {
self,
self: self,
selfNode,

@@ -160,2 +160,8 @@ coordinatorPort,

return behaviors.empty;
default: {
if (isCommand(post)) {
state.receptionist.tell(post);
return behaviors.same;
}
}
}

@@ -162,0 +168,0 @@ return behaviors.same;

import { GetClusterState, RouteMessage } from '../mail/command.js';
export { $getClusterState, $routeMessage, getClusterState, isGetClusterState, isRouteMessage, routeMessage } from '../mail/command.js';
import { Command as Command$1 } from '../receptionist/command.js';
export { $lookup, $register, $subscribe, $unregister, Lookup, Register, Subscribe, Unregister, isLookup, isRegister, isSubscribe, isUnregister, lookup, register, subscribe, unregister } from '@actor-system/receptionist/command';
type Command = GetClusterState | RouteMessage;
type Command = GetClusterState | RouteMessage | Command$1;
declare const isCommand: {

@@ -6,0 +8,0 @@ (value: unknown): value is Command;

import { GetClusterState, RouteMessage, Error, JoinTimeout, ActorRegistryUpdate } from '../mail/command.internal.js';
export { $actorRegistryUpdate, $error, $getClusterState, $joinTimeout, $routeMessage, actorRegistryUpdate, error, getClusterState, isActorRegistryUpdate, isError, isGetClusterState, isJoinTimeout, isRouteMessage, joinTimeout, routeMessage } from '../mail/command.internal.js';
import { Command as Command$1 } from '../receptionist/command.internal.js';
export { $lookup, $register, $subscribe, $unregister, Lookup, Register, Subscribe, Unregister, isLookup, isRegister, isSubscribe, isUnregister, lookup, register, subscribe, unregister } from '@actor-system/receptionist/command/internal';
type Command = GetClusterState | RouteMessage;
type Command = GetClusterState | RouteMessage | Command$1;
/** @internal */
declare namespace Command {
/** @internal */
type Internal = GetClusterState | RouteMessage | Error | JoinTimeout | ActorRegistryUpdate;
type Internal = GetClusterState | RouteMessage | Error | JoinTimeout | ActorRegistryUpdate | Command$1.Internal;
}

@@ -10,0 +12,0 @@ declare const isCommand: {

import { isLetter } from '@actor-system/mail';
import { $getClusterState, $routeMessage, $joinTimeout, $error, $actorRegistryUpdate } from '../mail/command.js';
export { actorRegistryUpdate, error, getClusterState, isActorRegistryUpdate, isError, isGetClusterState, isJoinTimeout, isRouteMessage, joinTimeout, routeMessage } from '../mail/command.js';
import '../receptionist/command.js';
import { $lookup, $register, $subscribe, $unregister } from '@actor-system/receptionist/command';
export { $lookup, $register, $subscribe, $unregister, isLookup, isRegister, isSubscribe, isUnregister, lookup, register, subscribe, unregister } from '@actor-system/receptionist/command';
const isCommand = (input) => isLetter(input, $getClusterState, $routeMessage, $joinTimeout, $error, $actorRegistryUpdate);
const isCommand = (input) => isLetter(input, $getClusterState, $routeMessage, $joinTimeout, $error, $actorRegistryUpdate, $lookup, $register, $subscribe, $unregister);
export { $actorRegistryUpdate, $error, $getClusterState, $joinTimeout, $routeMessage, isCommand };

@@ -1,2 +0,2 @@

import { $system, deadLetters } from '@actor-system/core';
import { systemMessage } from '@actor-system/core';
import { systemPathFromPath } from '../__bundle__/shared/dist/path.js';

@@ -33,3 +33,3 @@ import { routeMessage } from '../mail/node-letter.js';

const resolveRouteMessage = ({ post, state, }) => {
const system = state.self[$system];
const system = state.self._getSystem();
if (post.to.startsWith(state.selfNode.path)) {

@@ -40,7 +40,13 @@ // Local delivery - resolve and deliver directly

if (localActor) {
localActor.tell(rehydratedPayload);
// Route system messages via _sendSystemMessage, regular messages via tell
if (systemMessage.isSystemMessage(rehydratedPayload)) {
localActor._sendSystemMessage(rehydratedPayload);
}
else {
localActor.tell(rehydratedPayload);
}
}
else {
// Send to dead letters if actor doesn't exist
system.deadLetters.tell(deadLetters.cmd.deadLetter(rehydratedPayload, post.to));
system.deadLetters.tell(rehydratedPayload);
}

@@ -59,3 +65,3 @@ }

else {
system.deadLetters.tell(deadLetters.cmd.deadLetter(post.payload, post.to));
system.deadLetters.tell(post.payload);
}

@@ -62,0 +68,0 @@ }

@@ -5,3 +5,3 @@ import { ServiceKey } from '@actor-system/receptionist';

declare module "@actor-system/core" {
interface ActorSystemConfig {
interface SystemConfig {
readonly cluster?: ClusterConfig;

@@ -8,0 +8,0 @@ }

@@ -5,3 +5,3 @@ import { ServiceKey } from '@actor-system/receptionist/internal';

declare module "@actor-system/core" {
interface ActorSystemConfig {
interface SystemConfig {
readonly cluster?: ClusterConfig;

@@ -8,0 +8,0 @@ }

{
"name": "@actor-system/cluster",
"version": "0.0.18",
"version": "0.1.0",
"type": "module",

@@ -41,9 +41,9 @@ "scripts": {

"dependencies": {
"@actor-system/behaviors": "0.0.18",
"@actor-system/core": "0.1.2",
"@actor-system/behaviors": "0.1.0",
"@actor-system/core": "0.2.0",
"@actor-system/mail": "0.0.3",
"@actor-system/receptionist": "0.0.18"
"@actor-system/receptionist": "0.1.0"
},
"devDependencies": {
"@actor-system/testing": "0.0.2",
"@actor-system/testing": "0.1.0",
"@actor-system/shared": "0.0.3",

@@ -50,0 +50,0 @@ "config": "^1.0.0"