RemoteServiceManager

ServiceSDK

ServiceSDK constructor

Type:
function
new RemoteServiceManager(services)

A factory for ServiceSDK instances (see affiliated serviser-sdk plugin) and SDKs integration

Parameters:
  • services
    • Type: Object
      • <serviceName>
        • Type: Object
        • index name = name of the service

          • <scope>
            • Type: Object
            • index name not constrained, could be anything... eg.: specific service application name (in case multiple applications are listening under one service) or access level type eg.: "public" or "s2s"

              • npm
                • Type: String
                • npm sdk package name which exports a literal object of versioned ServiceSDKs. (use either dir or `npm option)

              • dir
                • Type: String
                • sdk package directory path which exports object that inherits ServiceSDK. (use either dir or `npm option)

              • host
                • Type: String
              • protocol
                • Type: Boolean
add(key, sdk)RemoteServiceManager

registers ServiceSDK instance

Parameters:
  • key
    • Type: String
    • format <serviceName>:<scope>

  • sdk
    • Type: ServiceSDK
Returns: RemoteServiceManager
  • self
buildRemoteService(key, options)ServiceSDK

constructs specific ServiceSDK from configuration provided to the constructor
the specific ServiceSDK is supposed to be auto generated by serviser-sdk plugin and published as a npm package

Parameters:
  • key
    • Type: String
    • format: <serviceName>:<scope>:<version>

  • options optional
    • Type: Object
    • ServiceSDK constructor options

Throws:
  • Error
Returns: ServiceSDK
Example:
//config.js:
module.exports = {
   services: {
      user: {
        public: {
          protocol: 'https',
          host: "127.0.0.1:4001",
          npm: "service-name-app-name-sdk"
        }
      }
   }
}

or

module.exports = {
   services: {
      user: {
        public: {
          protocol: 'https',
          host: "127.0.0.1:4001",
          dir: "/absolute/path/to/my/sdk/directory"
        }
      }
   }
}

//method usage
remoteServiceManager.buildRemoteService('user:public:v1.0');
get(key)ServiceSDK
Parameters:
  • key
    • Type: String
    • format <serviceName>:<scope>:<version>

Returns: ServiceSDK
has(key)Boolean
Parameters:
  • key
    • Type: String
    • format <serviceName>:<scope>:<version> (scope|version key segments are optional)

Returns: Boolean
comments powered by Disqus