Skip to content

Commit e6465a3

Browse files
gautamg795Convex, Inc.
authored and
Convex, Inc.
committed
update applicationapi to use ResolvedHost
GitOrigin-RevId: c3622368e13b6298b724b04187417dbc1d6b8da7
1 parent 21f4010 commit e6465a3

File tree

10 files changed

+233
-88
lines changed

10 files changed

+233
-88
lines changed

crates/application/src/api.rs

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ use common::{
1010
CanonicalizedComponentFunctionPath,
1111
ComponentId,
1212
},
13+
http::ResolvedHost,
1314
pause::PauseClient,
1415
runtime::Runtime,
1516
types::{
1617
AllowedVisibility,
18+
ConvexOrigin,
1719
FunctionCaller,
1820
RepeatableTimestamp,
1921
},
@@ -89,14 +91,14 @@ pub enum ExecuteQueryTimestamp {
8991
pub trait ApplicationApi: Send + Sync {
9092
async fn authenticate(
9193
&self,
92-
host: &str,
94+
host: &ResolvedHost,
9395
request_id: RequestId,
9496
auth_token: AuthenticationToken,
9597
) -> anyhow::Result<Identity>;
9698

9799
async fn execute_public_query(
98100
&self,
99-
host: &str,
101+
host: &ResolvedHost,
100102
request_id: RequestId,
101103
identity: Identity,
102104
path: CanonicalizedComponentFunctionPath,
@@ -108,7 +110,7 @@ pub trait ApplicationApi: Send + Sync {
108110

109111
async fn execute_public_mutation(
110112
&self,
111-
host: &str,
113+
host: &ResolvedHost,
112114
request_id: RequestId,
113115
identity: Identity,
114116
path: CanonicalizedComponentFunctionPath,
@@ -120,7 +122,7 @@ pub trait ApplicationApi: Send + Sync {
120122

121123
async fn execute_public_action(
122124
&self,
123-
host: &str,
125+
host: &ResolvedHost,
124126
request_id: RequestId,
125127
identity: Identity,
126128
path: CanonicalizedComponentFunctionPath,
@@ -130,7 +132,7 @@ pub trait ApplicationApi: Send + Sync {
130132

131133
async fn execute_any_function(
132134
&self,
133-
host: &str,
135+
host: &ResolvedHost,
134136
request_id: RequestId,
135137
identity: Identity,
136138
path: CanonicalizedComponentFunctionPath,
@@ -140,13 +142,13 @@ pub trait ApplicationApi: Send + Sync {
140142

141143
async fn latest_timestamp(
142144
&self,
143-
host: &str,
145+
host: &ResolvedHost,
144146
request_id: RequestId,
145147
) -> anyhow::Result<RepeatableTimestamp>;
146148

147149
async fn execute_http_action(
148150
&self,
149-
host: &str,
151+
host: &ResolvedHost,
150152
request_id: RequestId,
151153
http_request_metadata: HttpActionRequest,
152154
identity: Identity,
@@ -156,16 +158,17 @@ pub trait ApplicationApi: Send + Sync {
156158

157159
async fn check_store_file_authorization(
158160
&self,
159-
host: &str,
161+
host: &ResolvedHost,
160162
request_id: RequestId,
161163
token: &str,
162164
validity: Duration,
163165
) -> anyhow::Result<ComponentId>;
164166

165167
async fn store_file(
166168
&self,
167-
host: &str,
169+
host: &ResolvedHost,
168170
request_id: RequestId,
171+
origin: ConvexOrigin,
169172
component: ComponentId,
170173
content_length: Option<ContentLength>,
171174
content_type: Option<ContentType>,
@@ -175,17 +178,19 @@ pub trait ApplicationApi: Send + Sync {
175178

176179
async fn get_file_range(
177180
&self,
178-
host: &str,
181+
host: &ResolvedHost,
179182
request_id: RequestId,
183+
origin: ConvexOrigin,
180184
component: ComponentId,
181185
file_storage_id: FileStorageId,
182186
range: (Bound<u64>, Bound<u64>),
183187
) -> anyhow::Result<FileRangeStream>;
184188

185189
async fn get_file(
186190
&self,
187-
host: &str,
191+
host: &ResolvedHost,
188192
request_id: RequestId,
193+
origin: ConvexOrigin,
189194
component: ComponentId,
190195
file_storage_id: FileStorageId,
191196
) -> anyhow::Result<FileStream>;
@@ -197,15 +202,18 @@ pub trait ApplicationApi: Send + Sync {
197202
// socket connection. NOTE: We might eventually strengthen the requirement for
198203
// the implementation and require it to reconnect internally but easier to
199204
// start this way.
200-
async fn subscription_client(&self, host: &str) -> anyhow::Result<Box<dyn SubscriptionClient>>;
205+
async fn subscription_client(
206+
&self,
207+
host: &ResolvedHost,
208+
) -> anyhow::Result<Box<dyn SubscriptionClient>>;
201209
}
202210

203211
// Implements ApplicationApi via Application.
204212
#[async_trait]
205213
impl<RT: Runtime> ApplicationApi for Application<RT> {
206214
async fn authenticate(
207215
&self,
208-
_host: &str,
216+
_host: &ResolvedHost,
209217
_request_id: RequestId,
210218
auth_token: AuthenticationToken,
211219
) -> anyhow::Result<Identity> {
@@ -215,7 +223,7 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
215223

216224
async fn execute_public_query(
217225
&self,
218-
_host: &str,
226+
_host: &ResolvedHost,
219227
request_id: RequestId,
220228
identity: Identity,
221229
path: CanonicalizedComponentFunctionPath,
@@ -239,7 +247,7 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
239247

240248
async fn execute_public_mutation(
241249
&self,
242-
_host: &str,
250+
_host: &ResolvedHost,
243251
request_id: RequestId,
244252
identity: Identity,
245253
path: CanonicalizedComponentFunctionPath,
@@ -267,7 +275,7 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
267275

268276
async fn execute_public_action(
269277
&self,
270-
_host: &str,
278+
_host: &ResolvedHost,
271279
request_id: RequestId,
272280
identity: Identity,
273281
path: CanonicalizedComponentFunctionPath,
@@ -285,7 +293,7 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
285293

286294
async fn execute_any_function(
287295
&self,
288-
_host: &str,
296+
_host: &ResolvedHost,
289297
request_id: RequestId,
290298
identity: Identity,
291299
path: CanonicalizedComponentFunctionPath,
@@ -297,15 +305,15 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
297305

298306
async fn latest_timestamp(
299307
&self,
300-
_host: &str,
308+
_host: &ResolvedHost,
301309
_request_id: RequestId,
302310
) -> anyhow::Result<RepeatableTimestamp> {
303311
Ok(self.now_ts_for_reads())
304312
}
305313

306314
async fn execute_http_action(
307315
&self,
308-
_host: &str,
316+
_host: &ResolvedHost,
309317
request_id: RequestId,
310318
http_request_metadata: HttpActionRequest,
311319
identity: Identity,
@@ -324,7 +332,7 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
324332

325333
async fn check_store_file_authorization(
326334
&self,
327-
_host: &str,
335+
_host: &ResolvedHost,
328336
_request_id: RequestId,
329337
token: &str,
330338
validity: Duration,
@@ -335,8 +343,9 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
335343

336344
async fn store_file(
337345
&self,
338-
_host: &str,
346+
_host: &ResolvedHost,
339347
_request_id: RequestId,
348+
_origin: ConvexOrigin,
340349
component: ComponentId,
341350
content_length: Option<ContentLength>,
342351
content_type: Option<ContentType>,
@@ -355,8 +364,9 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
355364

356365
async fn get_file_range(
357366
&self,
358-
_host: &str,
367+
_host: &ResolvedHost,
359368
_request_id: RequestId,
369+
_origin: ConvexOrigin,
360370
component: ComponentId,
361371
file_storage_id: FileStorageId,
362372
range: (Bound<u64>, Bound<u64>),
@@ -366,8 +376,9 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
366376

367377
async fn get_file(
368378
&self,
369-
_host: &str,
379+
_host: &ResolvedHost,
370380
_request_id: RequestId,
381+
_origin: ConvexOrigin,
371382
component: ComponentId,
372383
file_storage_id: FileStorageId,
373384
) -> anyhow::Result<FileStream> {
@@ -376,7 +387,7 @@ impl<RT: Runtime> ApplicationApi for Application<RT> {
376387

377388
async fn subscription_client(
378389
&self,
379-
_host: &str,
390+
_host: &ResolvedHost,
380391
) -> anyhow::Result<Box<dyn SubscriptionClient>> {
381392
Ok(Box::new(ApplicationSubscriptionClient {
382393
database: self.database.clone(),

0 commit comments

Comments
 (0)