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

@service-broker/service-broker-client

v2.1.0

Published

Client library for interacting with a service broker

Downloads

13

Readme

service-broker-client

Client library for interacting with a service broker

Connect

const sb = new ServiceBroker("ws://sb.mydomain.com:8080", logger)

Advertise

sb.advertise(
  service: {name: string, capabilities?: string[], priority?: number},
  handler: (req: Message) => Message|Promise<Message>
)

A service provider calls this method to advertise to the broker the service(s) it provides. For explanation of parameters, see service broker.

Request

sb.request(
  service: {name: string, capabilities?: string[]},
  req: Message,
  timeout?: number
)
: Promise<Message>

A client calls this method to request some service. The broker will select a qualified provider based on service name and capabilities. The parameter req contains the actual message that'll be delivered to the service provider (see handler in Advertise). The returned promise contains the response from the provider.

RequestTo

sb.requestTo(
  endpointId: string,
  serviceName: string,
  req: Message,
  timeout?: number
)
: Promise<Message>

Send a request directly to an endpoint.

Notify

sb.notify(
  service: {name: string, capabilities?: string[]},
  msg: Message
)

A notification is a request without an id, and thus no response will be generated. Use a notification when you don't care about the result.

NotifyTo

sb.notifyTo(
  endpointId: string,
  serviceName: string,
  msg: Message
)

Send a notification directly to an endpoint.

Publish/Subscribe

sb.publish(
  topic: string,
  text: string
)

sb.subscribe(
  topic: string,
  handler: (text: string) => void
)

SetServiceHandler

sb.setServiceHandler(
  serviceName: string,
  handler: (req: Message) => Message|Promise<Message>
)

This installs a handler for a particular service without advertising the it to the broker. This is for when the client knows the provider's endpointId and can send the request directly to it (see RequestTo).

Status

sb.status(): Promise<any>

Returns the service broker's status, which includes the list of services and service providers currently active.

WaitEndpoint

sb.waitEndpoint(endpointId: string): Promise<void>

Returns a promise that resolves when the specified endpoint disconnects.

Shutdown

sb.shutdown()

Close the connection to the service broker.