Skip to content

Commit ad0cea8

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Remove optional from outcome.proto (#41827)
Gets rid of some TODOs and some error handling code that is now unnecessary. GitOrigin-RevId: d540891cb19699e68d3c8bd27c02d770ed7b4f7d
1 parent 449d4c1 commit ad0cea8

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed

crates/pb/protos/outcome.proto

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ message FunctionOutcome {
1717
}
1818

1919
message UdfOutcome {
20-
optional bytes rng_seed = 1;
21-
optional bool observed_rng = 2;
20+
bytes rng_seed = 1;
21+
bool observed_rng = 2;
2222

23-
optional google.protobuf.Timestamp unix_timestamp = 3;
24-
optional bool observed_time = 4;
23+
google.protobuf.Timestamp unix_timestamp = 3;
24+
bool observed_time = 4;
2525

2626
reserved 5;
2727
repeated LogLine log_lines = 9;
@@ -30,12 +30,12 @@ message UdfOutcome {
3030
common.FunctionResult result = 7;
3131
SyscallTrace syscall_trace = 8;
3232

33-
optional bool observed_identity = 10;
33+
bool observed_identity = 10;
3434
uint64 memory_in_mb = 11;
3535
}
3636

3737
message ActionOutcome {
38-
optional google.protobuf.Timestamp unix_timestamp = 3;
38+
google.protobuf.Timestamp unix_timestamp = 3;
3939

4040
reserved 5;
4141
reserved 9;
@@ -53,18 +53,18 @@ message HttpActionOutcome {
5353

5454
uint64 memory_in_mb = 4;
5555

56-
optional string path = 5;
57-
optional string method = 6;
56+
string path = 5;
57+
string method = 6;
5858
}
5959

6060
message SyscallTrace {
6161
map<string, SyscallStats> async_syscalls = 1;
6262
}
6363

6464
message SyscallStats {
65-
optional uint32 invocations = 1;
66-
optional uint32 errors = 2;
67-
optional google.protobuf.Duration total_duration = 3;
65+
uint32 invocations = 1;
66+
uint32 errors = 2;
67+
google.protobuf.Duration total_duration = 3;
6868
}
6969

7070
message SystemLogMetadata {
@@ -76,7 +76,7 @@ message StructuredLogLine {
7676
string level = 2;
7777
bool is_truncated = 3;
7878
google.protobuf.Timestamp timestamp = 4;
79-
optional SystemLogMetadata system_metadata = 5;
79+
SystemLogMetadata system_metadata = 5;
8080
repeated string messages = 6;
8181
}
8282

crates/udf/src/action_outcome.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,7 @@ impl HttpActionOutcome {
241241
},
242242
None => HttpActionResult::Streamed,
243243
};
244-
// TODO: Add `.context()` and remove fallback to `HttpRequestHead`
245-
let method = match method {
246-
Some(m) => m.parse()?,
247-
None => http_request.method.clone().try_into()?,
248-
};
249-
let path = match path {
250-
Some(p) => p,
251-
None => http_request.url.to_string(),
252-
};
244+
let method = method.parse()?;
253245
Ok(Self {
254246
identity,
255247
unix_timestamp: unix_timestamp
@@ -291,8 +283,8 @@ impl TryFrom<HttpActionOutcome> for HttpActionOutcomeProto {
291283
result: Some(FunctionResultProto { result }),
292284
syscall_trace: Some(syscall_trace.try_into()?),
293285
memory_in_mb,
294-
path: Some(route.path.to_string()),
295-
method: Some(route.method.to_string()),
286+
path: route.path.to_string(),
287+
method: route.method.to_string(),
296288
})
297289
}
298290
}

crates/udf/src/syscall_stats.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ impl TryFrom<SyscallStats> for SyscallStatsProto {
6666
}: SyscallStats,
6767
) -> anyhow::Result<Self> {
6868
Ok(Self {
69-
invocations: Some(invocations),
70-
errors: Some(errors),
69+
invocations,
70+
errors,
7171
total_duration: Some(total_duration.try_into()?),
7272
})
7373
}
@@ -84,9 +84,8 @@ impl TryFrom<SyscallStatsProto> for SyscallStats {
8484
}: SyscallStatsProto,
8585
) -> anyhow::Result<Self> {
8686
Ok(Self {
87-
invocations: invocations.ok_or_else(|| anyhow::anyhow!("Missing invocations"))?,
88-
errors: errors
89-
.ok_or_else(|| anyhow::anyhow!("Missing errors in SyscallStats deserialization"))?,
87+
invocations,
88+
errors,
9089
total_duration: total_duration
9190
.ok_or_else(|| anyhow::anyhow!("Missing total duration"))?
9291
.try_into()?,

crates/udf/src/udf_outcome.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ impl TryFrom<UdfOutcome> for UdfOutcomeProto {
101101
Err(js_error) => FunctionResultTypeProto::JsError(js_error.try_into()?),
102102
};
103103
Ok(Self {
104-
rng_seed: Some(rng_seed.to_vec()),
105-
observed_rng: Some(observed_rng),
104+
rng_seed: rng_seed.to_vec(),
105+
observed_rng,
106106
unix_timestamp: Some(unix_timestamp.into()),
107-
observed_time: Some(observed_time),
107+
observed_time,
108108
log_lines: log_lines.into_iter().map(|l| l.into()).collect(),
109109
journal: Some(journal.into()),
110110
result: Some(FunctionResultProto {
111111
result: Some(result),
112112
}),
113113
syscall_trace: Some(syscall_trace.try_into()?),
114-
observed_identity: Some(observed_identity),
114+
observed_identity,
115115
memory_in_mb,
116116
})
117117
}
@@ -162,7 +162,6 @@ impl UdfOutcome {
162162
path_and_args: ValidatedPathAndArgs,
163163
identity: InertIdentity,
164164
) -> anyhow::Result<Self> {
165-
let rng_seed = rng_seed.ok_or_else(|| anyhow::anyhow!("Missing rng_seed"))?;
166165
let rng_seed = rng_seed
167166
.as_slice()
168167
.try_into()
@@ -182,11 +181,11 @@ impl UdfOutcome {
182181
arguments,
183182
identity,
184183
rng_seed,
185-
observed_rng: observed_rng.unwrap_or_default(),
184+
observed_rng,
186185
unix_timestamp: unix_timestamp
187186
.ok_or_else(|| anyhow::anyhow!("Missing unix_timestamp"))?
188187
.try_into()?,
189-
observed_time: observed_time.unwrap_or_default(),
188+
observed_time,
190189
log_lines,
191190
journal: journal
192191
.ok_or_else(|| anyhow::anyhow!("Missing journal"))?
@@ -196,8 +195,7 @@ impl UdfOutcome {
196195
.ok_or_else(|| anyhow::anyhow!("Missing syscall_trace"))?
197196
.try_into()?,
198197
udf_server_version,
199-
// TODO(lee): Remove the default once we've pushed all services.
200-
observed_identity: observed_identity.unwrap_or(true),
198+
observed_identity,
201199
memory_in_mb,
202200
})
203201
}

0 commit comments

Comments
 (0)