@jjordy/service
A library for initializing a service oriented architecture
Last updated 7 months ago by jjordy .
MIT · Original npm · Tarball · package.json
$ cnpm install @jjordy/service 
SYNC missed versions from official npm registry.

@jjordy/Service


Basic Service

import Service, { Plugin, SentryPlugin, StatsDPlugin, DebugPlugin } from '@jjordy/service'

class CustomService extends Plugin {
  constructor() {
    super('CustomService')
  }
  public register () {
    this.doSomethingCool()
  }
  public async init () {
    // initialize your plugin
  }
  private doSomethingCool () {
    console.log('Do Something Cool')
  }
}

async function go() {
  try {
    const service = new Service()
    await service.registerPlugin<StatsDPlugin>('StatsDPlugin', new StatsDPlugin())
    await service.registerPlugin<SentryPlugin>('SentryPlugin', new SentryPlugin())
    await service.registerPlugin<DebugPlugin>(
      'DebugPlugin', new DebugPlugin({ name: 'My Custom service' }))
    await service.init()
    // provided by SentryPlugin
    service.logEvent('HEY THERE')
    service.logMessage('HEY THERE')
    service.logException('HEY THERE')
    // provided by DebugPlugin
    service.log("test")
    // provided by StatsDPlugin
    service.stats.increment('service.test.increments', 20)
    process.exit(0)
  } catch (err) {
    console.log('Uh oh something went wrong intializing the service', err)
  }
}

go()

Current Tags

  • 0.0.1                                ...           latest (7 months ago)

1 Versions

  • 0.0.1                                ...           7 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |