@norskvideo/ctl-product-template-schema 0.1.50 → 0.1.52

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.
Files changed (3) hide show
  1. package/index.d.ts +13 -0
  2. package/index.js +21 -0
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -150,6 +150,11 @@ export declare const ProductTemplateMigrationSchema: z.ZodObject<{
150
150
  }>;
151
151
  }, z.core.$strip>;
152
152
  export type ProductTemplateMigration = z.infer<typeof ProductTemplateMigrationSchema>;
153
+ export declare const ProductTemplateLeaseSchema: z.ZodObject<{
154
+ protected: z.ZodLiteral<true>;
155
+ graceMs: z.ZodOptional<z.ZodNumber>;
156
+ }, z.core.$strip>;
157
+ export type ProductTemplateLease = z.infer<typeof ProductTemplateLeaseSchema>;
153
158
  export declare const PRODUCT_TEMPLATE_WORKLOAD_ROLES: readonly ["viewer", "operator", "builder"];
154
159
  export declare const ProductTemplateWorkloadSchema: z.ZodObject<{
155
160
  role: z.ZodEnum<{
@@ -352,6 +357,10 @@ export declare const ProductTemplateManifestSchema: z.ZodObject<{
352
357
  name: z.ZodString;
353
358
  version: z.ZodNumber;
354
359
  }, z.core.$catchall<z.ZodUnknown>>>>;
360
+ lease: z.ZodOptional<z.ZodObject<{
361
+ protected: z.ZodLiteral<true>;
362
+ graceMs: z.ZodOptional<z.ZodNumber>;
363
+ }, z.core.$strip>>;
355
364
  migration: z.ZodOptional<z.ZodObject<{
356
365
  strategy: z.ZodEnum<{
357
366
  overlap: "overlap";
@@ -609,6 +618,10 @@ export declare const ProductTemplateMaterialsSchema: z.ZodObject<{
609
618
  name: z.ZodString;
610
619
  version: z.ZodNumber;
611
620
  }, z.core.$catchall<z.ZodUnknown>>>>;
621
+ lease: z.ZodOptional<z.ZodObject<{
622
+ protected: z.ZodLiteral<true>;
623
+ graceMs: z.ZodOptional<z.ZodNumber>;
624
+ }, z.core.$strip>>;
612
625
  migration: z.ZodOptional<z.ZodObject<{
613
626
  strategy: z.ZodEnum<{
614
627
  overlap: "overlap";
package/index.js CHANGED
@@ -320,6 +320,24 @@ export const ProductTemplateMigrationSchema = z
320
320
  }),
321
321
  })
322
322
  .meta({ id: "ProductTemplateMigration", outputId: "ProductTemplateMigration" });
323
+ // Lease-protected instances (norsk task 115 Phase 6; protocol 1.6). A product
324
+ // whose instance holds something that must never be in use by two encoders
325
+ // at once — an Akamai entry point, a multicast address, a SIP number —
326
+ // declares it here; the Manager does not need to know what the thing is.
327
+ // An instance lost uncleanly (its worker dropped off the network) is then
328
+ // not started again until `graceMs` has passed (absent: the deployment's,
329
+ // 60 s by default), and its worker stops it when it can no longer reach a
330
+ // live Manager. A clean stop needs no grace. Pair it with the default
331
+ // `stopThenStart` migration: an `overlap` migration would run two at once,
332
+ // which the Manager refuses for a lease-protected instance.
333
+ export const ProductTemplateLeaseSchema = z
334
+ .object({
335
+ protected: z.literal(true).meta({ description: "This product's instances are lease-protected." }),
336
+ graceMs: z.number().int().positive().max(3_600_000).optional().meta({
337
+ description: "How long an instance whose worker was lost uncleanly waits before it may start elsewhere, in ms. Must exceed the workers' lease deadline (30 s by default) by a margin. Absent: the deployment's (60 s by default).",
338
+ }),
339
+ })
340
+ .meta({ id: "ProductTemplateLease", outputId: "ProductTemplateLease" });
323
341
  // The roles a template may declare for its instances' workload: at most
324
342
  // builder, since registering a template takes builder and that registration is
325
343
  // the consent. Built-in names only, whose meaning every host agrees on.
@@ -388,6 +406,9 @@ export const ProductTemplateManifestSchema = z
388
406
  interfaces: z.array(ProductTemplateInterfaceSchema).optional().meta({
389
407
  description: "Named, versioned contracts this template implements (e.g. norsk.io/media-conversion), so a client can find the templates that implement one whatever product built them. Each entry is carried verbatim; the runner checks only contracts it knows, so a template declaring one an older ctl does not know still launches. Absent = implements none.",
390
408
  }),
409
+ lease: ProductTemplateLeaseSchema.optional().meta({
410
+ description: "Lease-protected instances: each holds something that must never be in use by two encoders at once. An instance lost uncleanly is not started again until its grace has passed; a clean stop needs none.",
411
+ }),
391
412
  migration: ProductTemplateMigrationSchema.optional().meta({
392
413
  description: "How a running instance may be moved between nodes. `strategy` is the strongest promise the product keeps: `overlap` (target started, then source stopped — both may produce briefly), `stopThenStart` (the default when absent — target prepared but not started, source stopped, target started), or `handover` (the job speaks the worker's migration socket and hands over at an exact position). A migrate request may down-grade to a safer strategy but never up-grade past the declaration. Only the manager reads this; the worker never does.",
393
414
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-product-template-schema",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {