-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add basic actor model #29
Conversation
e6ab5f0
to
bdf0c8b
Compare
223293d
to
0510aff
Compare
The most basic actor model is added for other components to interact, and an example of how the model should run is added in this PR, please have a review @PainterPuppets @felicityin @yanguoyu |
use eslint-disable-next-line instead of eslint-disable
4651e1e
to
9e7cb32
Compare
Does a example of communication between two actors need to be added? |
The example in the PR shows how actors communicate with each other, the root actor requests its child to increment its state by one and gets a response saying the child one has updated its state. > handle call request from root with symbol Symbol(one)
> /root: increment 1
> handle cast request from child_one with symbol Symbol(done)
> task is done |
I see it. |
2f1dccf
to
b7ac004
Compare
Please have a review @PainterPuppets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main idea delivered by the actor model is Divide-and-Conquer. If a heavy task is assigned to actor_a, the task would be split into sub-tasks and delegated to actor_a's child actors, recursively, until sub-tasks are small enough to be handled in one piece.
Is this part of the documentation implemented in another pr?
The current code does not seem to describe the behavior between parents and children
How to model users' business logic depends on their goals and kuai won't tell users how to split their tasks. But one target of kuai is to help users to divide their big task into small tasks easily and suitable for cell model so some paradigms are adopted in kuai and expected to prevail in dapps built on kuai. Once these paradigms prevades, interoperability among dapps would increase. |
This PR adds the actor model in a basic format for future development, an actor should have
ref
: reference to the actor;static method call/cast
: send call/cast request to the message queue;instance method call/cast
: wrappedstatic method call/cast
;handleCall/handleCast
: unified API to handle messages, and the messages will be delegated to user-defined business methods.Only actor is the key module implemented in this PR so it's covered by unit tests,
message-queue will be replaced with redis stream
and registry will be replaced with inversify so they are not covered by tests.
Besides, an example of how to use actors is added in src/examples/app
Ref: #4