Skip to content

Commit

Permalink
docs: use new api
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriano Santos committed Jan 6, 2025
1 parent 96c8991 commit 15ca7fd
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions docs/projections.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,26 @@ message ProductInventory {
string name = 2; // Product name
int32 quantity = 3; // Quantity in stock
}
service WarehouseActor {
option (spawn.actors.actor) = {
kind: NAMED
stateful: true
state_type: ".inventory.WarehouseState",
// here we are indicating that the state of this actor
// can be captured by any projection actor that is interested
sourceable: true
};
rpc UpdateInventory(.inventory.ProductInventory) returns (.google.protobuf.Empty);
}
```

2. Implement the sourceable actor:

```elixir
defmodule MyAppxample.Actors.WarehouseActor do
use SpawnSdk.Actor,
name: "WarehouseActor",
state_type: Inventory.WarehouseState,
# here we are indicating that the state of this actor
# can be captured by any projection actor that is interested
sourceable: true
use SpawnSdk.Actor, name: "WarehouseActor",

alias Inventory.{WarehouseState, ProductInventory}

Expand Down Expand Up @@ -163,7 +171,7 @@ service InventoryProjection {

## Implementing Projection Actors

After defining the Protobuf, implement the projection actor using the Spawn SDK. For example:
After defining the Protobuf, implement the projection actor using the Spawn Elixir SDK. For example:

```elixir
defmodule MyAppxample.Actors.InventoryProjectionActor do
Expand Down

0 comments on commit 15ca7fd

Please sign in to comment.