1.0.1 • Published 5 years ago

@avro/services v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Avro services

Avro-powered RPC services.

Features

  • Schema evolution
  • "Type safe" APIs
  • Efficient wire encoding

Examples

In-process client and server

const {Deadline, Server, Service} = require('@avro/services');

const stringService = new Service({
  protocol: 'StringService',
  messages: {
    upperCase: {
      request: [{name: 'message', type: 'string'}],
      response: 'string',
    },
  },
});

const stringServer = new Server(stringService)
  .onMessage().upperCase((str, cb) => { cb(null, str.toUpperCase()); });

const stringClient = stringServer.client(); // In-process client.

stringClient.emitMessage(Deadline.forMillis(100))
  .upperCase('hello!', (err, str) => {
    if (err) {
      throw err;
    }
    console.log(str); // HELLO!
  });

TCP server hosting two services

const {NettyGateway, RoutingChannel, Server, Service} = require('@avro/services');
const net = require('net');

const echoService = new Service({
  protocol: 'Echo',
  messages: {
    echo: {
      request: [{name: 'message', type: 'string'}],
      response: 'string',
    },
  },
});

const upperService = new Service({
  protocol: 'Upper',
  messages: {
    upper: {
      request: [{name: 'message', type: 'string'}],
      response: 'string',
    },
  },
});

const echoServer = new Server(echoService)
  .onMessage().echo((str, cb) => { cb(null, str); });

const upperServer = new Server(upperService)
  .onMessage().upper((str, cb) => { cb(null, str.toUpperCase()); });

const channel = RoutingChannel.forServers([echoServer, upperServer]);
const gateway = new NettyGateway(channel);

net.createServer()
  .on('connection', (conn) => {
    gateway.accept(conn.on('error', (err) => { console.error(err); }));
  })
  .listen(8080, () => { console.log('Listening...'); });
1.0.1

5 years ago

1.0.0

5 years ago

0.10.2

5 years ago

0.10.1

5 years ago

0.10.0

5 years ago

0.9.10

5 years ago

0.9.9

5 years ago

0.9.8

5 years ago

0.9.7

5 years ago

0.9.6

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.8

5 years ago

0.8.7

5 years ago

0.8.6

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.3

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.9

5 years ago

0.7.8

5 years ago

0.7.7

5 years ago

0.7.6

5 years ago

0.7.5

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.11

5 years ago

0.5.10

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

7 years ago