dfx 0.45.3 → 0.45.5
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Discord, Hub } from "dfx/_common";
|
|
1
|
+
import { Maybe, Schedule, Effect, Discord, Hub } from "dfx/_common";
|
|
2
2
|
import { DiscordConfig } from "dfx/DiscordConfig";
|
|
3
3
|
import { DiscordREST } from "dfx/DiscordREST";
|
|
4
4
|
import { RateLimiter } from "../RateLimit.js";
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "
|
|
2
|
-
import * as tsplus_module_2 from "@effect/
|
|
3
|
-
import * as tsplus_module_3 from "@effect/
|
|
4
|
-
import * as tsplus_module_4 from "
|
|
5
|
-
import * as tsplus_module_5 from "@effect/io/
|
|
6
|
-
import * as tsplus_module_6 from "@effect/data/
|
|
7
|
-
import * as tsplus_module_7 from "@effect/
|
|
8
|
-
import * as tsplus_module_8 from "@effect/io/
|
|
1
|
+
import * as tsplus_module_1 from "@effect/data/Option";
|
|
2
|
+
import * as tsplus_module_2 from "@effect/data/Duration";
|
|
3
|
+
import * as tsplus_module_3 from "@effect/io/Schedule";
|
|
4
|
+
import * as tsplus_module_4 from "dfx/_common";
|
|
5
|
+
import * as tsplus_module_5 from "@effect/io/Effect";
|
|
6
|
+
import * as tsplus_module_6 from "@effect/data/Chunk";
|
|
7
|
+
import * as tsplus_module_7 from "@effect/io/Deferred";
|
|
8
|
+
import * as tsplus_module_8 from "@effect/io/Ref";
|
|
9
|
+
import * as tsplus_module_9 from "@effect/io/Layer";
|
|
9
10
|
import { millis } from "@effect/data/Duration";
|
|
10
11
|
import { DiscordConfig } from "dfx/DiscordConfig";
|
|
11
12
|
import { DiscordREST } from "dfx/DiscordREST";
|
|
12
13
|
import { LiveRateLimiter, RateLimiter } from "../RateLimit.js";
|
|
13
14
|
import { LiveShard, Shard } from "./Shard.js";
|
|
14
15
|
import { ShardStore } from "./ShardStore.js";
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const claimRepeatPolicy = tsplus_module_3.passthrough(tsplus_module_3.whileInput(tsplus_module_3.fixed(tsplus_module_2.minutes(3)), (_) => tsplus_module_1.isNone(_)));
|
|
17
|
+
const make = tsplus_module_5.flatMap(ShardStore, store => tsplus_module_5.flatMap(DiscordREST, rest => tsplus_module_5.flatMap(DiscordConfig, ({ gateway: config }) => tsplus_module_5.flatMap(RateLimiter, limiter => tsplus_module_5.flatMap(Shard, shard => {
|
|
18
|
+
const takeConfig = (totalCount) => tsplus_module_5.map(tsplus_module_8.make(0), currentCount => {
|
|
19
|
+
const claimId = (sharderCount) => tsplus_module_5.map(tsplus_module_5.repeat(store
|
|
18
20
|
.claimId({
|
|
19
21
|
totalCount,
|
|
20
22
|
sharderCount,
|
|
21
|
-
}),
|
|
22
|
-
return
|
|
23
|
+
}), claimRepeatPolicy), _ => _.value);
|
|
24
|
+
return tsplus_module_5.map(tsplus_module_5.flatMap(tsplus_module_8.getAndUpdate(currentCount, _ => _ + 1), claimId), id => ({ id, totalCount }));
|
|
23
25
|
});
|
|
24
|
-
return
|
|
25
|
-
.getGatewayBot(), r => r.json), () =>
|
|
26
|
+
return tsplus_module_5.map(tsplus_module_5.catchAll(tsplus_module_5.flatMap(rest
|
|
27
|
+
.getGatewayBot(), r => r.json), () => tsplus_module_5.succeed({
|
|
26
28
|
url: "wss://gateway.discord.gg/",
|
|
27
29
|
shards: 1,
|
|
28
30
|
session_start_limit: {
|
|
@@ -32,18 +34,18 @@ const make = tsplus_module_2.flatMap(ShardStore, store => tsplus_module_2.flatMa
|
|
|
32
34
|
max_concurrency: 1,
|
|
33
35
|
},
|
|
34
36
|
})), gateway => {
|
|
35
|
-
const run = (hub) =>
|
|
36
|
-
const spawner =
|
|
37
|
+
const run = (hub) => tsplus_module_5.flatMap(tsplus_module_7.make(), deferred => tsplus_module_5.flatMap(takeConfig(config.shardCount ?? gateway.shards), take => {
|
|
38
|
+
const spawner = tsplus_module_5.forever(tsplus_module_5.flatMap(tsplus_module_5.flatMap(tsplus_module_5.tap(tsplus_module_5.map(take, config => ({
|
|
37
39
|
...config,
|
|
38
40
|
url: gateway.url,
|
|
39
41
|
concurrency: gateway.session_start_limit.max_concurrency,
|
|
40
|
-
})), ({ id, concurrency }) => limiter.maybeWait(`dfx.sharder.${id % concurrency}`, millis(config.identifyRateLimit[0]), config.identifyRateLimit[1])), c => shard.connect([c.id, c.totalCount], hub)), shard =>
|
|
41
|
-
const spawners =
|
|
42
|
-
return
|
|
42
|
+
})), ({ id, concurrency }) => limiter.maybeWait(`dfx.sharder.${id % concurrency}`, millis(config.identifyRateLimit[0]), config.identifyRateLimit[1])), c => shard.connect([c.id, c.totalCount], hub)), shard => tsplus_module_5.fork(tsplus_module_5.catchAllCause(shard.run, _ => tsplus_module_7.failCause(deferred, _)))));
|
|
43
|
+
const spawners = tsplus_module_6.map(tsplus_module_6.range(1, gateway.session_start_limit.max_concurrency), () => spawner);
|
|
44
|
+
return tsplus_module_5.zipParLeft(tsplus_module_5.allParDiscard(spawners), tsplus_module_4.deferredAwait(deferred));
|
|
43
45
|
}));
|
|
44
46
|
return { run };
|
|
45
47
|
});
|
|
46
48
|
})))));
|
|
47
|
-
export const Sharder =
|
|
48
|
-
export const LiveSharder =
|
|
49
|
+
export const Sharder = tsplus_module_4.Tag();
|
|
50
|
+
export const LiveSharder = tsplus_module_9.provide(tsplus_module_5.toLayer(make, Sharder))((tsplus_module_9.merge(LiveShard)(LiveRateLimiter)));
|
|
49
51
|
//# sourceMappingURL=Sharder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sharder.js","sourceRoot":"","sources":["../src/DiscordGateway/Sharder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sharder.js","sourceRoot":"","sources":["../src/DiscordGateway/Sharder.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,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EAAE,CAAC,OAAO,CAAC,CAAA;mBAGlB,2BAAA,8BAAqB,QAAQ,CAAC,gCAAY,QAAQ,EAIjD;WAEH,CAAA;QAEJ,OAAO,EAAE,GAAG,EAAW,CAAA;;MACvB,CAAA;AAGF,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAA,GAAG,EAAW,CAAA;AACrC,MAAM,CAAC,MAAM,WAAW,2BACW,wBAAA,IAAI,EAAS,OAAO,CAAC,EAAtD,uBAAmB,SAAS,EAA3B,eAAe,EAAa,CAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@tim-smart/discord-api-docs-parser": "^0.5.2",
|
|
28
28
|
"@tsplus-types/effect__data": "0.12.2-3b576ba",
|
|
29
|
-
"@tsplus-types/effect__io": "0.25.
|
|
29
|
+
"@tsplus-types/effect__io": "0.25.9-11739c0",
|
|
30
30
|
"@tsplus-types/effect__stream": "0.21.1-3b576ba",
|
|
31
31
|
"@types/ws": "^8.5.4",
|
|
32
32
|
"dotenv": "^16.0.3",
|
|
33
|
-
"lerna": "^6.6.
|
|
33
|
+
"lerna": "^6.6.2",
|
|
34
34
|
"madge": "^6.0.0",
|
|
35
35
|
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer@0.0.171/compiler/typescript.tgz"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@effect-http/client": "^0.
|
|
38
|
+
"@effect-http/client": "^0.25.0",
|
|
39
39
|
"@effect/data": "^0.12.2",
|
|
40
|
-
"@effect/io": "~0.25.
|
|
40
|
+
"@effect/io": "~0.25.9",
|
|
41
41
|
"@effect/stream": "~0.21.1",
|
|
42
42
|
"tweetnacl": "^1.0.3"
|
|
43
43
|
},
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"ws": "^8.13.0"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": false,
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "bf1e0d84f67cfc5cd65c9c61c554b17e5552ba32"
|
|
52
52
|
}
|
|
@@ -5,6 +5,11 @@ import { LiveRateLimiter, RateLimiter } from "../RateLimit.js"
|
|
|
5
5
|
import { LiveShard, Shard } from "./Shard.js"
|
|
6
6
|
import { ShardStore } from "./ShardStore.js"
|
|
7
7
|
import { WebSocketCloseError, WebSocketError } from "./WS.js"
|
|
8
|
+
import { Some } from "@effect/data/Option"
|
|
9
|
+
|
|
10
|
+
const claimRepeatPolicy = Schedule.fixed(Duration.minutes(3)).whileInput(
|
|
11
|
+
(_: Maybe<number>) => _.isNone(),
|
|
12
|
+
).passthrough as Schedule<never, Maybe<number>, Some<number>>
|
|
8
13
|
|
|
9
14
|
const make = Do($ => {
|
|
10
15
|
const store = $(ShardStore)
|
|
@@ -23,12 +28,8 @@ const make = Do($ => {
|
|
|
23
28
|
totalCount,
|
|
24
29
|
sharderCount,
|
|
25
30
|
})
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
() => claimId(sharderCount).delay(Duration.minutes(3)),
|
|
29
|
-
id => Effect.succeed(id),
|
|
30
|
-
),
|
|
31
|
-
)
|
|
31
|
+
.repeat(claimRepeatPolicy)
|
|
32
|
+
.map(_ => _.value)
|
|
32
33
|
|
|
33
34
|
return currentCount
|
|
34
35
|
.getAndUpdate(_ => _ + 1)
|
package/src/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@tim-smart/discord-api-docs-parser": "^0.5.2",
|
|
28
28
|
"@tsplus-types/effect__data": "0.12.2-3b576ba",
|
|
29
|
-
"@tsplus-types/effect__io": "0.25.
|
|
29
|
+
"@tsplus-types/effect__io": "0.25.9-11739c0",
|
|
30
30
|
"@tsplus-types/effect__stream": "0.21.1-3b576ba",
|
|
31
31
|
"@types/ws": "^8.5.4",
|
|
32
32
|
"dotenv": "^16.0.3",
|
|
33
|
-
"lerna": "^6.6.
|
|
33
|
+
"lerna": "^6.6.2",
|
|
34
34
|
"madge": "^6.0.0",
|
|
35
35
|
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer@0.0.171/compiler/typescript.tgz"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@effect-http/client": "^0.
|
|
38
|
+
"@effect-http/client": "^0.25.0",
|
|
39
39
|
"@effect/data": "^0.12.2",
|
|
40
|
-
"@effect/io": "~0.25.
|
|
40
|
+
"@effect/io": "~0.25.9",
|
|
41
41
|
"@effect/stream": "~0.21.1",
|
|
42
42
|
"tweetnacl": "^1.0.3"
|
|
43
43
|
},
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"ws": "^8.13.0"
|
|
49
49
|
},
|
|
50
50
|
"sideEffects": false,
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "bf1e0d84f67cfc5cd65c9c61c554b17e5552ba32"
|
|
52
52
|
}
|