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

@nexgin/totaljsapplication

v0.0.66

Published

TotalJS Application Components

Downloads

338

Readme

Version Node version MIT License

Downloads Total downloads Packagephobia Bundlephobia

Table of contents

Description

This project provides a set of components to help build applications using TotalJS Flow. The two main components are the Application and the Module. The Application is responsible for processing requests and managing the modules. The Module is responsible for handling all the operational logic. The TotalJS Flow project is a great tool for developing applications using flow based programming. When building larger applications where inter-module communication, multiphase processing, and scaling need to be taken into account it can be difficult to manage. This project provides a set of components to facilitate the building of larger applications using TotalJS Flow. Both the Application and the Module need to communicate with a redis server. Redis is used as the backend for how Application and Module instances communicate with each other. The Application component needs to communicate with a MongoDB server. The MongoDB server is primarily used to store details about the modules and their status. This is used so that the Application instances can be scaled out horizontally and keep in sync when it comes to processing.

Dependencies

  • TotalJS Flow
  • Redis Server
  • RethinkDB Server

Application Configuration

  • Application Name (Required: String)
  • Processing Mode (Required: String)
    • "Everything" (all) = Both input and API requests are processed
    • "Input" (input) = Only input requests are processed
    • "API" (api) = Only API requests are processed
  • Redis Connection (Required: String)
  • RethinkDB Connection (Required: String)

Application Bootstrapping

  • Application does sanity checks on the configuration
    • Check connection to MongoDB and Redis
  • Then application executes the "init" phase.
    • Initialize the Application Worker
    • Initialize the Module Manager
    • Create a new FlowMessage (with config as data) then send it to the "init" output and store message data on 'end' as Application Data (AppData)
  • Then application executes the "boot" phase.
    • Boot the Application Worker
    • Boot the Module Manager
    • Create a new FlowMessage then send it to the "boot" output with AppData and update message data on 'end' as AppData
  • Then application executes the "start" phase.
    • Start the Application Worker
    • Start the Module Manager
    • Create a new FlowMessage then send it to the "start" output with AppData and update message data on 'end' as AppData
  • Then application executes the "ready" phase.
    • Ready the Application Worker
    • Ready the Module Manager
    • Create a new FlowMessage then send it to the "ready" output with AppData and update message data on 'end' as AppData
    • Start the status monitor which sends status to UI at interval
  • The application is now ready to process requests.

Module Configuration

  • Label (Required: String)
  • Name (Required: String)
  • Application (Required: String)
  • Mode (Required: String)
    • "Everything" (all) = Both input and API requests are processed
    • "Input" (input) = Only input requests are processed
    • "API" (api) = Only API requests are processed
  • Redis Connection (Required: String)

Module Bootstrapping

  • Module does sanity checks on the configuration
    • Check connection to Redis
  • Then module connects to the application and registers itself.
    • Module sends a AppRegisterMessage to the application informing it of its existence.
    • Application responds with a AppRegisterResponse.
  • If AppRegisterResponse.success is true, then the module is registered.
    • Module executes the "init" phase.
      • Initialize the Module Worker
      • Create a new FlowMessage (with config as data) then send it to the "init" output and store message data on 'end' as Module Data (ModData)
    • Module executes the "boot" phase.
      • Boot the Module Worker
      • Create a new FlowMessage then send it to the "boot" output with ModData and update message data on 'end' as ModData
    • Module executes the "start" phase.
      • Start the Module Worker
      • Create a new FlowMessage then send it to the "start" output with ModData and update message data on 'end' as ModData
    • Module executes the "ready" phase.
      • Ready the Module Worker
      • Create a new FlowMessage then send it to the "ready" output with ModData and update message data on 'end' as ModData
      • Start the status monitor which sends status to UI at interval
      • Start heartbeat monitor which sends heartbeat to application at interval
  • If AppRegisterResponse.success is false, then the module is not registered.
    • Module is disabled.

Application Flow Architecture

  • Application Input (Input -> Phases -> Output)
    • Application Input is the entry point for the application which is the input labeled "input".
    • Application Input is then sent to the "phases" output with the result being an array of strings used for that inputs processing phases.
    • Application Input metadata is sent to each module requesting its involvement (phases and priority).
    • Application Input is processed by each module involved according to priority with the results becoming the updated Application Input.
    • Resulting Application Input is sent to "output" output for final processing.
  • Application Message (Message -> Application -> Response)
    • Application Message is the message that is sent to the application from a module.
    • Application Messages are sent to the application via the BullMQ job queue system.
    • AppRegisterMessage is sent to the application to register a module.
    • AppUnregisterMessage is sent to the application to unregister a module.
    • AppHeartbeatMessage is sent to the application to inform it that a module is still alive.
    • AppAPIMessage is sent to the application to execute an API call (Handled by "api" output. When the message ends the data is sent back as the result).
    • AppModuleMessage is sent to the application to execute a module API call.
    • Application Messages are sent to the "api" output with the result being sent back to the module as an AppMessageResponse.
  • Module Message (Module <-> Application <-> Module)
    • Module Message is the message that is sent to a module from the another module through the Application.
    • Module Messages are sent to the application via the BullMQ job queue system.
    • The application sends the message to the appropriate module for processing and the result is sent back to the requesting module.

Pre-requisites

Setup

Install

Install Application

  • Create a new TotalJS Flow.
  • Create a new component and containing the contents of Application Component.
  • Add the Application component under the "Application" group to the Flow.
  • Attach desired input and outputs to the Application component.
  • Configure Application component.

Install Module

  • Create a new TotalJS Flow.
  • Create a new component and containing the contents of Module Component.
  • Add the Module component under the "Module" group to the Flow.
  • Attach desired input and outputs to the Module component.
  • Configure Module component.

Messages

Application Messages

Theses are messages sent TO the application.

License

MIT License © Colton McInroy