twilson63 / palmettoflow

MIT License
14 stars 2 forks source link

Palmetto Flow Service Containers and Services #9

Open twilson63 opened 9 years ago

twilson63 commented 9 years ago

What is a Palmetto Flow Service?

A Palmetto Flow Service is a code library that does specific functionality and receives its input by subscribing to a pub/sub system by using a palmettoflow-adapter - the adapters use the same api as an EventEmitter in NodeJS and the same Event Structure, { to, from, object, ...} - By building your services to take in configuration and keeping the services simple, you can combine the services with other services using service containers.

What is a service container?

A service container is an application that manages the configuration info, adapter, health check and initializes your services for action. By using service containers you can combine collections of services for the same adapter and share configurations.

After building a few service containers, I have built a npm module palmettoflow-service-container it is an opinionated service container library to be used for services that follow the same initialization pattern:

module.exports = function (config) {
  return function  (ee) {
    ...
  }
}

By following this pattern you can quickly create service containers by using this module:

var fetchConfig = require('zero-config')
var config = fetchConfig(__dirname, { dcValue: 'us-east-1'})
var sc = require('palmettoflow-service-container')
sc(config, [
  'service1',
  'service2',
  'service3'
])

see https://github.com/twilson63/palmettoflow-svc-container