Skip to content

Commit 7e4493f

Browse files
committed
feat: implement new actor ids
1 parent 6a71c38 commit 7e4493f

File tree

122 files changed

+1935
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1935
-558
lines changed

Cargo.lock

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

examples/system-test-actor/src/managerClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function connectToManager() {
2020

2121
let message = {
2222
init: {
23-
runner_id: process.env.RIVET_RUNNER_ID
23+
access_token: process.env.RIVET_ACCESS_TOKEN
2424
}
2525
};
2626
let buffer = Buffer.from(JSON.stringify(message));

packages/common/api-helper/macros/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate proc_macro;
33
use std::iter::FromIterator;
44

55
use proc_macro::TokenStream;
6-
use proc_macro2::{Literal, TokenStream as TokenStream2, TokenTree};
6+
use proc_macro2::{Literal, Spacing, TokenStream as TokenStream2, TokenTree};
77
use proc_macro_error::{emit_warning, proc_macro_error};
88
use quote::{format_ident, quote, ToTokens};
99
use syn::{
@@ -454,6 +454,22 @@ impl Parse for Endpoint {
454454
while let Some((tt, next)) = rest.token_tree() {
455455
match &tt {
456456
TokenTree::Punct(punct) if punct.as_char() == ':' => {
457+
// Check for path separator (::)
458+
if punct.spacing() == Spacing::Joint {
459+
if let Some((tt2, next)) = next.token_tree() {
460+
match &tt2 {
461+
TokenTree::Punct(punct) if punct.as_char() == ':' => {
462+
tts.push(tt);
463+
tts.push(tt2);
464+
rest = next;
465+
466+
continue;
467+
}
468+
_ => {}
469+
}
470+
}
471+
}
472+
457473
return Ok((tts.into_iter().collect::<TokenStream2>(), next));
458474
}
459475
_ => {

packages/common/chirp-workflow/core/src/db/crdb_nats/debug.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ impl DatabaseDebug for DatabaseCrdbNats {
535535
tags,
536536
NULL AS workflow_id,
537537
create_ts,
538+
silence_ts,
538539
body,
539540
ack_ts
540541
FROM db_workflow.tagged_signals

packages/common/chirp-workflow/core/src/db/fdb_sqlite_nats/keys/workflow.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,6 @@ impl TuplePack for ByNameAndTagSubspaceKey {
926926
&self.k,
927927
&self.v,
928928
);
929-
tracing::info!(?t, "---------------------");
930929
t.pack(w, tuple_depth)
931930
}
932931
}

packages/common/chirp-workflow/core/src/db/fdb_sqlite_nats/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,6 @@ impl Database for DatabaseFdbSqliteNats {
27952795
// TODO: Add config parameter in either fdb or sqlite to toggle this per wf
27962796
let delete_instead_of_forget =
27972797
workflow_name == "pegboard_client" || workflow_name == "pegboard_actor";
2798-
// let delete_instead_of_forget = false;
27992798

28002799
if delete_instead_of_forget {
28012800
sql_execute!(

packages/common/config/src/config/server/rivet/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,3 +850,12 @@ pub struct Edge {
850850
#[serde(default)]
851851
pub redirect_logs_dir: Option<PathBuf>,
852852
}
853+
854+
impl Edge {
855+
/// u16 used in the `Id` type for actors
856+
pub fn datacenter_label(&self) -> u16 {
857+
// Read first 2 bytes
858+
let bytes = self.datacenter_id.as_bytes();
859+
u16::from_be_bytes([bytes[0], bytes[1]])
860+
}
861+
}

packages/common/fdb-util/src/codes.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// FDB defines a range (0x40-0x4f) of user type codes for use with its tuple encoding system.
2+
// https://github.com/apple/foundationdb/blob/main/design/tuple.md#user-type-codes
3+
4+
pub const ID: u8 = 0x40;

packages/common/fdb-util/src/keys.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub const RUNNERS_BY_REMAINING_SLOTS: usize = 49;
5151
pub const REMAINING_SLOTS: usize = 50;
5252
pub const TOTAL_SLOTS: usize = 51;
5353
pub const IMAGE_ID: usize = 52;
54+
pub const ACTOR2: usize = 53;
5455

5556
// Directories with fdbrs must use string paths instead of tuples
5657
pub mod dir {
@@ -114,6 +115,7 @@ pub fn key_from_str(key: &str) -> Option<usize> {
114115
"remaining_slots" => Some(REMAINING_SLOTS),
115116
"total_slots" => Some(TOTAL_SLOTS),
116117
"image_id" => Some(IMAGE_ID),
118+
"actor2" => Some(ACTOR2),
117119
_ => None,
118120
}
119121
}

packages/common/fdb-util/src/lib.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ use foundationdb::{
1111
self as fdb,
1212
future::FdbValue,
1313
options::DatabaseOption,
14-
tuple::{self, PackResult, TuplePack, TupleUnpack},
14+
tuple::{self, PackResult, PackError, TuplePack, TupleUnpack},
1515
KeySelector, RangeOption,
1616
};
1717

1818
pub mod keys;
19+
pub mod codes;
1920
mod metrics;
2021

2122
/// Makes the code blatantly obvious if its using a snapshot read.
@@ -189,6 +190,39 @@ pub fn end_of_key_range(key: &[u8]) -> Vec<u8> {
189190
end_key
190191
}
191192

193+
// Copied from foundationdb crate
194+
#[inline]
195+
pub fn parse_bytes(input: &[u8], num: usize) -> PackResult<(&[u8], &[u8])> {
196+
if input.len() < num {
197+
Err(PackError::MissingBytes)
198+
} else {
199+
Ok((&input[num..], &input[..num]))
200+
}
201+
}
202+
203+
// Copied from foundationdb crate
204+
#[inline]
205+
pub fn parse_byte(input: &[u8]) -> PackResult<(&[u8], u8)> {
206+
if input.is_empty() {
207+
Err(PackError::MissingBytes)
208+
} else {
209+
Ok((&input[1..], input[0]))
210+
}
211+
}
212+
213+
// Copied from foundationdb crate
214+
pub fn parse_code(input: &[u8], expected: u8) -> PackResult<&[u8]> {
215+
let (input, found) = parse_byte(input)?;
216+
if found == expected {
217+
Ok(input)
218+
} else {
219+
Err(PackError::BadCode {
220+
found,
221+
expected: Some(expected),
222+
})
223+
}
224+
}
225+
192226
pub mod prelude {
193227
pub use std::result::Result::Ok;
194228

0 commit comments

Comments
 (0)