1+ syntax = "proto3" ;
2+
3+ package spawn.actors ;
4+
5+ import "google/protobuf/any.proto" ;
6+ import "google/protobuf/timestamp.proto" ;
7+
8+ option java_package = "io.spawn.actors" ;
9+ option go_package = "github.com/eigr/go-support/eigr/actors;actors" ;
10+
11+ message Registry {
12+ map <string , Actor > actors = 1 ;
13+ }
14+
15+ message ActorSystem {
16+ string name = 1 ;
17+ Registry registry = 2 ;
18+ }
19+
20+ // A strategy for save state.
21+ message ActorSnapshotStrategy {
22+ oneof strategy {
23+ // the timeout strategy.
24+ TimeoutStrategy timeout = 1 ;
25+ }
26+ }
27+
28+ // A strategy which a user function's entity is passivated.
29+ message ActorDeactivationStrategy {
30+ oneof strategy {
31+ // the timeout strategy.
32+ TimeoutStrategy timeout = 1 ;
33+ }
34+ }
35+
36+ // A strategy based on a timeout.
37+ message TimeoutStrategy {
38+ // The timeout in millis
39+ int64 timeout = 1 ;
40+ }
41+
42+ // A action represents an action that the user can perform on an Actor.
43+ // Actions in supporting languages are represented by functions or methods.
44+ // An Actor action has nothing to do with the semantics of Actions in a
45+ // CQRS/EventSourced system. It just represents an action that supporting
46+ // languages can invoke.
47+ message Action {
48+
49+ // The name of the function or method in the supporting language that has been
50+ // registered in Ator.
51+ string name = 1 ;
52+ }
53+
54+ // A FixedTimerAction is similar to a regular Action, its main differences are
55+ // that it is scheduled to run at regular intervals and only takes the actor's
56+ // state as an argument. Timer Actions are good for executing loops that
57+ // manipulate the actor's own state. In Elixir or other languages in BEAM it
58+ // would be similar to invoking Process.send_after(self(), atom, msg, timeout)
59+ message FixedTimerAction {
60+
61+ // The time to wait until the action is triggered
62+ int32 seconds = 1 ;
63+
64+ // See Action description Above
65+ Action action = 2 ;
66+ }
67+
68+ message ActorState {
69+ map <string , string > tags = 1 ;
70+ google.protobuf.Any state = 2 ;
71+ }
72+
73+ // Metadata represents a set of key-value pairs that can be used to
74+ // provide additional information about an Actor.
75+ message Metadata {
76+ // A channel group represents a way to send actions to various actors
77+ // that belong to a certain semantic group. Following the Pub-Sub pattern.
78+ repeated Channel channel_group = 1 ;
79+
80+ map <string , string > tags = 2 ;
81+ }
82+
83+ // Represents a Pub-Sub binding, where a actor can be subscribed to a channel
84+ // and map a specific action to a specific topic if necessary
85+ // if the action is not informed, the default action will be "receive".
86+ message Channel {
87+ string topic = 1 ;
88+ string action = 2 ;
89+ }
90+
91+ // The type that defines the runtime characteristics of the Actor.
92+ // Regardless of the type of actor it is important that
93+ // all actors are registered during the proxy and host initialization phase.
94+ enum Kind {
95+ // When no type is informed, the default to be assumed will be the Named
96+ // pattern.
97+ UNKNOW_KIND = 0 ;
98+
99+ // NAMED actors as the name suggests have only one real instance of themselves
100+ // running during their entire lifecycle. That is, they are the opposite of
101+ // the UNNAMED type Actors.
102+ NAMED = 1 ;
103+
104+ // UNNAMED actors are used to create children of this based actor at runtime
105+ UNNAMED = 2 ;
106+
107+ // Pooled Actors are similar to Unnamed actors, but unlike them,
108+ // their identifying name will always be the one registered at the system
109+ // initialization stage. The great advantage of Pooled actors is that they
110+ // have multiple instances of themselves acting as a request service pool.
111+ // Pooled actors are also stateless actors, that is, they will not have their
112+ // in-memory state persisted via Statesstore. This is done to avoid problems
113+ // with the correctness of the stored state.
114+ // Pooled Actors are generally used for tasks where the Actor Model would
115+ // perform worse than other concurrency models and for tasks that do not
116+ // require state concerns. Integration flows, data caching, proxies are good
117+ // examples of use cases for this type of Actor.
118+ POOLED = 3 ;
119+
120+ // Reserved for future use
121+ PROXY = 4 ;
122+
123+ TASK = 5 ;
124+
125+ // Projection actors are used to project data from different actor streams.
126+ PROJECTION = 6 ;
127+ }
128+
129+ message ProjectionSubject {
130+ string actor = 1 ;
131+ string source_action = 2 ;
132+ string action = 3 ;
133+ google.protobuf.Timestamp start_time = 4 ;
134+ }
135+
136+ message EventsRetentionStrategy {
137+ oneof strategy {
138+ int64 duration_ms = 1 ;
139+ bool infinite = 2 ;
140+ }
141+ }
142+
143+ message ProjectionSettings {
144+ // Define this for projections that need to listen to events
145+ repeated ProjectionSubject subjects = 1 ;
146+
147+ // Define this for actors that can emit events
148+ bool sourceable = 2 ;
149+
150+ // The strategy for event store retention
151+ EventsRetentionStrategy events_retention_strategy = 3 ;
152+
153+ // Define how we consume events from subjects
154+ bool strict_events_ordering = 4 ;
155+ }
156+
157+ message ActorSettings {
158+
159+ // Indicates the type of Actor to be configured.
160+ Kind kind = 1 ;
161+
162+ // Indicates whether an actor's state should be persisted in a definitive
163+ // store.
164+ bool stateful = 2 ;
165+
166+ // Snapshot strategy
167+ ActorSnapshotStrategy snapshot_strategy = 3 ;
168+
169+ // Deactivate strategy
170+ ActorDeactivationStrategy deactivation_strategy = 4 ;
171+
172+ // When kind is POOLED this is used to define minimun actor instances
173+ int32 min_pool_size = 5 ;
174+
175+ // When kind is POOLED this is used to define maximum actor instances
176+ int32 max_pool_size = 6 ;
177+
178+ // Event source settings
179+ ProjectionSettings projection_settings = 7 ;
180+
181+ // Actor's state type
182+ string state_type = 8 ;
183+ }
184+
185+ message ActorId {
186+ // The name of a Actor Entity.
187+ string name = 1 ;
188+
189+ // Name of a ActorSystem
190+ string system = 2 ;
191+
192+ // When the Actor is of the Unnamed type,
193+ // the name of the parent Actor must be informed here.
194+ string parent = 3 ;
195+ }
196+
197+ message Actor {
198+ // Actor Identification
199+ ActorId id = 1 ;
200+
201+ // A Actor state.
202+ ActorState state = 2 ;
203+
204+ // Actor metadata
205+ Metadata metadata = 6 ;
206+
207+ // Actor settings.
208+ ActorSettings settings = 3 ;
209+
210+ // The actions registered for an actor
211+ repeated Action actions = 4 ;
212+
213+ // The registered timer actions for an actor.
214+ repeated FixedTimerAction timer_actions = 5 ;
215+ }
0 commit comments