File tree Expand file tree Collapse file tree 3 files changed +64
-1
lines changed Expand file tree Collapse file tree 3 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 1+ local spawn = require (" eigr.spawn" )
2+ local JoeActor = require (" examples.joe_actor" )
3+
4+ local system = spawn .new_system (" spawn-system" )
5+ :with_actor (JoeActor )
6+ :start ()
Original file line number Diff line number Diff line change @@ -9,11 +9,23 @@ function Client.new(host, port)
99 local self = setmetatable ({}, Client )
1010 self .host = host or " localhost"
1111 self .port = port or 8091
12+ self .connected = false
1213 return self
1314end
1415
16+ function Client :connect ()
17+ -- TODO Actual gRPC connection implementation
18+ self .connected = true
19+ return true
20+ end
21+
22+ function Client :register_actor (actor_def )
23+ -- TODO Implementation of logging via Spawn protocol
24+ print ((" Registering actor: %s" ):format (actor_def .name ))
25+ end
26+
1527function Client :invoke_actor (actor , message )
16- -- Implementação da comunicação com o Spawn System
28+ -- TODO Implementing communication with the Spawn System
1729end
1830
1931return Client
Original file line number Diff line number Diff line change 1+ local Spawn = {}
2+ local Client = require (" eigr.spawn.client" )
3+ local Actors = require (" eigr.spawn.actors" )
4+
5+ function Spawn .new_system (name )
6+ local system = {
7+ name = name ,
8+ actors = {}
9+ }
10+
11+ local self = setmetatable (system , { __index = Spawn })
12+ return self
13+ end
14+
15+ function Spawn :with_actor (actor_module )
16+ table.insert (self .actors , actor_module )
17+ return self
18+ end
19+
20+ function Spawn :start ()
21+ print ((" Starting Spawn System [%s]..." ):format (self .name ))
22+
23+ -- TODO Initialize gRPC client
24+ local client = Client .new (" localhost" , 8091 )
25+
26+ -- TODO Registers all actors
27+ for _ , actor in ipairs (self .actors ) do
28+ local config = actor :configure ()
29+ print ((" Registering Actor [%s]..." ):format (config .name ))
30+
31+ -- TODO Implement actual logging logic
32+ client :register_actor ({
33+ name = config .name ,
34+ channels = config .channels ,
35+ actions = config .actions
36+ })
37+ end
38+
39+ print (" System started successfully" )
40+ return true
41+ end
42+
43+ return {
44+ new_system = Spawn .new_system
45+ }
You can’t perform that action at this time.
0 commit comments