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

@skhail/amqp

v1.8.3

Published

AMQP module for @skhail/core. Allows to connect to rabbitmq to organize service communication

Downloads

43

Readme

@skhail/core

This library is the core of the skhail library.

Skhail

Skhail is a way to build application and scale it easily. It provides the basis for any application to be built as a monolith and switch to a micro service architecture with little changes to the code base.

Get ready to contribute

First, install dependencies

yarn install

Second, ... nothing, you are good to go !

Ideology

Skhail is a developper friendly library. It uses typescript to enhance the experience of the developper while providing robust architecture.

Everything should be simple

Service

A service is class that will receive requests. This is how you declare a basic service:

import {SkhailService} from '@skhail/core':

class TodoList extends SkhailService {
    async add(item: string) {
        console.log("add", item);
    }

    async remove(item: string) {
        console.log("remove", item);
    }
}

Asynchronous behaviour is at the core of Skhail. Only methods returning a promise will be callable. The methods add and remove are available.

That's it. You have you first service

Server

The skhail server is the instance that will hold the service and connect them together through a queue and an event system.

To create a server:

import {SkhailServer, ConsoleLogger, LogLevel, InMemoryQueue, InMemoryEventEmitter} from '@skhail/core':
import {TodoList} from './classes':

const server = new SkhailServer({
    services: [new Todolist()],
    logger: new ConsoleLogger(LogLevel.ERROR),
    queue: new InMemoryQueue(),
    event: new InMemoryEventEmitter(),
});

server.start().then(async () => {
    console.log("Server started");

    await server.stop();

    console.log("Server stopped");
});

With this code, the server will start all required resources for the services and setup the communication channels.

Note: the event property is optional and can be omitted if you don't want to have an event system.

Calling a service

Since you now have a server running a service, it would be interesting to call this service

server.start().then(async () => {
  console.log("Server started");

  await server.get(TodoList).add("my first todo list item");
  await server.get(TodoList).add("my second todo list item");
  await server.get(TodoList).remove("my first todo list item");
});

The server will send a message in the queue. The queue will find an instance of the requested service and call the method on this instance. As a monolith, there is only one instance of each service, but in a micro service architecture, multiple instances can be available at once. Only one instance has to be called when calling a method once.