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
29 changes: 29 additions & 0 deletions rivetkit-rust/packages/rivetkit-core/src/actor/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,22 +323,37 @@ impl ActorContext {
ctx
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub async fn kv_batch_get(&self, keys: &[&[u8]]) -> Result<Vec<Option<Vec<u8>>>> {
self.0.kv.batch_get(keys).await
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub async fn kv_batch_put(&self, entries: &[(&[u8], &[u8])]) -> Result<()> {
self.0.kv.batch_put(entries).await
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub async fn kv_batch_delete(&self, keys: &[&[u8]]) -> Result<()> {
self.0.kv.batch_delete(keys).await
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub async fn kv_delete_range(&self, start: &[u8], end: &[u8]) -> Result<()> {
self.0.kv.delete_range(start, end).await
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub async fn kv_list_prefix(
&self,
prefix: &[u8],
Expand All @@ -347,6 +362,9 @@ impl ActorContext {
self.0.kv.list_prefix(prefix, opts).await
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub async fn kv_list_range(
&self,
start: &[u8],
Expand All @@ -356,10 +374,21 @@ impl ActorContext {
self.0.kv.list_range(start, end, opts).await
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
pub fn kv(&self) -> &Kv {
&self.0.kv
}

/// Internal accessor for the actor KV store. Core uses KV as the backing
/// store for the inspector token and actor startup persistence. Unlike the
/// public `kv()` accessor, this is not deprecated because the storage
/// machinery itself is not going away, only the public actor-facing API.
pub(crate) fn kv_internal(&self) -> &Kv {
&self.0.kv
}

pub fn sql(&self) -> &SqliteDb {
&self.0.sql
}
Expand Down
4 changes: 2 additions & 2 deletions rivetkit-rust/packages/rivetkit-core/src/actor/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ impl ActorTask {

let mut values = self
.ctx
.kv()
.kv_internal()
.batch_get(&[PERSIST_DATA_KEY, LAST_PUSHED_ALARM_KEY])
.await
.context("load persisted actor startup data")?
Expand Down Expand Up @@ -1298,7 +1298,7 @@ impl ActorTask {
}

self.ctx
.kv()
.kv_internal()
.get(key)
.await
.context("load persisted actor startup key")
Expand Down
6 changes: 3 additions & 3 deletions rivetkit-rust/packages/rivetkit-core/src/inspector/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl InspectorAuth {
}

let stored_token = ctx
.kv()
.kv_internal()
.get(&INSPECTOR_TOKEN_KEY)
.await
.ok()
Expand Down Expand Up @@ -91,7 +91,7 @@ pub(crate) async fn init_inspector_token_with_preload(
match preloaded_kv.and_then(|preloaded| preloaded.key_entry(&INSPECTOR_TOKEN_KEY)) {
Some(existing) => existing,
None => ctx
.kv()
.kv_internal()
.get(&INSPECTOR_TOKEN_KEY)
.await
.context("load inspector token")?,
Expand All @@ -101,7 +101,7 @@ pub(crate) async fn init_inspector_token_with_preload(
}

let token = generate_inspector_token();
ctx.kv()
ctx.kv_internal()
.put(&INSPECTOR_TOKEN_KEY, token.as_bytes())
.await
.context("persist inspector token")?;
Expand Down
4 changes: 4 additions & 0 deletions rivetkit-rust/packages/rivetkit/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ impl<A: Actor> Ctx<A> {
self.inner.region()
}

#[deprecated(
note = "Actor KV is deprecated. Use embedded SQLite (`sql()`) or actor state instead."
)]
#[allow(deprecated)]
pub fn kv(&self) -> &Kv {
self.inner.kv()
}
Expand Down
8 changes: 8 additions & 0 deletions rivetkit-typescript/packages/rivetkit/src/actor/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ type ActorKvListOptions<

type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;

/**
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db` / `c.sql`)
* or actor state instead.
*/
export interface ActorKv {
get<T extends ActorKvValueType = "text">(
key: Uint8Array | string,
Expand Down Expand Up @@ -305,6 +309,10 @@ export interface ActorContext<
[RAW_STATE_SYMBOL](): TState;
state: TState;
vars: TVars;
/**
* @deprecated Actor KV is deprecated. Use embedded SQLite (`db` / `sql`)
* or actor state instead.
*/
readonly kv: ActorKv;
readonly db: InferDatabaseClient<TDatabase>;
readonly schedule: ActorSchedule;
Expand Down
5 changes: 0 additions & 5 deletions website/src/sitemap/mod.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading