New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

braker-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

braker-client

An client with circuit.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

cloud-client

Usage

ResourceClient

import CloudClient from 'cloud-client';

import * as resourceInterface from './ResourceInterface';

const SERVICE_NAME = 'a-service';
const cClient = new CloudClient(SERVICE_NAME, resourceInterface);

//set health check.
cClient.setHealthCheck(resourceInterface.checkHealth);

//register http request api.
export default cClient.registerApi();

ResourceInterface

import rp from 'request-promise';

/**
 * Check the service's health status.
 */
export function checkHealth() {
    return rp({
        method: 'get',
        url: `/${SERVICE_NAME}/health`,
        headers: {
            'Content-Type': 'application/json'
        }
    });
}

export function getResource(id) {
    return rp({
        method: 'get',
        url: `/${SERVICE_NAME}/v1/resources/:id`,
        params: {id: id},
        headers: {
            'Content-Type': 'application/json'
        }
    });
}

You can use cloud client to invoke resource interface's function. example is

import resourceClient from './ResourceClient';

resourceClient.getResource(id);

API

new CloudClient(serviceName, interface, options)

serviceName

The service name.

interface

The key-value object for sending request.

options
  • logger: Default is console. you can use any other logger that implements logger.log function.
  • Other options param is the same as brakes

cClient.setHealthCheck(callback)

Set a callback, when the circuit is open, the callback will be used for checking the service's health status, if the status is ok, the circuit will close.

cClient.registerApi()

return cClient.registerApi();

Keywords

FAQs

Package last updated on 25 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc