@persistica/flux-mesh 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@persistica/flux-mesh",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Persistica Flux Mesh",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -1,15 +1,15 @@
1
1
  import { type TAddress, type TClientId } from '@flux/shared/types';
2
2
  import { RedisConnection } from '../routing/redis/redis-connection.class';
3
3
  import { TConnectedClientSocket } from '../connected-client-socket.types';
4
- import { NetworkAgentRedisCache } from '../register/network-agent-redis-cache.class';
4
+ import { NetworkAgentService } from '../register/network-agent.service';
5
5
  export declare class AgentManager {
6
6
  private readonly _redisConnection;
7
7
  private readonly _clientMap;
8
- private readonly _networkAgentRedisCache;
8
+ private readonly _networkAgentService;
9
9
  private readonly machineAddress;
10
10
  private readonly processAddress;
11
11
  private readonly _globalClientManager;
12
12
  private readonly _localAgentManager;
13
- constructor(_redisConnection: RedisConnection, _clientMap: Map<TClientId, TConnectedClientSocket>, _networkAgentRedisCache: NetworkAgentRedisCache);
13
+ constructor(_redisConnection: RedisConnection, _clientMap: Map<TClientId, TConnectedClientSocket>, _networkAgentService: NetworkAgentService);
14
14
  kick(agentAddress: TAddress): void;
15
15
  }
@@ -3,10 +3,10 @@
3
3
  */
4
4
  import type { TClientId } from '@flux/shared/types';
5
5
  import { TConnectedClientSocket } from '../../connected-client-socket.types';
6
- import { NetworkAgentRedisCache } from '../../register/network-agent-redis-cache.class';
6
+ import { NetworkAgentService } from '../../register/network-agent.service';
7
7
  export declare class LocalAgentManager {
8
8
  private readonly _clientMap;
9
- private readonly _networkAgentRedisCache;
10
- constructor(_clientMap: Map<TClientId, TConnectedClientSocket>, _networkAgentRedisCache: NetworkAgentRedisCache);
9
+ private readonly _networkAgentService;
10
+ constructor(_clientMap: Map<TClientId, TConnectedClientSocket>, _networkAgentService: NetworkAgentService);
11
11
  kickAgent(clientId: TClientId): Promise<void>;
12
12
  }
@@ -0,0 +1,4 @@
1
+ import { TConnectedClientSocket } from '../connected-client-socket.types';
2
+ import { NetworkAuthorityCache } from '../register/network-authority-cache.class';
3
+ import { NetworkAgentService } from '../register/network-agent.service';
4
+ export declare const onSocketClosed: (clientMap: Map<string, TConnectedClientSocket>, networkAuthorityRedisCache: NetworkAuthorityCache, networkAgentService: () => NetworkAgentService) => (ws: TConnectedClientSocket, code: number) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { type TAddress, type TChannelName, type TNetworkId_S, type TSubscription_S } from '@flux/shared/types';
1
+ import { type TAddress, type TChannelName, type TNetworkId_S, type TSubscription_S, type TClientId } from '@flux/shared/types';
2
2
  import type { GlobalChannelPubsub } from '../../routing/global-channel/global-channel-pubsub.class';
3
3
  export declare class NetworkChannelManager {
4
4
  private readonly _globalChannelPubsub;
@@ -24,6 +24,7 @@ export declare class NetworkChannelManager {
24
24
  * Leaves all network channels.
25
25
  */
26
26
  leaveAllNetworkChannels(networkId: TNetworkId_S, clientAddress: TAddress, channelNames: Set<TChannelName>): Promise<void>;
27
+ readChannelNamesForClientId(networkId: TNetworkId_S, clientId: TClientId): Promise<Set<TChannelName>>;
27
28
  /**
28
29
  * Increases the usage count of a channel.
29
30
  */
@@ -1,13 +1,10 @@
1
1
  import { type TProcessAddress, type TMachineAddress } from '@flux/shared/types';
2
2
  import { RedisConnection } from '../../routing/redis/redis-connection.class';
3
- import { NetworkChannelManager } from '../channels/channel-manager.class';
3
+ import { NetworkAgentService } from '../../register/network-agent.service';
4
4
  export declare class ProcessClass {
5
5
  private readonly _redisConnection;
6
- private readonly _networkChannelManager;
7
- private readonly networkAgentRedisRepository;
8
- private readonly networkChannelService;
9
- private readonly networkAgentRedisService;
10
- constructor(_redisConnection: RedisConnection, _networkChannelManager: NetworkChannelManager);
6
+ private readonly _networkAgentService;
7
+ constructor(_redisConnection: RedisConnection, _networkAgentService: NetworkAgentService);
11
8
  /**
12
9
  *
13
10
  */
package/src/main.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare class FluxMeshServer {
13
13
  private readonly channelManager;
14
14
  private readonly agentManager;
15
15
  private readonly processClass;
16
+ private readonly networkAgentService;
16
17
  constructor(optionsOrPort?: (TOptions | number) | undefined);
17
18
  onReady(fn: () => void): void;
18
19
  /**
@@ -13,7 +13,7 @@ export declare class NetworkAgentRedisCache {
13
13
  * Register an agent.
14
14
  *
15
15
  * @param { TNetworkId_S } networkId - The network ID
16
- * @param { TClientId } id - The client socket ID
16
+ * @param { TClientId } clientId - The client socket ID
17
17
  * @param { Bun.SocketAddress | null } ip - The client IP address
18
18
  * @param { TAddress } address - The client address
19
19
  * @param { object } throughput - The throughput tracking object
@@ -22,7 +22,7 @@ export declare class NetworkAgentRedisCache {
22
22
  *
23
23
  * @returns { Promise<void> }
24
24
  */
25
- registerAgent(networkId: TNetworkId_S, id: TClientId, ip: Bun.SocketAddress | null, address: TAddress, throughput: {
25
+ registerAgent(networkId: TNetworkId_S, clientId: TClientId, ip: Bun.SocketAddress | null, address: TAddress, throughput: {
26
26
  bytes: number;
27
27
  packets: number;
28
28
  }, uid?: TAgentOwnUId, machineUID?: TFluxClientUID): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import type { TAddress, TClientId, TAgentOwnUId, TNetworkId_S, TChannelName } from '@flux/shared/types';
2
+ import type { TFluxClientUID } from '@flux/shared/utils';
3
+ import { NetworkAgentRedisCache } from './network-agent-redis-cache.class';
4
+ import { NetworkChannelManager } from '../business-logic/channels/channel-manager.class';
5
+ import { RedisConnection } from '../routing/redis/redis-connection.class';
6
+ export declare class NetworkAgentService {
7
+ private readonly networkAgentRedisCache;
8
+ private readonly redisConnection;
9
+ private readonly networkChannelManager;
10
+ private readonly networkAgentRedisRepository;
11
+ constructor(networkAgentRedisCache: NetworkAgentRedisCache, redisConnection: RedisConnection, networkChannelManager: NetworkChannelManager);
12
+ /**
13
+ * Register an agent.
14
+ */
15
+ registerAgent(networkId: TNetworkId_S, clientId: TClientId, ip: Bun.SocketAddress | null, address: TAddress, throughput: {
16
+ bytes: number;
17
+ packets: number;
18
+ }, uid?: TAgentOwnUId, machineUID?: TFluxClientUID): Promise<void>;
19
+ /**
20
+ * Unregisters a network agent UID and associated data from the Redis hash.
21
+ */
22
+ unregister(clientId: TClientId, clientAddress?: TAddress, networkId?: TNetworkId_S, networkChannels?: Set<TChannelName>, clientOwnUId?: {
23
+ clientOwnUId: TAgentOwnUId;
24
+ networkId: TNetworkId_S;
25
+ }): Promise<void>;
26
+ /**
27
+ * Resolves the network client address by an agent's UID, using a local cache to avoid unnecessary Redis calls.
28
+ */
29
+ resolveClientAddressByUid(networkId: TNetworkId_S, clientOwnUId: TAgentOwnUId): Promise<TAddress>;
30
+ }
@@ -9,11 +9,12 @@ export declare class NetworkAuthorityCache {
9
9
  *
10
10
  * @param { TNetworkId_S } networkId - The network ID to register on
11
11
  * @param { TClientId } clientId - The socket ID of the authority
12
+ * @param { Bun.SocketAddress | null } ip - The client IP address
12
13
  * @param { TFluxClientUID } [machineUID] - Optional machine UID
13
14
  *
14
15
  * @returns { Promise<void> }
15
16
  */
16
- register(networkId: TNetworkId_S, clientId: TClientId, machineUID?: TFluxClientUID): Promise<void>;
17
+ register(networkId: TNetworkId_S, clientId: TClientId, ip: Bun.SocketAddress | null, machineUID?: TFluxClientUID): Promise<void>;
17
18
  /**
18
19
  * Unregisters a network authority from the local network.
19
20
  *