https://github.com/nhomble/shakespeare
my toy actor model framework
https://github.com/nhomble/shakespeare
Last synced: 3 months ago
JSON representation
my toy actor model framework
- Host: GitHub
- URL: https://github.com/nhomble/shakespeare
- Owner: nhomble
- Created: 2018-12-28T13:36:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-29T11:11:21.000Z (over 6 years ago)
- Last Synced: 2025-01-21T00:47:23.943Z (5 months ago)
- Language: Java
- Size: 23.4 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
shakespeare
===
A toy actor-model framework that makes no attempt to be better than akka.```java
public class SpawnWaitExample {private static final Logger log = LoggerFactory.getLogger(SpawnWaitExample.class);
public static void main(String... args) {
Theatre theatre = Theatre.builder()
.setName("name")
.build()
.start();theatre.spawn(WaitingActor.class, SpawnOptions.builder()
.setAwaitConfirmation(true)
.build());
theatre.send(Message.builder()
.setData("hello")
.setTo(RootClientActor.REFERENCE.append(WaitingActor.class))
.build());
theatre.shutdown();
}
}
``````java
@Actor
public class WaitingActor {private static final Logger log = LoggerFactory.getLogger(WaitingActor.class);
@OnInit
void init() throws InterruptedException {
log.info("start init");
Thread.sleep(1_000);
log.info("end init");
}@OnMessage
void handle(@Data String msg) {
log.info("message={}", msg);
}
}
```