Comparing version 5.0.0-rc.11 to 5.0.0-rc.12
{ | ||
"name": "avsc", | ||
"version": "5.0.0-rc.11", | ||
"version": "5.0.0-rc.12", | ||
"description": "Avro for JavaScript", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/mtth/avsc", |
@@ -69,2 +69,3 @@ # Avsc [![NPM version](https://img.shields.io/npm/v/avsc.svg)](https://www.npmjs.com/package/avsc) [![Download count](https://img.shields.io/npm/dm/avsc.svg)](https://www.npmjs.com/package/avsc) [![Build status](https://travis-ci.org/mtth/avsc.svg?branch=master)](https://travis-ci.org/mtth/avsc) [![Coverage status](https://coveralls.io/repos/mtth/avsc/badge.svg?branch=master&service=github)](https://coveralls.io/github/mtth/avsc?branch=master) | ||
}); | ||
// We can use `type` to encode any values with the same structure: | ||
const bufs = [ | ||
@@ -88,13 +89,17 @@ type.toBuffer({city: 'Seattle', zipCodes: ['98101'], visits: 3}), | ||
```javascript | ||
// First assemble the schema from the IDL specification. | ||
avro.assembleProtocolSchema('Ping.avdl', (err, schema) => { | ||
// Then create a server, attaching a handler for `ping` messages. | ||
const server = avro.Protocol.forSchema(schema) | ||
.createServer() | ||
.onPing((cb) => { cb(null, 'pong'); }); | ||
// Finally, respond to incoming TCP connections. | ||
require('net').createServer() | ||
.on('connection', (con) => { server.createListener(con); }) | ||
.listen(8000); | ||
}); | ||
// We first assemble a protocol from its IDL specification. | ||
const protocol = avro.readProtocol(` | ||
protocol LengthService { | ||
/** Endpoint which returns the length of the input string. */ | ||
int stringLength(string str); | ||
} | ||
`); | ||
// We then create a corresponding server, implementing our endpoint. | ||
const server = avro.Service.forProtocol(protocol) | ||
.createServer() | ||
.onStringLength(function (str, cb) { cb(null, str.length); }); | ||
// Finally, we use our server to respond to incoming TCP connections! | ||
require('net').createServer() | ||
.on('connection', (con) => { server.createChannel(con); }) | ||
.listen(24950); | ||
``` | ||
@@ -101,0 +106,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231275
7342
119