get-safe-instance
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Actions Status Actions Status Actions Status Test Coverage Maintainability Packages npm version

Am pbkect wrapper to make its operations error proof. Basically, any error is ignored. You can have a callback when an error happens, for registering purpose, bue during the application use, every error will be ignored and undefined will be returned instead.

How to Install

npm i get-safe-instance

How to use it

Just wrap your redis instance and use the wrapped one

const wrappedRedis = getSafeInstance(someRedisInstance, timeout, ['get', 'getBuffer'], myErrorCallback)

Now, the wrapped instance will never throw an error during get or getBuffer calls, instead, it will resolve to undefined. See that only methods that return promises can be wrapped like that, as, under the hood, we also use opossum to have a circuit breaker on the given methods, avoiding some calls if constants errors are happening. Finally, the given methods will also return undefined if they reach the specified timeout without returning anything.

License

Licensed under MIT.

Dependencies (0)

    Dev Dependencies (27)

    Package Sidebar

    Install

    npm i get-safe-instance

    Weekly Downloads

    30

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    10.8 kB

    Total Files

    11

    Last publish

    Collaborators

    • farenheith