Skip to main content

hyperi_rustlib/deployment/
waves.rs

1// Project:   hyperi-rustlib
2// File:      src/deployment/waves.rs
3// Purpose:   Shared ArgoCD sync-wave constants
4//
5// License:   FSL-1.1-ALv2
6// Copyright: (c) 2026 HYPERI PTY LIMITED
7
8//! ArgoCD sync-wave constants.
9//!
10//! Convention for the order in which ArgoCD applies resources during a
11//! sync. Lower waves run first. Used as the `argocd.argoproj.io/sync-wave`
12//! annotation on Application resources and as the default for
13//! [`crate::deployment::ArgocdConfig::sync_wave`].
14//!
15//! The numeric values are gaps wide enough that consumer projects can
16//! slot custom waves (e.g. `-15` for "between operators and CRDs", `-3`
17//! for "before topics but after CRDs"). Stick to the canonical bands
18//! where possible -- operators install order is genuinely
19//! dependency-driven.
20
21/// Operators that must install before everything else (e.g.
22/// Strimzi Kafka Operator, External Secrets Operator).
23/// Their CRDs are prerequisites for later waves.
24pub const WAVE_OPERATORS: i32 = -20;
25
26/// Custom Resource Definitions that other resources depend on.
27/// Runs after operators (which often install their own CRDs).
28pub const WAVE_CRDS: i32 = -10;
29
30/// Cross-application Kafka topology: `KafkaTopic`, `KafkaUser`,
31/// and similar CRs that DFE apps consume.
32pub const WAVE_TOPICS: i32 = -5;
33
34/// DFE apps themselves (loader, receiver, archiver, ...).
35/// The default for any Application without an explicit sync wave.
36pub const WAVE_APPS: i32 = 0;
37
38/// Post-deployment work: smoke tests, notification webhooks,
39/// observability registrations.
40pub const WAVE_POST: i32 = 10;
41
42// Compile-time invariants for the wave constants. Each leaves room for
43// consumer-specific slots between the canonical waves (e.g. -15 between
44// OPERATORS and CRDS). WAVE_APPS=0 is the documented default for plain
45// Application resources without a more specific wave.
46const _: () = assert!(WAVE_OPERATORS < WAVE_CRDS);
47const _: () = assert!(WAVE_CRDS < WAVE_TOPICS);
48const _: () = assert!(WAVE_TOPICS < WAVE_APPS);
49const _: () = assert!(WAVE_APPS < WAVE_POST);
50const _: () = assert!(WAVE_APPS == 0);
51const _: () = assert!(WAVE_CRDS - WAVE_OPERATORS >= 5);
52const _: () = assert!(WAVE_TOPICS - WAVE_CRDS >= 5);
53const _: () = assert!(WAVE_APPS - WAVE_TOPICS >= 5);
54const _: () = assert!(WAVE_POST - WAVE_APPS >= 5);