# Interface ActorDriver

interface ActorDriver {
getContext(actorId: string): unknown;
getDatabase(actorId: string): Promise<unknown>;
getExtraActorLogParams?(): Record<string, string>;
kvBatchDelete(
actorId: string,
keys: Uint8Array<ArrayBufferLike>[],
): Promise<void>;
kvBatchGet(
actorId: string,
keys: Uint8Array<ArrayBufferLike>[],
): Promise<(Uint8Array<ArrayBufferLike> | null)[]>;
kvBatchPut(
actorId: string,
entries: [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>][],
): Promise<void>;
kvListPrefix(
actorId: string,
prefix: Uint8Array,
): Promise<[Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>][]>;
loadActor(actorId: string): Promise<AnyActorInstance>;
serverlessHandleStart?(c: Context): Promise<Response>;
setAlarm(actor: AnyActorInstance, timestamp: number): Promise<void>;
shutdownRunner?(immediate: boolean): Promise<void>;
startSleep?(actorId: string): void;
}

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:15

##### Index

### Methods

getContext
getDatabase
getExtraActorLogParams?
kvBatchDelete
kvBatchGet
kvBatchPut
kvListPrefix
loadActor
serverlessHandleStart?
setAlarm
shutdownRunner?
startSleep?

## Methods

### getContext

- getContext(actorId: string): unknown

  #### Parameters

  - actorId: string

  #### Returns unknown

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:20

### getDatabase

- getDatabase(actorId: string): Promise<unknown>
  `Experimental`

  This is an experimental API that may change in the future.

  #### Parameters

  - actorId: string

  #### Returns Promise<unknown>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:53

### `Optional` getExtraActorLogParams

- getExtraActorLogParams?(): Record<string, string>

  Extra properties to add to logs for each actor.

  #### Returns Record<string, string>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:72

### kvBatchDelete

- kvBatchDelete(
  actorId: string,
  keys: Uint8Array<ArrayBufferLike>[],
  ): Promise<void>

  Batch delete multiple keys.

  #### Parameters

  - actorId: string
  - keys: Uint8Array<ArrayBufferLike>[]

  #### Returns Promise<void>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:36

### kvBatchGet

- kvBatchGet(
  actorId: string,
  keys: Uint8Array<ArrayBufferLike>[],
  ): Promise<(Uint8Array<ArrayBufferLike> | null)[]>

  Batch read multiple keys. Returns null for keys that don't exist.

  #### Parameters

  - actorId: string
  - keys: Uint8Array<ArrayBufferLike>[]

  #### Returns Promise<(Uint8Array<ArrayBufferLike> | null)[]>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:30

### kvBatchPut

- kvBatchPut(
  actorId: string,
  entries: [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>][],
  ): Promise<void>

  Batch write multiple key-value pairs. Keys and values are Uint8Arrays.

  #### Parameters

  - actorId: string
  - entries: [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>][]

  #### Returns Promise<void>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:24

### kvListPrefix

- kvListPrefix(
  actorId: string,
  prefix: Uint8Array,
  ): Promise<[Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>][]>

  List all keys with a given prefix.

  #### Parameters

  - actorId: string
  - prefix: Uint8Array

  #### Returns Promise<[Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>][]>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:39

### loadActor

- loadActor(actorId: string): Promise<AnyActorInstance>

  #### Parameters

  - actorId: string

  #### Returns Promise<AnyActorInstance>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:18

### `Optional` serverlessHandleStart

- serverlessHandleStart?(c: Context): Promise<Response>

  This handles the serverless start request. This should manage the lifecycle of the runner tied to the request lifecycle.

  #### Parameters

  - c: Context

  #### Returns Promise<Response>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:69

### setAlarm

- setAlarm(actor: AnyActorInstance, timestamp: number): Promise<void>

  ActorInstance ensure that only one instance of setAlarm is called in parallel at a time.

  #### Parameters

  - actor: AnyActorInstance
  - timestamp: number

  #### Returns Promise<void>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:46

### `Optional` shutdownRunner

- shutdownRunner?(immediate: boolean): Promise<void>

  Shuts down the actor runner.

  #### Parameters

  - immediate: boolean

  #### Returns Promise<void>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:65

### `Optional` startSleep

- startSleep?(actorId: string): void

  Requests the actor to go to sleep.

  This will call `_stop` independently.

  #### Parameters

  - actorId: string

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/driver.ts:60