Giter VIP home page Giter VIP logo

miniactors's People

Contributors

ognen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

miniactors's Issues

Ask Pattern

Implement the ask pattern in ActorRef. The basic signature is already there.

Implementation details. Whenever someone asks an actor about something, the following happens:

  • a temporary actor is created under /system/queries
  • this actor poses the question and awaits the answer (for a certain amount of time)
  • once the response msg arrives it completes the callback
  • on timeout, it should complete with error.

Here in the callback signature, it's OK to use Swift 5's result type.

Dead Letters

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.

Unhandled Messages

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:

  • The cell will assume that a message is unhandled unless the receive method explicitly consumes it.
  • The cell will assume that the message is handled unless the recieve methods raises a specific error to signal otherwise
  • The cell doesn't assume anythign. The receive method returns Handled|Unhandled to signal the outcome.

Think about other possibilities (return the message if unhandled, etc...)

Message Forwarding

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

Stashing

Implement the stashing / unstashing feature as described here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.