Skip to main content

palladium_cli/commands/consensus/
types.rs

1use clap::{Args, Subcommand};
2use schemars::JsonSchema;
3use serde::Serialize;
4
5#[derive(Subcommand, Debug, Serialize, JsonSchema)]
6#[serde(rename_all = "kebab-case")]
7pub enum ConsensusCommand {
8    /// Manage consensus groups.
9    #[command(subcommand)]
10    Group(ConsensusGroupCommand),
11    /// Inspect consensus bindings.
12    #[command(subcommand)]
13    Binding(ConsensusBindingCommand),
14    /// Propose a write via the consensus engine.
15    Propose(ConsensusProposeArgs),
16    /// Perform a linearizable read via the consensus engine.
17    Read(ConsensusReadArgs),
18    /// Show consensus engine info.
19    #[command(subcommand)]
20    Engine(ConsensusEngineCommand),
21}
22
23#[derive(Subcommand, Debug, Serialize, JsonSchema)]
24#[serde(rename_all = "kebab-case")]
25pub enum ConsensusGroupCommand {
26    /// Create a consensus group.
27    Create(ConsensusGroupCreateArgs),
28    /// Attach an actor path to a consensus group.
29    Attach(ConsensusGroupAttachArgs),
30    /// List consensus groups and attached actors.
31    List(ConsensusGroupListArgs),
32    /// Detach an actor path from a consensus group.
33    Detach(ConsensusGroupDetachArgs),
34    /// Delete a consensus group.
35    Delete(ConsensusGroupDeleteArgs),
36    /// Show members of a consensus group.
37    Members(ConsensusGroupMembersArgs),
38    /// Show consensus group status summary.
39    Status(ConsensusGroupStatusArgs),
40}
41
42#[derive(Subcommand, Debug, Serialize, JsonSchema)]
43#[serde(rename_all = "kebab-case")]
44pub enum ConsensusEngineCommand {
45    /// Show whether a consensus engine is configured.
46    Status(ConsensusEngineStatusArgs),
47    /// Show consensus engine configuration (redacted TLS).
48    Config(ConsensusEngineConfigArgs),
49}
50
51#[derive(Subcommand, Debug, Serialize, JsonSchema)]
52#[serde(rename_all = "kebab-case")]
53pub enum ConsensusBindingCommand {
54    /// List actor bindings by consensus group.
55    List(ConsensusBindingListArgs),
56}
57
58#[derive(Args, Debug, Serialize, JsonSchema)]
59#[serde(rename_all = "kebab-case")]
60pub struct ConsensusGroupCreateArgs {
61    /// Group name.
62    #[arg(long)]
63    pub name: String,
64    /// Member engine IDs (repeatable).
65    #[arg(long = "member")]
66    pub members: Vec<String>,
67    /// Heartbeat interval in milliseconds.
68    #[arg(long)]
69    pub heartbeat_interval_ms: Option<u64>,
70    /// Election timeout minimum in milliseconds.
71    #[arg(long)]
72    pub election_timeout_min_ms: Option<u64>,
73    /// Election timeout maximum in milliseconds.
74    #[arg(long)]
75    pub election_timeout_max_ms: Option<u64>,
76    /// Snapshot interval (log entries).
77    #[arg(long)]
78    pub snapshot_interval: Option<u64>,
79    /// Output in JSON format.
80    #[arg(long)]
81    pub json: bool,
82}
83
84#[derive(Args, Debug, Serialize, JsonSchema)]
85#[serde(rename_all = "kebab-case")]
86pub struct ConsensusGroupAttachArgs {
87    /// Group name.
88    #[arg(long)]
89    pub group: String,
90    /// Actor path to attach.
91    #[arg(long)]
92    pub path: String,
93    /// Output in JSON format.
94    #[arg(long)]
95    pub json: bool,
96}
97
98#[derive(Args, Debug, Serialize, JsonSchema)]
99#[serde(rename_all = "kebab-case")]
100pub struct ConsensusGroupListArgs {
101    /// Output in JSON format.
102    #[arg(long)]
103    pub json: bool,
104}
105
106#[derive(Args, Debug, Serialize, JsonSchema)]
107#[serde(rename_all = "kebab-case")]
108pub struct ConsensusGroupDetachArgs {
109    /// Group name.
110    #[arg(long)]
111    pub group: String,
112    /// Actor path to detach.
113    #[arg(long)]
114    pub path: String,
115    /// Output in JSON format.
116    #[arg(long)]
117    pub json: bool,
118}
119
120#[derive(Args, Debug, Serialize, JsonSchema)]
121#[serde(rename_all = "kebab-case")]
122pub struct ConsensusGroupDeleteArgs {
123    /// Group name.
124    #[arg(long)]
125    pub name: String,
126    /// Output in JSON format.
127    #[arg(long)]
128    pub json: bool,
129}
130
131#[derive(Args, Debug, Serialize, JsonSchema)]
132#[serde(rename_all = "kebab-case")]
133pub struct ConsensusGroupMembersArgs {
134    /// Group name.
135    #[arg(long)]
136    pub group: String,
137    /// Output in JSON format.
138    #[arg(long)]
139    pub json: bool,
140}
141
142#[derive(Args, Debug, Serialize, JsonSchema)]
143#[serde(rename_all = "kebab-case")]
144pub struct ConsensusGroupStatusArgs {
145    /// Group name.
146    #[arg(long)]
147    pub group: String,
148    /// Output in JSON format.
149    #[arg(long)]
150    pub json: bool,
151}
152
153#[derive(Args, Debug, Serialize, JsonSchema)]
154#[serde(rename_all = "kebab-case")]
155pub struct ConsensusProposeArgs {
156    /// Group name.
157    #[arg(long)]
158    pub group: String,
159    /// JSON payload to propose.
160    pub payload: String,
161    /// Output in JSON format.
162    #[arg(long)]
163    pub json: bool,
164}
165
166#[derive(Args, Debug, Serialize, JsonSchema)]
167#[serde(rename_all = "kebab-case")]
168pub struct ConsensusReadArgs {
169    /// Group name.
170    #[arg(long)]
171    pub group: String,
172    /// JSON query payload.
173    pub query: String,
174    /// Output in JSON format.
175    #[arg(long)]
176    pub json: bool,
177}
178
179#[derive(Args, Debug, Serialize, JsonSchema)]
180#[serde(rename_all = "kebab-case")]
181pub struct ConsensusEngineStatusArgs {
182    /// Output in JSON format.
183    #[arg(long)]
184    pub json: bool,
185}
186
187#[derive(Args, Debug, Serialize, JsonSchema)]
188#[serde(rename_all = "kebab-case")]
189pub struct ConsensusEngineConfigArgs {
190    /// Output in JSON format.
191    #[arg(long)]
192    pub json: bool,
193}
194
195#[derive(Args, Debug, Serialize, JsonSchema)]
196#[serde(rename_all = "kebab-case")]
197pub struct ConsensusBindingListArgs {
198    /// Output in JSON format.
199    #[arg(long)]
200    pub json: bool,
201}