Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ members = [
path = "engine/packages/depot-client-types"
version = "=2.3.3-rc.2"

[workspace.dependencies.rivetkit]
path = "rivetkit-rust/packages/rivetkit"
version = "=2.3.3-rc.2"

[workspace.dependencies.rivetkit-core]
path = "rivetkit-rust/packages/rivetkit-core"
version = "=2.3.3-rc.2"
Expand Down
2 changes: 1 addition & 1 deletion rivetkit-rust/packages/rivetkit/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::queue::QueueSet;
#[async_trait]
pub trait Actor: Send + Sync + Sized + 'static {
type State: Serialize + DeserializeOwned + Send + Sync + 'static;
type Input: DeserializeOwned + Send + 'static;
type Input: DeserializeOwned + Default + Send + 'static;
type Actions: ActionSet<Self>;
type Events: EventSet;
type Queue: QueueSet<Self>;
Expand Down
1 change: 1 addition & 0 deletions rivetkit-rust/packages/rivetkit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub use rivetkit_core::metrics_endpoint::RenderedMetrics;
pub use rivetkit_core::serverless::{
CoreServerlessRuntime, ServerlessRequest, ServerlessResponse, ServerlessStreamError,
};
pub use rivetkit_core::serverless_http;
pub use rivetkit_core::{
ActorConfig, ActorKey, ActorKeySegment, CanHibernateWebSocket, CompletableQueueMessage,
ConnHandle, ConnId, EngineSpawnMode, EnqueueAndWaitOpts, KeepAwakeRegion, Kv, ListOpts,
Expand Down
34 changes: 27 additions & 7 deletions rivetkit-rust/packages/rivetkit/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ pub async fn run_actor<A: Actor>(start: Start<A>) -> Result<()> {

let state = match snapshot.decode()? {
Some(state) => state,
None => A::create_state(&ctx, input.decode()?).await?,
// Absent input falls back to the input type's default, matching
// rivetkit-typescript where createState receives undefined input.
None => A::create_state(&ctx, input.decode_or_default()?).await?,
};
ctx.set_state(state);
ctx.clear_state_dirty();
Expand Down Expand Up @@ -647,7 +649,7 @@ mod tests {
}
}

#[derive(Debug, PartialEq, Eq, Serialize, serde::Deserialize)]
#[derive(Debug, Default, PartialEq, Eq, Serialize, serde::Deserialize)]
struct LifecycleInput {
count: u32,
}
Expand All @@ -658,7 +660,7 @@ mod tests {
log: Vec<String>,
}

#[derive(Debug, PartialEq, Eq, Serialize, serde::Deserialize)]
#[derive(Debug, Default, PartialEq, Eq, Serialize, serde::Deserialize)]
struct UnitInput;

#[derive(Debug, Default, PartialEq, Eq, Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -1638,13 +1640,18 @@ mod tests {
"local",
));

let is_new = snapshot.is_none();
let start = Start {
ctx: ctx.clone(),
input: Input {
bytes: input,
_p: PhantomData,
},
snapshot: Snapshot { bytes: snapshot },
is_new,
snapshot: Snapshot {
is_new,
bytes: snapshot,
},
hibernated: Vec::new(),
events: Events {
ctx: ctx.clone(),
Expand All @@ -1669,13 +1676,18 @@ mod tests {
"local",
));

let is_new = snapshot.is_none();
Start {
ctx: ctx.clone(),
input: Input {
bytes: input,
_p: PhantomData,
},
snapshot: Snapshot { bytes: snapshot },
is_new,
snapshot: Snapshot {
is_new,
bytes: snapshot,
},
hibernated: Vec::new(),
events: Events {
ctx,
Expand All @@ -1700,7 +1712,11 @@ mod tests {
bytes: None,
_p: PhantomData,
},
snapshot: Snapshot { bytes: None },
is_new: true,
snapshot: Snapshot {
is_new: true,
bytes: None,
},
hibernated: Vec::new(),
events: Events {
ctx,
Expand All @@ -1726,7 +1742,11 @@ mod tests {
bytes: None,
_p: PhantomData,
},
snapshot: Snapshot { bytes: None },
is_new: true,
snapshot: Snapshot {
is_new: true,
bytes: None,
},
hibernated: Vec::new(),
events: Events {
ctx,
Expand Down
Loading