Skip to content

Commit a34bcc7

Browse files
feat: kronos implementation
1 parent 680f07d commit a34bcc7

21 files changed

Lines changed: 3180 additions & 2085 deletions

File tree

Cargo.lock

Lines changed: 702 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ tracing-actix-web = "0.7.21"
100100
url = "2.5.0"
101101
uuid = { version = "1.20.0", features = ["v4", "serde", "js"] }
102102
uniffi = { version = "0.29.3", features = ["cli"] }
103+
kronos-worker = { git = "https://github.com/juspay/kronos.git", rev = "b77d3a6a44dec158f7e83798d1c804e7ded8b15d" }
104+
kronos-common = { git = "https://github.com/juspay/kronos.git", rev = "b77d3a6a44dec158f7e83798d1c804e7ded8b15d" }
103105
superposition = { path = "crates/superposition", version = "0.114.0" }
104106
superposition_types = { path = "crates/superposition_types", version = "0.114.0" }
105107
superposition_derives = { path = "crates/superposition_derives", version = "0.114.0" }

crates/frontend/src/api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ pub async fn create_webhook(
839839
payload_version: PayloadVersion,
840840
custom_headers: CustomHeaders,
841841
events: Vec<WebhookEvent>,
842+
max_retries: i32,
842843
change_reason: String,
843844
workspace: &str,
844845
org_id: &str,
@@ -852,6 +853,7 @@ pub async fn create_webhook(
852853
payload_version: Some(payload_version),
853854
custom_headers: Some(custom_headers),
854855
events,
856+
max_retries: Some(max_retries),
855857
change_reason: ChangeReason::try_from(change_reason)?,
856858
};
857859
let host = use_host_server();

crates/frontend/src/components/webhook_form.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fn try_update_payload(
4343
payload_version: PayloadVersion,
4444
custom_headers: CustomHeaders,
4545
events: Vec<WebhookEvent>,
46+
max_retries: i32,
4647
description: String,
4748
change_reason: String,
4849
) -> Result<UpdateWebhookRequest, String> {
@@ -53,6 +54,7 @@ fn try_update_payload(
5354
payload_version: Some(payload_version),
5455
custom_headers: Some(custom_headers),
5556
events: Some(events),
57+
max_retries: Some(max_retries),
5658
description: Some(Description::try_from(description)?),
5759
change_reason: ChangeReason::try_from(change_reason)?,
5860
})
@@ -69,6 +71,7 @@ pub fn WebhookForm(
6971
#[prop(default = PayloadVersion::default())] payload_version: PayloadVersion,
7072
#[prop(default = CustomHeaders::default())] custom_headers: CustomHeaders,
7173
#[prop(default = Vec::new())] events: Vec<WebhookEvent>,
74+
#[prop(default = 3)] max_retries: i32,
7275
#[prop(into)] handle_submit: Callback<()>,
7376
) -> impl IntoView {
7477
let workspace = use_context::<Signal<Workspace>>().unwrap();
@@ -83,6 +86,7 @@ pub fn WebhookForm(
8386
let (custom_headers_rs, custom_headers_ws) = create_signal(custom_headers);
8487
let (change_reason_rs, change_reason_ws) = create_signal(String::new());
8588
let (events_rs, events_ws) = create_signal(events);
89+
let (max_retries_rs, max_retries_ws) = create_signal(max_retries);
8690
let (req_inprogess_rs, req_inprogress_ws) = create_signal(false);
8791
let update_request_rws = RwSignal::new(None);
8892

@@ -108,6 +112,7 @@ pub fn WebhookForm(
108112
let custom_headers = custom_headers_rs.get_untracked();
109113
let change_reason = change_reason_rs.get_untracked();
110114
let events = events_rs.get_untracked();
115+
let max_retries = max_retries_rs.get_untracked();
111116
let workspace = workspace.get_untracked().0;
112117
let org_id = org.get_untracked().0;
113118

@@ -132,6 +137,7 @@ pub fn WebhookForm(
132137
payload_version,
133138
custom_headers,
134139
events,
140+
max_retries,
135141
description,
136142
change_reason,
137143
);
@@ -152,6 +158,7 @@ pub fn WebhookForm(
152158
payload_version,
153159
custom_headers,
154160
events,
161+
max_retries,
155162
change_reason,
156163
&workspace,
157164
&org_id,
@@ -295,6 +302,22 @@ pub fn WebhookForm(
295302
/>
296303
</div>
297304

305+
<div class="form-control">
306+
<Label title="Max Retries" description="Number of retry attempts on failure." />
307+
<Input
308+
placeholder="Max Retries"
309+
class="input input-bordered w-full max-w-md"
310+
value=Value::Number(serde_json::Number::from(max_retries_rs.get_untracked()))
311+
schema_type=Single(JsonSchemaType::Integer)
312+
r#type=InputType::Integer
313+
on_change=Callback::new(move |value: Value| {
314+
if let Some(n) = value.as_i64().and_then(|n| i32::try_from(n).ok()) {
315+
max_retries_ws.set(n);
316+
}
317+
})
318+
/>
319+
</div>
320+
298321
<div class="form-control gap-3">
299322
<Label
300323
title="Custom Headers"

crates/frontend/src/pages/webhook.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ pub fn Webhook() -> impl IntoView {
219219
custom_headers=webhook_st
220220
.with_value(|w| w.custom_headers.clone())
221221
events=webhook_st.with_value(|w| w.events.clone())
222+
max_retries=webhook_st.with_value(|w| w.max_retries)
222223
handle_submit=move |_| {
223224
webhook_resource.refetch();
224225
action_rws.set(Action::None);

crates/service_utils/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ opentelemetry-instrumentation-actix-web = { workspace = true }
3434
prometheus = { workspace = true }
3535
rand = "0.8"
3636
tokio = { workspace = true }
37+
kronos-worker = { workspace = true }
38+
kronos-common = { workspace = true }
3739
tracing = { workspace = true }
3840
regex = { workspace = true }
3941
reqwest = { workspace = true }

0 commit comments

Comments
 (0)