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

@o3/service

v0.0.2

Published

The Node.js service library for Ozone (Node 8+)

Downloads

1

Readme

ozone-service

The Node.js service library for Ozone (Node 8+)

What is it

In principle, this package acts as an asynchronous wrapper for the Ozone package. It's goal is to provide the ability to modify and update it's instance based on external intents and state updates.

Learn more about Ozone

Installation

Before installing, make sure your system is qualified to use the Ozone subsystem by checking out the Ozone readme. In short, as long as you are running a modern Unix-like operating system or environment, Ozone should be able to run.

To use the ozone service package, install this as a dependency for your npm project

npm (latest)

npm i -S @o3/service

git (latest)

git clone https://github.com/flynnham/ozone-service.git

Usage

Pre-configure

Be sure to configure Ozone to recognize your service otherwise it won't be loaded.

Initialization

Assuming a live Ozone core instance is running, the first step to starting an Ozone service is to await the ozone service initializer.

Example

const ozoneService = require('@o3/service/init');

// Because we are using async we need to (unfortunately) wrap the context in order to use it
(async function(){
	// Let's attempt to start the service
	const service = await ozoneService();

	// now that the service is running, let's include the base state and intents
	const { state, intent } = require('@o3/service');

	// tell the core we are ready (needs to be ready before any intents are recieved)
	await state.ready();
})();

Full examples avaliable here

The above code will do the absolute minimum required to start a properly configured Ozone service. Once we know it's been configured we can start sending intents and working with the multi-instance state.

State

async state.ready()

Waits for the core to signal that services are now ready

state.addListener(name, callback(state))

Adds a listener to the core global context. Each listener should have a unique name so it can be remved when needed.

state.removeListener(name)

Removes a state listener by name

state.update(key, mutator function(currentState))

Updates the state specified by the key. Mutator is a function that must return a modified or new version of the old state. Key must exactly match the state attribute defined with the service configuration.

Intent

intent.send([ name, data || {} ],...)

Sends a list of intentions all with their own unique set of data. This arrives to the core as a bundle and are processed as such. Data must be of type Object

intent.addListener(intent, callback(data))

Listens for a properly configured intention and will run based on the code. In future versions, name will also be of type Array, allowing for multiple listeners.