Skip to content

Commit 1b4be2b

Browse files
committed
Use new spawn protocol version
1 parent 892f687 commit 1b4be2b

File tree

8 files changed

+126
-57
lines changed

8 files changed

+126
-57
lines changed

protobuf/eigr/functions/protocol/actors/protocol.proto

+2
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ message ActorInvocationResponse {
407407
}
408408

409409
Workflow workflow = 5;
410+
411+
bool checkpoint = 7;
410412
}
411413

412414
// InvocationResponse is the response that the proxy that received the InvocationRequest request will forward to the request's original user function.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// The Spawn State Extension Protocol
2+
//
3+
//
4+
syntax = "proto3";
5+
6+
package eigr.functions.protocol.state;
7+
8+
import "eigr/functions/protocol/actors/actor.proto";
9+
10+
option java_package = "io.eigr.functions.protocol.state";
11+
option go_package = "github.com/eigr/go-support/eigr/protocol/state;state";
12+
13+
// A revision is just a version number for a record in the snapshot table that stores the actors' state.
14+
// When an actor has its snaphost timeout, it increments its internal revision number and saves it along with its internal data.
15+
// Some of the persistence adapters can use this revision number to find the state of an Actor at a given point in time.
16+
// As Actors in Spawn persist their internal data as snapshots from time to time a revision number may not indicate the state of a given change
17+
// but will most likely point to the exact time that a given actor's internal state was persisted into the database.
18+
message Revision {
19+
int64 value = 1;
20+
}
21+
22+
// A checkpoint encapsulates a revision and the state it represents.
23+
message Checkpoint {
24+
25+
Revision revision = 1;
26+
27+
eigr.functions.protocol.actors.ActorState state = 2;
28+
}

scripts/compile-pb.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -o errexit
55
set -o pipefail
66

77
# follow the basic steps here: https://grpc.io/docs/tutorials/basic/python/
8-
#protoc -I ../protobuf/ --python_out=../spawn eigr/functions/protocol/actors/actor.proto
9-
#protoc -I ../protobuf/ --python_out=../spawn eigr/functions/protocol/actors/protocol.proto
8+
protoc -I ../protobuf/ --python_out=../spawn eigr/functions/protocol/actors/actor.proto
9+
protoc -I ../protobuf/ --python_out=../spawn eigr/functions/protocol/actors/protocol.proto
10+
protoc -I ../protobuf/ --python_out=../spawn eigr/functions/protocol/actors/state.proto
1011

1112
protoc -I ../example/protobuf/ --python_out=../example ../example/protobuf/domain/domain.proto

spawn/eigr/functions/actors/api/value.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Value():
2727
__forward: Forward = None
2828
__pipe: Pipe = None
2929
__reply_kind: ReplyKind = ReplyKind.REPLY
30+
__checkpoint: bool = False
3031

3132
def get_state(self):
3233
return self.__state
@@ -55,6 +56,9 @@ def get_pipe(self):
5556
def get_reply_kind(self):
5657
return self.__reply_kind
5758

59+
def has_checkpoint(self):
60+
return self.__checkpoint
61+
5862
def of(self, value, state=None):
5963
self.__response = value
6064
self.__state = state
@@ -96,10 +100,12 @@ def pipe(self, pipe: Pipe):
96100
self.__pipe = pipe
97101
return self
98102

99-
def reply(self):
103+
def reply(self, checkpoint: bool = False):
100104
self.__reply_kind = ReplyKind.REPLY
105+
self.__checkpoint = checkpoint
101106
return self
102107

103-
def noreply(self):
108+
def noreply(self, checkpoint: bool = False):
104109
self.__reply_kind = ReplyKind.NO_REPLY
110+
self.__checkpoint = checkpoint
105111
return self

spawn/eigr/functions/actors/internal/controller.py

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def handle_response(system, actor_name, result):
127127
pipe.action_name = p.action
128128
actor_invocation_response.workflow.pipe.CopyFrom(pipe)
129129

130+
if result.has_checkpoint():
131+
actor_invocation_response.checkpoint = True
132+
130133
return actor_invocation_response
131134

132135

spawn/eigr/functions/protocol/actors/actor_pb2.py

+45-45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)