ResourceManager

new ResourceManager()

A Resource can be any object that implements inspectIntegrity method which must return a Promise.

add(key, resource)Object
Parameters:
  • key
    • Type: String
  • resource
    • Type: Object
Returns: Object resource object
get(key)Object
Parameters:
Returns: Object resource object
has(key)Boolean
Parameters:
Returns: Boolean
inspectIntegrity(tag, options)Promise

inspects integrity of a group of registered resources.
Groups are recognized via resource tags. if no group is provided, all resources will be inspected.
This method operates in two modes include/exclude - where include mode inspects a provided resource group (tag) as opposed to exclude which inspects all resources which are NOT assigned provided tag.

Parameters:
  • tag optional
    • Type: String
    • Default: '*'
    • identifies a span of resources which will be inspected

  • options optional
    • Type: Object
      • mode optional
        • Type: String
        • Default: 'include'
        • include | exclude

Returns: Promise
Example:
resourceManager.register('mysql', mysqlAdapter);
resourceManager.register('postgres', postgresAdapter);
resourceManager.register('rabbit', amqpAdapter);

resourceManager.tag('postgres', 'database');
resourceManager.tag('mysql', 'database');

return resourceManager.inspectIntegrity('database'); //inspects only mysql & postgres
register(key, resource)Object

The resource is given default tag which is equal to the resource key.

Parameters:
  • key
    • Type: String
    • resource identifier

  • resource
    • Type: Object
Throws:
  • TypeError
Returns: Object
  • resource object
remove(key)Object or undefined
Parameters:
Returns: Object or undefined removed resource object or undefined when nothing was removed
tag(key, tag)undefined

assigns tag(s) to a resource. Tags meet the role of groups of resources.
You can use a tag instead of a resource key to identify and target a span of resources.

Parameters:
  • tag repeatable
    • Type: String
Returns: undefined
comments powered by Disqus