ognen / miniactors Goto Github PK
View Code? Open in Web Editor NEWA minimal actor implementation for Swift. Built on top of GCD, supporting actor supervision.
License: MIT License
A minimal actor implementation for Swift. Built on top of GCD, supporting actor supervision.
License: MIT License
Setup CI, using Circle CI.
Whenever a message can't be delivered to actor, or is sent to Nobody
, or is not handled by an actor, it needs to end up delivered to a special actor called /system/deadLetters
. This actor is present in all ActorSystems
and initially, just logs the dead letters in a nice way.
It may also be a good idea to envelope the messages sent to the DeadLetters actor, so that the intended recipient (its path
) is also known.
Find a way how an Actor can signal an unhandled message with minimum ceremony.
It is quite common for an actor to ignore messages it is not able to handle at a given moment. This should be handled with minimum ceremony within the receive
method. On the other hand if a message has not been handled by an actor, its cell should report it to the dead letters mailbox.
This poses a requirement on the actor's receive
method to signal whether a message has been handled or not. The question is how to do it properly.
Akka makes use of Scala's partial functions and the built in syntactic sugar for them to solve this elegantly (the cell can inspect whether the receive
method is defined at a certain value).
In Swift we have to be more explicit. Possible solutions:
receive
method explicitly consume
s it.recieve
methods raises a specific error to signal otherwisereceive
method returns Handled|Unhandled to signal the outcome.Think about other possibilities (return the message if unhandled, etc...)
Implement the ask pattern in ActorRef
. The basic signature is already there.
Implementation details. Whenever someone asks an actor about something, the following happens:
/system/queries
Here in the callback signature, it's OK to use Swift 5's result type.
Also provide:
Implement the become
and unbecome
methods for actors (via the actor context). See Akka's documentation for details.
Implement the stashing / unstashing feature as described here.
Implement ActorRef.forward
. The method should allow message forwarding, i.e.
// within an actor method
func receive(msg: Any) {
let ref: ActorRef = // ...
ref.forward(msg: msg)
}
In this case, the actor behind ref
will receive the message with the original sender rather than the actor that forwards it (as it would happen if one goes for ref.tell(msg)
. The call is equivalent to
ref.tell(msg: msg, sender: sender)
executed in an actor's receive method.
ActorRef.tell(msg:sender:)
should be made internal to the project.
A forwarding operator might also be added, e.g. !<<
, as in
ref !<< msg
this
might be confusing in the swift context. Perhaps ref
or refToSelf
or selfRef
or something more pleasing.
Use Coveralls.io
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.