So, Node is becoming more and more a requirement for doing modern dev work. I admit I’ve been slow on the uptake on this, but I’m always wanting to learn new things, so I’ve been getting to grips with it recently.

Spoiler alert: it’s really really easy if you’re coming from a bit of a web background and have written a bit of frontend javascript.

So, in part to build up a bit of node code on my github profile, and in part to prove a concept for something I talked about recently when I rewrote the Known event queue processor back end, I wrote a Node version of the event queue processor service.

Usage

Configure your database settings and path to Known in the package.json.

By default, the settings are configured to talk to Known as installed with by the vagrant package.

Then, run the event queue:

node main.js

» Visit the project on Github...

Sometimes it is desirable to execute actions in the background and periodic intervals. Building on from last week’s post, I wanted to spotlight a new feature, which uses the asynchronous event queue, to allow you to do this – the periodic execution (cron) service.

After completing the configuration step for enabling the Asynchronous Event Queue, you can then run the Known console periodic execution service:

./known.php service-cron

Once running, this service will periodically trigger an event to which code can listen to. Available events are cron/minute, cron/hourly and cron/daily.

While I’ve not really had a chance to talk about it recently, owing to being rather busy, there has been a lot of work done in Known core recently.

Known uses event queues to dispatch things like Webmention pings. By default, this dispatching is synchronous. However, an advanced feature that was recently added, was the ability to enqueue events and have them dispatched later in an asynchronous fashion, enabling faster page loading.

Configuring

As mentioned above, by default Known uses a synchronous event queue. To use something the asynchronous queue, add the following line to your config.ini:

event_queue = 'AsynchronousQueue'

Next, you need to run the Known event queue dispatching service using the Known console tool:

./known service-event-queue

Note: if you’re using per-domain configuration you’ll need to set an environment variable in order for everything to work as expected:

export KNOWN_DOMAIN='your.domain.name'

Enjoy!