npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aktor-js

v1.4.0

Published

Actor model (style) API in JS

Downloads

19

Readme

Actor Model in JS

Exploring the potential benefits of implementing APIs in the style of the Actor Model, even in single-threaded programming environments such as Javascript.

TODO

Actor system ActorSystem

  • [x] createSystem()
  • [x] system.actorOf(IActorFactory) -> ActorRef

Actors Actor

  • [x] actor.tell() - fire & forget message
  • [x] actor.ask() - ask & await async response from an actor
  • [x] actor.stop() - send a message instructing an actor to terminate

Actor context ActorContext

  • [x] context.stop(IActorRef) - allow an actor to be stopped via a ref
  • [x] context.gracefulStop(IActorRef) - allow an actor to be stopped via a ref with confirmation (for sequencing etc)
  • [x] context.actorOf(IActorFactory) - allow an actor to create more actors
  • [x] context.parent - allow an actor to access it's parent (in order to send it messages)
  • [x] context.self - allow an actor to access it's own ref (in order to send it's self messages)
  • [ ] context.become(newHandler) - designate a new handler for future messages http://doc.akka.io/docs/akka/current/scala/actors.html#Graceful_Stop
  • [x] context.actorSelection(lookup: string) - allow actor lookups via paths, such as /system /deadletter etc

Actor receive method

  • [x] receive(payload, message, sender)

  • [x] sender.reply() for replying directly to a message

  • [x] mappedMethods define 1 function per message name

  • [x] handle cancellation of pending message should a new one override it

  • [x] pass state into mapped methods for encapsulated state management

  • [x] sender - allow every message access to an ActorRef that allow communication with the sender

    receive (payload message sender)
      switch payload
        case 'ping' sender.reply 'pong'
        default sender.reply 'missing'
        
    // callsite
    actor.ask 'ping'
      |> resp console.log 'resp:' + resp

Actor Lifecycle

  • actorOf(...)
    • [x] path is reserved
    • [ ] uuid is assigned
    • [x] actor instance is created
    • [x] preStart is called on instance
  • Incarnation (restarting)
    • [x] preRestart called on old instance
    • [x] new instance replaces old
    • [x] postRestart called on new instance
  • Stop, context.stop() or PoisonPill
    • [x] postStop is called on instance
    • [x] actor is removed from the internal system register
    • [ ] Terminated is sent to watchers
    • [x] path is free to be used again
  • graceful stop http://doc.akka.io/docs/akka/current/scala/actors.html#Graceful_Stop
    • [ ] become() - designate a new handler for future messages

Actor References, Paths and Addresses

  • [x] actorOf() only ever creates a new actor, and it creates it as a direct child of the context on which this method is invoked (which may be any actor or actor system).
  • [ ] /deadletters all messages sent to stopped or non-existing actors are re-routed here
  • [x] /system is the guardian actor for all system-created top-level actors, e.g. logging listeners or actors automatically deployed by configuration at the start of the actor system.