2.0.0 • Published 4 years ago

diesis-electrician v2.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

diesis-electrician

This is an adapter for using electrician components with Diesis.

How it works

You import the adapter like this:

const diesisElectrician = require('diesis-electrician')

Then you pass a map of electric components:

const deps = diesisElectrician(components)

You get back an object with startAll/stopAll methods:

const deps = diesisElectrician({
  config: new Conflab(),
  endpoints: new Endpoints(),
  metrics: new ElectricMetrics(),
  refdata: new Refdata(),
  server: new Server(),
})

deps.startAll() // ... starts all components
  .then(obj => {
    // obj is a map with all components
  })

deps.stopAll() // ... stops all components
  .then(() => {
  })

Every dependency not declared in the components is intended as additional argument that can be sent in the startAll/stopAll method:

deps.startAll({ value: 5 })

startAll/stopAll are convenience methods build on top of run:

run([config, endpoints, metrics, refdata, server], { value: 5 })

deps contains also 2 registries (startRegistry and stopRegistry) with all dependencies that you can export and use:

const getConfig = deps.startRegistry.config
const getRefdata = deps.startRegistry.refdata

const { dependency } = require('diesis')
const doSomething = dependency([getConfig, getRefdata], (config, refdata) => {
  // ...
})

If you want get the same API of electrician you can call getSystem:

const system = deps.getSystem(obj) // you inject some argument if required

system.start((err) => {
  // ...
})

system.stop((err) => {
  // ...
})
2.0.0

4 years ago

1.1.4

4 years ago

1.1.3

5 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago