Coder Social home page Coder Social logo

Comments (4)

kemitix avatar kemitix commented on June 6, 2024 1

That appears to be working for me. Pity to loose some of the strong typing, but that'd be the same with BoxedMessage.

Thanks for the advice.

from ractor.

slawlor avatar slawlor commented on June 6, 2024

Can you make your message type

dyn Any?

Similar to what boxed message is doing behind the scenes. It means you have to cast to the expected type within your actors handler, however that's pretty similar to what Erlang does since there is no strong typing. If you want to go that route, the supervision model will protect you from unexpected casting errors causing your actor to crash

Does that solve your need? I also have kind of stumbled across this and didn't have a great solution at the time, however I have not myself explored using the Anytype but I think it should work.

from ractor.

kemitix avatar kemitix commented on June 6, 2024

I'll have a look at using Any and see.

the supervision model will protect you from unexpected casting errors causing your actor to crash

Having the Actor crash on a bad cast would prevent the next cast attempt from being tried, no? I may be misunderstanding you.

I'll try adding the Any and see where that gets me.

from ractor.

slawlor avatar slawlor commented on June 6, 2024

Yes you are right, on a crash you will lose the pending message queue as it'll be cleaned up with actor teardown. If you want to persist the message queue, usually what we would do is have a supervisor, of that single actor which is trying the downcast, which manages the queue and only allows the child to process one message at a time and maintain no queue.

It would sort of be like a factory of one, where the factory maintains an internal state of the messages in queue, and the child is a worker. If the child crashes, the supervisor can capture the crash and restart the child without losing the pending message queue

from ractor.

Related Issues (20)

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.