Skip to content

Commit 50a60ed

Browse files
refactor: extract restate services into crates with type-safe pipeline status (#3919)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d1d43fa commit 50a60ed

File tree

28 files changed

+708
-173
lines changed

28 files changed

+708
-173
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ hypr-porkbun = { path = "crates/porkbun", package = "porkbun" }
8787
hypr-posthog = { path = "crates/posthog", package = "posthog" }
8888
hypr-pyannote-cloud = { path = "crates/pyannote-cloud", package = "pyannote-cloud" }
8989
hypr-pyannote-local = { path = "crates/pyannote-local", package = "pyannote-local" }
90+
hypr-restate-rate-limit = { path = "crates/restate-rate-limit", package = "restate-rate-limit" }
91+
hypr-restate-stt = { path = "crates/restate-stt", package = "restate-stt" }
92+
hypr-restate-stt-types = { path = "crates/restate-stt-types", package = "restate-stt-types" }
9093
hypr-s3 = { path = "crates/s3", package = "s3" }
9194
hypr-slack = { path = "crates/slack", package = "slack" }
9295
hypr-supabase-auth = { path = "crates/supabase-auth", package = "supabase-auth" }

apps/api/openapi.gen.json

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,40 @@
239239
}
240240
}
241241
},
242+
"/stt/status/{pipeline_id}": {
243+
"get": {
244+
"tags": [
245+
"stt"
246+
],
247+
"operationId": "handler",
248+
"parameters": [
249+
{
250+
"name": "pipeline_id",
251+
"in": "path",
252+
"description": "Pipeline ID (Restate workflow key)",
253+
"required": true,
254+
"schema": {
255+
"type": "string"
256+
}
257+
}
258+
],
259+
"responses": {
260+
"200": {
261+
"description": "Pipeline status",
262+
"content": {
263+
"application/json": {
264+
"schema": {
265+
"$ref": "#/components/schemas/SttStatusResponse"
266+
}
267+
}
268+
}
269+
},
270+
"502": {
271+
"description": "Restate service unavailable"
272+
}
273+
}
274+
}
275+
},
242276
"/subscription/can-start-trial": {
243277
"get": {
244278
"tags": [
@@ -641,6 +675,15 @@
641675
}
642676
}
643677
},
678+
"PipelineStatus": {
679+
"type": "string",
680+
"enum": [
681+
"QUEUED",
682+
"TRANSCRIBING",
683+
"DONE",
684+
"ERROR"
685+
]
686+
},
644687
"StartTrialReason": {
645688
"type": "string",
646689
"enum": [
@@ -671,6 +714,29 @@
671714
}
672715
}
673716
},
717+
"SttStatusResponse": {
718+
"type": "object",
719+
"required": [
720+
"status"
721+
],
722+
"properties": {
723+
"error": {
724+
"type": [
725+
"string",
726+
"null"
727+
]
728+
},
729+
"status": {
730+
"$ref": "#/components/schemas/PipelineStatus"
731+
},
732+
"transcript": {
733+
"type": [
734+
"string",
735+
"null"
736+
]
737+
}
738+
}
739+
},
674740
"WebhookResponse": {
675741
"type": "object",
676742
"required": [
@@ -720,7 +786,7 @@
720786
"description": "Subscription and trial management"
721787
},
722788
{
723-
"name": "transcribe",
789+
"name": "stt",
724790
"description": "Speech-to-text transcription proxy"
725791
},
726792
{

apps/restate/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7+
hypr-restate-rate-limit = { workspace = true }
8+
hypr-restate-stt = { workspace = true }
79
restate-sdk = "0.7.0"
810

9-
chrono = { workspace = true, features = ["serde"] }
1011
dotenvy = { workspace = true }
1112
envy = { workspace = true }
12-
reqwest = { workspace = true, features = ["json"] }
1313
serde = { workspace = true, features = ["derive"] }
14-
serde_json = { workspace = true }
1514
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal"] }
1615
tracing = { workspace = true }
1716
tracing-subscriber = { workspace = true, features = ["env-filter"] }
18-
urlencoding = { workspace = true }

apps/restate/src/main.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1+
use hypr_restate_rate_limit::{RateLimiter, RateLimiterImpl};
2+
use hypr_restate_stt::{Config, StorageCleanup, StorageCleanupImpl, SttFile, SttFileImpl};
13
use restate_sdk::endpoint::Endpoint;
24
use restate_sdk::http_server::HttpServer;
35

46
mod env;
5-
mod services;
6-
mod soniox;
7-
mod supabase;
8-
9-
use services::rate_limit::RateLimiter;
10-
use services::storage_cleanup::StorageCleanup;
11-
use services::stt_file::SttFile;
127

138
#[tokio::main]
149
async fn main() {
1510
tracing_subscriber::fmt::init();
1611
let env = env::env();
1712

13+
let config: &'static Config = Box::leak(Box::new(Config {
14+
restate_ingress_url: env.restate_ingress_url.clone(),
15+
soniox_api_key: env.soniox_api_key.clone(),
16+
supabase_url: env.supabase_url.clone(),
17+
supabase_service_role_key: env.supabase_service_role_key.clone(),
18+
}));
19+
1820
let mut builder = Endpoint::builder()
19-
.bind(services::SttFileImpl::new(env).serve())
20-
.bind(services::RateLimiterImpl.serve())
21-
.bind(services::StorageCleanupImpl::new(env).serve());
21+
.bind(SttFileImpl::new(config).serve())
22+
.bind(RateLimiterImpl.serve())
23+
.bind(StorageCleanupImpl::new(config).serve());
2224

2325
if let Some(key) = &env.restate_identity_key {
2426
builder = builder.identity_key(key).expect("invalid identity key");

apps/restate/src/services/mod.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/restate/src/services/rate_limit.rs

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "restate-rate-limit"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
restate-sdk = "0.7.0"
8+
9+
serde = { workspace = true, features = ["derive"] }
10+
serde_json = { workspace = true }

0 commit comments

Comments
 (0)