Enter your search

Introducing Ribbon

By
A lightweight Node.js service wrapper

This morning the silence of my room, and subsequently the serenity of my rare hours of sleep were suddenly pierced by my iPhone’s ringtone at 5am. On the other end of the line was the mechanised TTS-voice of our server monitoring system, informing me that our DBs had noticed a drop in connections.

As was my duty, I hopped on to find the source of the issue. It turned out to be faulty reconnection logic in one of many adapters we had developed for managing connections to MySQL servers in our applications. It was a bug that still existed simply because we had too many of these adapters lying around to feasibly maintain, and this one slipped through.

Over many months, I’ve noticed that the various clients on offer for connecting to and working with external services, like Redis, MongoDB, RabbitMQ, MySQL etc. all share very similar concepts: a connection is established to a service running on a server, and depending on the state of that connection, you interact with that service using the client.

However, it’s apparent that while sharing similar concepts (such as a connection must be active before querying, and you won’t get anywhere with a dead connection), these modules didn’t stick to a consistent methodology for your application to understand and respond to changes in state. They’d often use different event names to describe the same states (such as ‘connected’, ‘ready’ ‘open’ to represent an active connection, and ‘close’, ‘end’, ‘exit’, ‘error’ to denote an inactive connection). Worse still, they commonly lacked convenience methods to check the state, such as .isUp() or .isDown().

That’s why I wrote Ribbon

Predominantly formulated during the small hours of this morning, Ribbon is simply defined as a lightweight Node.js service wrapper. It provides a standard set of events and methods for use in your applications to react to and verify the status of external services, as an alternative to dealing with various different terminology and definitions for common state events.

Ribbon instead exposes a set of standard events, such as simply ‘up’ for connection available, and ‘down’ for connection unavailable.

Adaptors
Ribbon includes a collection of adaptors which inherit the ribbon interface. An adaptor is a controller for your underlying connection or service, known as the client. The adaptor is the interface between the service’s client and ribbon.

Adaptors are bundled as part of Ribbon, and I’d be grateful to anyone contributing adaptors for their use case. I’ll be putting together a guide to building an adapter before too long.

See the repo for more info + README.

You May Also Like

Group 5 Created with Sketch. Group 11 Created with Sketch. CLOSE ICON Created with Sketch. icon-microphone Group 9 Created with Sketch. CLOSE ICON Created with Sketch. SEARCH ICON Created with Sketch. Group 4 Created with Sketch. Path Created with Sketch. Group 5 Created with Sketch.