
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
brake-client
Advanced tools
import BrakeClient from 'brake-client';
import rp from 'request-promise';
const SERVICE_NAME = 'a-service';
const brake = new BrakeClient(SERVICE_NAME);
//set health check.
brake.healthCheck(() => {
return rp({
method: 'get',
url: `/${SERVICE_NAME}/health`,
headers: {
'Content-Type': 'application/json'
}
});
});
brake.on('circuitOpen', () => {
logger.warn(`The service: ${SERVICE_NAME}'s circuit is opened.`);
});
brake.on('circuitClosed', () => {
logger.info(`The service: ${SERVICE_NAME}'s circuit is closed.`);
});
brake.fallback(err => {
throw new Error('Cannot invoke downstream service. please try again soon.', err);
});
export function getResource(id) {
const request = {
method: 'get',
url: `/${SERVICE_NAME}/v1/resources/:id`,
params: {id: id},
headers: {
'Content-Type': 'application/json'
}
};
return brake.circuit({send: rp}).send(request);
}
You can use brake client to invoke resource api. The example is
import resourceClient from './ResourceClient';
resourceClient.getResource(id).then(resource => {
console.log(resource);
})
The service name.
The options param is the same as brakes. We extend it, and support request handlers
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.
See brakes for detail.
Return the circuit's status.
FAQs
An client with circuit.
The npm package brake-client receives a total of 2 weekly downloads. As such, brake-client popularity was classified as not popular.
We found that brake-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.