@pylonsync/functions 0.15.0 → 0.16.1
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/dist/types.d.ts +11 -2
- package/package.json +1 -1
- package/src/runtime.ts +2 -1
- package/src/types.ts +14 -2
package/dist/types.d.ts
CHANGED
|
@@ -771,11 +771,18 @@ export interface Shards {
|
|
|
771
771
|
* `params` reach the module's `init`. Actions only: a mutation's
|
|
772
772
|
* rollback cannot undo it.
|
|
773
773
|
*
|
|
774
|
+
* On an app that runs on several machines, the shard runs on the one
|
|
775
|
+
* with the most free capacity, or on `opts.machine` (a machine id, as
|
|
776
|
+
* `ShardInfo.machine` reports it). `maxInstances` counts every machine.
|
|
777
|
+
*
|
|
774
778
|
* Throws `SHARD_EXISTS` when the id is running, `SHARD_LIMIT_REACHED`
|
|
775
779
|
* at the kind's `maxInstances`, `SHARD_KIND_NOT_FOUND`,
|
|
776
|
-
* `SHARD_ID_INVALID`,
|
|
780
|
+
* `SHARD_ID_INVALID`, `SHARD_INIT_FAILED` when `init` refuses, or
|
|
781
|
+
* `SHARD_MACHINE_UNAVAILABLE` when `opts.machine` is not running.
|
|
777
782
|
*/
|
|
778
|
-
create(kind: string, shardId: string, params?: unknown
|
|
783
|
+
create(kind: string, shardId: string, params?: unknown, opts?: {
|
|
784
|
+
machine?: string;
|
|
785
|
+
}): Promise<ShardInfo>;
|
|
779
786
|
/** Stop a shard and close its subscribers' connections. Resolves to
|
|
780
787
|
* `false` when no shard has that id. Actions only. */
|
|
781
788
|
stop(shardId: string): Promise<boolean>;
|
|
@@ -799,6 +806,8 @@ export interface ShardInfo {
|
|
|
799
806
|
running: boolean;
|
|
800
807
|
/** Why the module stopped, when it trapped. */
|
|
801
808
|
error?: string;
|
|
809
|
+
/** The machine that runs it, when the app runs on several. */
|
|
810
|
+
machine?: string;
|
|
802
811
|
}
|
|
803
812
|
/** Context for query handlers (read-only).
|
|
804
813
|
*
|
package/package.json
CHANGED
package/src/runtime.ts
CHANGED
|
@@ -536,13 +536,14 @@ function buildShards(callId: string): Shards {
|
|
|
536
536
|
ttl_secs: opts?.ttlSecs,
|
|
537
537
|
}) as Promise<string>;
|
|
538
538
|
},
|
|
539
|
-
async create(kind, shardId, params) {
|
|
539
|
+
async create(kind, shardId, params, opts) {
|
|
540
540
|
return rpc(callId, {
|
|
541
541
|
type: "shard_op",
|
|
542
542
|
op: "create",
|
|
543
543
|
kind,
|
|
544
544
|
id: shardId,
|
|
545
545
|
params: params ?? {},
|
|
546
|
+
...(opts?.machine ? { machine: opts.machine } : {}),
|
|
546
547
|
}) as Promise<ShardInfo>;
|
|
547
548
|
},
|
|
548
549
|
async stop(shardId) {
|
package/src/types.ts
CHANGED
|
@@ -867,11 +867,21 @@ export interface Shards {
|
|
|
867
867
|
* `params` reach the module's `init`. Actions only: a mutation's
|
|
868
868
|
* rollback cannot undo it.
|
|
869
869
|
*
|
|
870
|
+
* On an app that runs on several machines, the shard runs on the one
|
|
871
|
+
* with the most free capacity, or on `opts.machine` (a machine id, as
|
|
872
|
+
* `ShardInfo.machine` reports it). `maxInstances` counts every machine.
|
|
873
|
+
*
|
|
870
874
|
* Throws `SHARD_EXISTS` when the id is running, `SHARD_LIMIT_REACHED`
|
|
871
875
|
* at the kind's `maxInstances`, `SHARD_KIND_NOT_FOUND`,
|
|
872
|
-
* `SHARD_ID_INVALID`,
|
|
876
|
+
* `SHARD_ID_INVALID`, `SHARD_INIT_FAILED` when `init` refuses, or
|
|
877
|
+
* `SHARD_MACHINE_UNAVAILABLE` when `opts.machine` is not running.
|
|
873
878
|
*/
|
|
874
|
-
create(
|
|
879
|
+
create(
|
|
880
|
+
kind: string,
|
|
881
|
+
shardId: string,
|
|
882
|
+
params?: unknown,
|
|
883
|
+
opts?: { machine?: string },
|
|
884
|
+
): Promise<ShardInfo>;
|
|
875
885
|
|
|
876
886
|
/** Stop a shard and close its subscribers' connections. Resolves to
|
|
877
887
|
* `false` when no shard has that id. Actions only. */
|
|
@@ -900,6 +910,8 @@ export interface ShardInfo {
|
|
|
900
910
|
running: boolean;
|
|
901
911
|
/** Why the module stopped, when it trapped. */
|
|
902
912
|
error?: string;
|
|
913
|
+
/** The machine that runs it, when the app runs on several. */
|
|
914
|
+
machine?: string;
|
|
903
915
|
}
|
|
904
916
|
|
|
905
917
|
/** Context for query handlers (read-only).
|