@persistica/flux-mesh 0.0.17 → 0.0.19
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/index.js +30 -30
- package/package.json +1 -1
- package/src/_managers/authority.manager.d.ts +2 -2
- package/src/_managers/global/global-client.manager.d.ts +6 -4
- package/src/_managers/local/local-agent.manager.d.ts +1 -1
- package/src/_managers/local/local-authority.manager.d.ts +1 -1
- package/src/business-logic/channels/channel-manager.class.d.ts +1 -1
- package/src/register/network-agent-redis-cache.class.d.ts +7 -4
- package/src/register/network-authority-redis-cache.class.d.ts +9 -8
- package/src/routing/redis/network-agent.redis.d.ts +0 -10
- package/src/routing/redis/redis-connection.class.d.ts +2 -2
- package/src/routing/redis/hash/network-agent.redis.sorted-set.d.ts +0 -26
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TAddress, TClientId } from '@flux/shared/types';
|
|
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
4
|
import { NetworkAuthorityRedisCache } from '../register/network-authority-redis-cache.class';
|
|
@@ -11,5 +11,5 @@ export declare class AuthorityManager {
|
|
|
11
11
|
private readonly _globalClientManager;
|
|
12
12
|
private readonly _localAuthorityManager;
|
|
13
13
|
constructor(_redisConnection: RedisConnection, _clientMap: Map<TClientId, TConnectedClientSocket>, _networkAuthorityRedisCache: NetworkAuthorityRedisCache);
|
|
14
|
-
kick(
|
|
14
|
+
kick(authorityAddress: TAddress): void;
|
|
15
15
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Global client manager.
|
|
3
|
+
*
|
|
4
|
+
* Routes kick event to the process on which the client is connected.
|
|
3
5
|
*/
|
|
4
6
|
import { type TAddress, type TClientId } from '@flux/shared/types';
|
|
5
7
|
import { RedisConnection } from '../../routing/redis/redis-connection.class';
|
|
@@ -10,13 +12,13 @@ export declare class GlobalClientManager {
|
|
|
10
12
|
/**
|
|
11
13
|
* Sends a global message to kick a client.
|
|
12
14
|
*
|
|
13
|
-
* @param { TAddress }
|
|
15
|
+
* @param { TAddress } agentAddress
|
|
14
16
|
*
|
|
15
17
|
* @returns { Promise<void> }
|
|
16
18
|
*/
|
|
17
|
-
kickClient(agentAddress: TAddress): Promise<void>;
|
|
19
|
+
kickClient(type: 'agent' | 'authority', agentAddress: TAddress): Promise<void>;
|
|
18
20
|
/**
|
|
19
|
-
* On event on this process
|
|
21
|
+
* On event on this process.
|
|
20
22
|
*/
|
|
21
|
-
onKickClient(onKickCallback: (clientAddress: TClientId) => void): void;
|
|
23
|
+
onKickClient(type: 'agent' | 'authority', onKickCallback: (clientAddress: TClientId) => void): void;
|
|
22
24
|
}
|
|
@@ -8,5 +8,5 @@ export declare class LocalAgentManager {
|
|
|
8
8
|
private readonly _clientMap;
|
|
9
9
|
private readonly _networkAgentRedisCache;
|
|
10
10
|
constructor(_clientMap: Map<TClientId, TConnectedClientSocket>, _networkAgentRedisCache: NetworkAgentRedisCache);
|
|
11
|
-
kickAgent(
|
|
11
|
+
kickAgent(clientId: TClientId): Promise<void>;
|
|
12
12
|
}
|
|
@@ -8,5 +8,5 @@ export declare class LocalAuthorityManager {
|
|
|
8
8
|
private readonly _clientMap;
|
|
9
9
|
private readonly _networkAuthorityRedisCache;
|
|
10
10
|
constructor(_clientMap: Map<TClientId, TConnectedClientSocket>, _networkAuthorityRedisCache: NetworkAuthorityRedisCache);
|
|
11
|
-
kickAuthority(
|
|
11
|
+
kickAuthority(clientId: TClientId): Promise<void>;
|
|
12
12
|
}
|
|
@@ -32,7 +32,7 @@ export declare class NetworkChannelManager {
|
|
|
32
32
|
/**
|
|
33
33
|
* Leaves all network channels.
|
|
34
34
|
*/
|
|
35
|
-
leaveAllNetworkChannels(networkId: TNetworkId_S, clientAddress: TAddress, channelNames: Set<TChannelName>): void
|
|
35
|
+
leaveAllNetworkChannels(networkId: TNetworkId_S, clientAddress: TAddress, channelNames: Set<TChannelName>): Promise<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Creates a network channel if it does not exist.
|
|
38
38
|
*/
|
|
@@ -29,13 +29,16 @@ export declare class NetworkAgentRedisCache {
|
|
|
29
29
|
/**
|
|
30
30
|
* Unregisters a network agent UID and associated data from the Redis hash.
|
|
31
31
|
*
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
32
|
+
* @param { TClientId } clientId
|
|
33
|
+
* @param { TNetworkId_S } [networkId]
|
|
34
34
|
* @param { TAgentOwnUId } [clientOwnUId] - Optional agent UID
|
|
35
35
|
*
|
|
36
36
|
* @returns { void }
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
unregister(clientId: TClientId, networkId?: TNetworkId_S, clientOwnUId?: {
|
|
39
|
+
clientOwnUId: TAgentOwnUId;
|
|
40
|
+
networkId: TNetworkId_S;
|
|
41
|
+
}): Promise<void>;
|
|
39
42
|
/**
|
|
40
43
|
* Resolves the network client address by an agent's UID, using a local cache to avoid unnecessary Redis calls.
|
|
41
44
|
*
|
|
@@ -44,5 +47,5 @@ export declare class NetworkAgentRedisCache {
|
|
|
44
47
|
*
|
|
45
48
|
* @returns { Promise<TAddress> } The resolved address
|
|
46
49
|
*/
|
|
47
|
-
|
|
50
|
+
resolveClientAddressByUid(networkId: TNetworkId_S, clientOwnUId: TAgentOwnUId): Promise<TAddress>;
|
|
48
51
|
}
|
|
@@ -3,25 +3,26 @@ import type { TFluxClientUID } from '@flux/shared/utils';
|
|
|
3
3
|
export declare class NetworkAuthorityRedisCache {
|
|
4
4
|
private readonly redisConnection;
|
|
5
5
|
private readonly cache;
|
|
6
|
+
private readonly clientCache;
|
|
6
7
|
/**
|
|
7
8
|
* Registers a network authority.
|
|
8
9
|
*
|
|
9
10
|
* @param { TNetworkId_S } networkId - The network ID to register on
|
|
10
|
-
* @param { TClientId }
|
|
11
|
+
* @param { TClientId } clientId - The socket ID of the authority
|
|
11
12
|
* @param { TFluxClientUID } [machineUID] - Optional machine UID
|
|
12
13
|
*
|
|
13
14
|
* @returns { Promise<void> }
|
|
14
15
|
*/
|
|
15
|
-
register(networkId: TNetworkId_S,
|
|
16
|
+
register(networkId: TNetworkId_S, clientId: TClientId, machineUID?: TFluxClientUID): Promise<void>;
|
|
16
17
|
/**
|
|
17
18
|
* Unregisters a network authority from the local network.
|
|
18
19
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
20
|
+
* @param { TClientId } clientId
|
|
21
|
+
* @param { TNetworkId_S } [networkId]
|
|
21
22
|
*
|
|
22
|
-
* @returns { void }
|
|
23
|
+
* @returns { Promise<void> }
|
|
23
24
|
*/
|
|
24
|
-
unregister(
|
|
25
|
+
unregister(clientId: TClientId, networkId?: TNetworkId_S): Promise<void>;
|
|
25
26
|
/**
|
|
26
27
|
* Used for cleanup, in case of discovering an idle authority.
|
|
27
28
|
*
|
|
@@ -38,11 +39,11 @@ export declare class NetworkAuthorityRedisCache {
|
|
|
38
39
|
*
|
|
39
40
|
* @returns { Promise<TAddress> } The resolved authority address
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
resolveAuthorityAddressOrThrow(networkId: TNetworkId_S): Promise<TAddress>;
|
|
42
43
|
/**
|
|
43
44
|
* Removes a client from the cache and unregisters it globally.
|
|
44
45
|
*
|
|
45
|
-
* @param { TNetworkId_S } networkId
|
|
46
|
+
* @param { TNetworkId_S } networkId
|
|
46
47
|
* @param { TAddress } networkAuthorityAddress - The address of the unresponsive client
|
|
47
48
|
*/
|
|
48
49
|
removeUnresponsiveClient(networkId: TNetworkId_S, networkAuthorityAddress: TAddress): void;
|
|
@@ -5,7 +5,6 @@ import type { RedisClient } from 'bun';
|
|
|
5
5
|
import type { TClientId, TNetworkId_S } from '@flux/shared/types';
|
|
6
6
|
export declare class NetworkAgentRedis {
|
|
7
7
|
private readonly client;
|
|
8
|
-
private readonly networkAgentRedisSortedSet;
|
|
9
8
|
private readonly cashedDataUsage;
|
|
10
9
|
constructor(client: RedisClient);
|
|
11
10
|
/**
|
|
@@ -41,15 +40,6 @@ export declare class NetworkAgentRedis {
|
|
|
41
40
|
);
|
|
42
41
|
}
|
|
43
42
|
*/
|
|
44
|
-
/**
|
|
45
|
-
* Unregisters a network agent from the sorted set.
|
|
46
|
-
*
|
|
47
|
-
* @param { TNetworkId_S } networkId - The network ID
|
|
48
|
-
* @param { TClientId } clientId - The socket ID
|
|
49
|
-
*
|
|
50
|
-
* @returns { Promise<number> } The number of elements removed
|
|
51
|
-
*/
|
|
52
|
-
unregisterNetworkAgent(networkId: TNetworkId_S, clientId: TClientId): Promise<number>;
|
|
53
43
|
/**
|
|
54
44
|
* Caches the data usage for a network agent to be pushed periodically.
|
|
55
45
|
*
|
|
@@ -74,8 +74,8 @@ export declare class RedisConnection {
|
|
|
74
74
|
* Used by {@link NetworkTokenCache} for cold-start bootstrapping.
|
|
75
75
|
*/
|
|
76
76
|
getNetworkTokenValues(networkId: TNetworkId_S): Promise<TNetworkToken_S[]>;
|
|
77
|
-
publishCustom(subChannel: 'kick-client', destinationProcessAddress: TProcessAddress, message: string): Promise<
|
|
78
|
-
subscribeToCustom(subChannel: 'kick-client', destinationProcessAddress: TProcessAddress, callback: (data: string) => void): void;
|
|
77
|
+
publishCustom(subChannel: 'kick-client-agent' | 'kick-client-authority', destinationProcessAddress: TProcessAddress, message: string): Promise<number>;
|
|
78
|
+
subscribeToCustom(subChannel: 'kick-client-agent' | 'kick-client-authority', destinationProcessAddress: TProcessAddress, callback: (data: string) => void): void;
|
|
79
79
|
/**
|
|
80
80
|
* Publishes a message directly to an address.
|
|
81
81
|
*/
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { RedisClient } from 'bun';
|
|
2
|
-
import type { TClientId, TNetworkId_S } from '@flux/shared/types';
|
|
3
|
-
export declare class NetworkAgentRedisSortedSet {
|
|
4
|
-
private readonly client;
|
|
5
|
-
private readonly processId;
|
|
6
|
-
private readonly machineAddress;
|
|
7
|
-
constructor(client: RedisClient);
|
|
8
|
-
/**
|
|
9
|
-
* Registers a network agent in the sorted set.
|
|
10
|
-
*
|
|
11
|
-
* @param { TNetworkId_S } networkId - The network ID
|
|
12
|
-
* @param { TClientId } socketId - The socket/client ID
|
|
13
|
-
*
|
|
14
|
-
* @returns { Promise<void> }
|
|
15
|
-
*/
|
|
16
|
-
registerAgent(networkId: TNetworkId_S, socketId: TClientId): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Unregisters a network agent from the sorted set.
|
|
19
|
-
*
|
|
20
|
-
* @param { TNetworkId_S } networkId - The network ID
|
|
21
|
-
* @param { TClientId } socketId - The socket/client ID
|
|
22
|
-
*
|
|
23
|
-
* @returns { Promise<number> } The number of elements removed
|
|
24
|
-
*/
|
|
25
|
-
unregisterAgent(networkId: TNetworkId_S, socketId: TClientId): Promise<number>;
|
|
26
|
-
}
|