fffleet 2.6.0 → 2.7.0

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.d.ts CHANGED
@@ -38,6 +38,8 @@ export interface JobSpecInput {
38
38
  class?: string;
39
39
  /** -1000..1000, higher runs first. */
40
40
  priority?: number;
41
+ /** Ordered worker IDs. The first eligible worker wins; unlisted workers are excluded. */
42
+ workerPreference?: string[];
41
43
  owner?: string;
42
44
  /** Capabilities a worker must have, e.g. 'filter:ass', 'encoder:libx264', 'font:DejaVu Sans'. */
43
45
  requires?: string[];
@@ -65,6 +67,8 @@ export interface JobSpec {
65
67
  type: string;
66
68
  class: string;
67
69
  priority: number;
70
+ /** Ordered worker IDs; when set, only listed workers may run the job. */
71
+ workerPreference?: string[];
68
72
  owner: string;
69
73
  requires: string[];
70
74
  labels: Record<string, string>;
@@ -119,6 +123,7 @@ export interface JobSnapshot {
119
123
  class: string;
120
124
  owner: string;
121
125
  priority: number;
126
+ workerPreference?: string[];
122
127
  labels: Record<string, string>;
123
128
  state: JobState;
124
129
  workerId: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fffleet",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Run ffmpeg jobs locally, on one worker or across a pool, through one client and one job contract",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/contract.js CHANGED
@@ -79,6 +79,15 @@ export function validateSpec(input) {
79
79
  const priority = s.priority ?? 0;
80
80
  if (!Number.isInteger(priority) || priority < -1000 || priority > 1000) err('priority', 'must be an integer from -1000 to 1000');
81
81
 
82
+ // Ordered worker IDs; when set, this list is also a placement allowlist.
83
+ const workerPreference = s.workerPreference;
84
+ if (workerPreference !== undefined && (!Array.isArray(workerPreference)
85
+ || workerPreference.length === 0
86
+ || workerPreference.some(id => typeof id !== 'string' || !id.trim() || id.length > 128)
87
+ || new Set(workerPreference).size !== workerPreference.length)) {
88
+ err('workerPreference', 'must be a non-empty array of unique worker IDs (1-128 characters each)');
89
+ }
90
+
82
91
  const owner = s.owner ?? '';
83
92
  if (typeof owner !== 'string' || owner.length > 256) err('owner', 'must be a string of at most 256 characters');
84
93
 
@@ -132,6 +141,7 @@ export function validateSpec(input) {
132
141
  type,
133
142
  class: cls,
134
143
  priority,
144
+ ...(workerPreference !== undefined ? { workerPreference: [...workerPreference] } : {}),
135
145
  owner,
136
146
  requires: [...new Set(requires)].sort(),
137
147
  labels: { ...labels },
package/src/job-record.js CHANGED
@@ -129,6 +129,7 @@ export class JobRecord {
129
129
  class: this.spec.class,
130
130
  owner: this.spec.owner,
131
131
  priority: this.spec.priority,
132
+ ...(this.spec.workerPreference ? { workerPreference: this.spec.workerPreference } : {}),
132
133
  labels: this.spec.labels,
133
134
  state: this.state,
134
135
  workerId: this.workerId,
package/src/types.js CHANGED
@@ -16,6 +16,7 @@
16
16
  * @property {string} type Executor, 'ffmpeg' by default.
17
17
  * @property {string} class Slot pool on the worker, 'default' by default.
18
18
  * @property {number} priority Higher runs first.
19
+ * @property {string[]} [workerPreference] Ordered worker IDs; also restricts placement to listed workers.
19
20
  * @property {string} owner Opaque label of whoever submitted the job.
20
21
  * @property {string[]} requires Capabilities a worker must have, e.g. 'filter:ass'.
21
22
  * @property {Record<string, string>} labels