xen-service

Simple and flexible microservice library. Features:

Usage no npm install needed!

<script type="module">
  import xenService from 'https://cdn.skypack.dev/xen-service';
</script>

README

Xen Service

Simple and flexible microservice library. Features:

  • declarative constructor syntax
  • action/dispatch-based internal RPC (inspired by Flux)
  • functional to the core
  • build services with RxJS 5, Promises, or blocking code
  • TODO wrap dispatch in middleware, or override it completely
  • TODO external RPC helper for Docker Swarm mode service discovery
  • TODO trace dispatches across multiple nested procedure calls

WIP Creating a Service

XenServer.createService accepts a service config object and returns an Observable.

const XenService = require('xen-service');

// Configure your new service
XenService.createService({
  name: 'MyService',
  procedures: {
    test: () => 'Prepare for unforeseen consequences'
  }
})
// Create the service by subscribing to it
.subscribe(service => {
  // Once the service is ready, invoke the "test" procedure by
  // dispatching an action of the same type
  service.dispatch({
    type: 'test'
  })
  .subscribe(response => {
    console.log(service); // 'Prepare for unforeseen consequences'
  });
})