Skip to content

Commit 657ceea

Browse files
Preslav LeConvex, Inc.
authored andcommitted
Get allowed visibility based on the caller instead of passing it seperatly. (#25521)
Allowed visibility is completely derivable by the function caller. There are many places we pass the two alongside each other but this is error prone. The redundant code is especially problematic as we introduce more layers and services. Instead of this, add a method to functionCaller that gives is allowed visibility, and deleted all redundant code. GitOrigin-RevId: f8167938fb011f15fab2b175a5e6c6c66e9df2e7
1 parent b947cdb commit 657ceea

File tree

12 files changed

+40
-115
lines changed

12 files changed

+40
-115
lines changed

crates/application/src/application_function_runner/mod.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
660660
mut tx: Transaction<RT>,
661661
udf_path: CanonicalizedUdfPath,
662662
arguments: ConvexArray,
663-
allowed_visibility: AllowedVisibility,
664663
caller: FunctionCaller,
665664
) -> anyhow::Result<UdfOutcome> {
666665
if !(tx.identity().is_admin() || tx.identity().is_system()) {
@@ -670,7 +669,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
670669
let identity = tx.inert_identity();
671670
let start = self.runtime.monotonic_now();
672671
let validate_result = ValidatedUdfPathAndArgs::new(
673-
allowed_visibility,
672+
caller.allowed_visibility(),
674673
&mut tx,
675674
udf_path.clone(),
676675
arguments.clone(),
@@ -731,7 +730,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
731730
arguments: Vec<JsonValue>,
732731
identity: Identity,
733732
mutation_identifier: Option<SessionRequestIdentifier>,
734-
allowed_visibility: AllowedVisibility,
735733
caller: FunctionCaller,
736734
pause_client: PauseClient,
737735
block_logging: bool,
@@ -744,7 +742,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
744742
arguments,
745743
identity,
746744
mutation_identifier,
747-
allowed_visibility,
748745
caller,
749746
pause_client,
750747
block_logging,
@@ -766,7 +763,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
766763
arguments: Vec<JsonValue>,
767764
identity: Identity,
768765
mutation_identifier: Option<SessionRequestIdentifier>,
769-
allowed_visibility: AllowedVisibility,
770766
caller: FunctionCaller,
771767
mut pause_client: PauseClient,
772768
block_logging: bool,
@@ -818,7 +814,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
818814
tx,
819815
udf_path.clone(),
820816
arguments.clone(),
821-
allowed_visibility.clone(),
817+
caller.allowed_visibility(),
822818
context.clone(),
823819
)
824820
.await;
@@ -1034,7 +1030,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
10341030
name: UdfPath,
10351031
arguments: Vec<JsonValue>,
10361032
identity: Identity,
1037-
allowed_visibility: AllowedVisibility,
10381033
caller: FunctionCaller,
10391034
block_logging: bool,
10401035
) -> anyhow::Result<Result<ActionReturn, ActionError>> {
@@ -1059,7 +1054,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
10591054
name.clone(),
10601055
arguments.clone(),
10611056
identity.clone(),
1062-
allowed_visibility,
10631057
caller.clone(),
10641058
usage_tracking.clone(),
10651059
context.clone(),
@@ -1109,21 +1103,12 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
11091103
name: CanonicalizedUdfPath,
11101104
arguments: ConvexArray,
11111105
identity: Identity,
1112-
allowed_visibility: AllowedVisibility,
11131106
caller: FunctionCaller,
11141107
usage_tracking: FunctionUsageTracker,
11151108
context: ExecutionContext,
11161109
) -> anyhow::Result<ActionCompletion> {
11171110
let result = self
1118-
.run_action_inner(
1119-
name,
1120-
arguments,
1121-
identity,
1122-
allowed_visibility,
1123-
caller,
1124-
usage_tracking,
1125-
context,
1126-
)
1111+
.run_action_inner(name, arguments, identity, caller, usage_tracking, context)
11271112
.await;
11281113
match result.as_ref() {
11291114
Ok(completion) => {
@@ -1151,7 +1136,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
11511136
name: CanonicalizedUdfPath,
11521137
arguments: ConvexArray,
11531138
identity: Identity,
1154-
allowed_visibility: AllowedVisibility,
11551139
caller: FunctionCaller,
11561140
usage_tracking: FunctionUsageTracker,
11571141
context: ExecutionContext,
@@ -1166,7 +1150,7 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
11661150
.begin_with_usage(identity.clone(), usage_tracking)
11671151
.await?;
11681152
let validate_result = ValidatedUdfPathAndArgs::new(
1169-
allowed_visibility,
1153+
caller.allowed_visibility(),
11701154
&mut tx,
11711155
name.clone(),
11721156
arguments.clone(),
@@ -1821,7 +1805,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
18211805
identity: Identity,
18221806
ts: Timestamp,
18231807
journal: Option<QueryJournal>,
1824-
allowed_visibility: AllowedVisibility,
18251808
caller: FunctionCaller,
18261809
block_logging: bool,
18271810
) -> anyhow::Result<QueryReturn> {
@@ -1833,7 +1816,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
18331816
identity,
18341817
ts,
18351818
journal,
1836-
allowed_visibility,
18371819
caller,
18381820
block_logging,
18391821
)
@@ -1866,7 +1848,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
18661848
identity: Identity,
18671849
ts: Timestamp,
18681850
journal: Option<QueryJournal>,
1869-
allowed_visibility: AllowedVisibility,
18701851
caller: FunctionCaller,
18711852
block_logging: bool,
18721853
) -> anyhow::Result<QueryReturn> {
@@ -1900,7 +1881,6 @@ impl<RT: Runtime> ApplicationFunctionRunner<RT> {
19001881
identity.clone(),
19011882
ts,
19021883
journal,
1903-
allowed_visibility,
19041884
caller,
19051885
block_logging,
19061886
usage_tracker.clone(),
@@ -1986,7 +1966,6 @@ impl<RT: Runtime> ActionCallbacks for ApplicationFunctionRunner<RT> {
19861966
identity,
19871967
*ts,
19881968
None,
1989-
AllowedVisibility::All,
19901969
FunctionCaller::Action {
19911970
parent_scheduled_job: context.parent_scheduled_job,
19921971
},
@@ -2013,7 +1992,6 @@ impl<RT: Runtime> ActionCallbacks for ApplicationFunctionRunner<RT> {
20131992
args,
20141993
identity,
20151994
None,
2016-
AllowedVisibility::All,
20171995
FunctionCaller::Action {
20181996
parent_scheduled_job: context.parent_scheduled_job,
20191997
},
@@ -2044,7 +2022,6 @@ impl<RT: Runtime> ActionCallbacks for ApplicationFunctionRunner<RT> {
20442022
name,
20452023
args,
20462024
identity,
2047-
AllowedVisibility::All,
20482025
FunctionCaller::Action {
20492026
parent_scheduled_job: context.parent_scheduled_job,
20502027
},

crates/application/src/cache/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ impl<RT: Runtime> CacheManager<RT> {
205205
identity: Identity,
206206
ts: Timestamp,
207207
journal: Option<QueryJournal>,
208-
allowed_visibility: AllowedVisibility,
209208
caller: FunctionCaller,
210209
block_logging: bool,
211210
usage_tracker: FunctionUsageTracker,
@@ -219,7 +218,6 @@ impl<RT: Runtime> CacheManager<RT> {
219218
identity,
220219
ts,
221220
journal,
222-
allowed_visibility,
223221
caller,
224222
block_logging,
225223
usage_tracker,
@@ -245,7 +243,6 @@ impl<RT: Runtime> CacheManager<RT> {
245243
identity: Identity,
246244
ts: Timestamp,
247245
journal: Option<QueryJournal>,
248-
allowed_visibility: AllowedVisibility,
249246
caller: FunctionCaller,
250247
block_logging: bool,
251248
usage_tracker: FunctionUsageTracker,
@@ -257,7 +254,7 @@ impl<RT: Runtime> CacheManager<RT> {
257254
args: args.clone(),
258255
identity: identity_cache_key,
259256
journal: journal.unwrap_or_else(QueryJournal::new),
260-
allowed_visibility,
257+
allowed_visibility: caller.allowed_visibility(),
261258
};
262259
let context = ExecutionContext::new(request_id, &caller);
263260

crates/application/src/cron_jobs/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use common::{
3232
RuntimeInstant,
3333
},
3434
types::{
35-
AllowedVisibility,
3635
FunctionCaller,
3736
UdfType,
3837
},
@@ -351,7 +350,7 @@ impl<RT: Runtime> CronJobExecutor<RT> {
351350
tx,
352351
job.cron_spec.udf_path.clone(),
353352
job.cron_spec.udf_args.clone(),
354-
AllowedVisibility::All,
353+
caller.allowed_visibility(),
355354
context.clone(),
356355
)
357356
.await;
@@ -482,7 +481,6 @@ impl<RT: Runtime> CronJobExecutor<RT> {
482481
job.clone().cron_spec.udf_path,
483482
job.cron_spec.udf_args,
484483
identity.clone(),
485-
AllowedVisibility::All,
486484
caller,
487485
usage_tracker.clone(),
488486
context.clone(),

0 commit comments

Comments
 (0)