https://github.com/bigeasy/conference
Framework communicating using a Compassion atomic log.
https://github.com/bigeasy/conference
consensus nodejs paxos
Last synced: about 1 month ago
JSON representation
Framework communicating using a Compassion atomic log.
- Host: GitHub
- URL: https://github.com/bigeasy/conference
- Owner: bigeasy
- License: mit
- Created: 2016-06-30T13:45:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-26T06:34:52.000Z (about 3 years ago)
- Last Synced: 2025-03-02T12:19:39.926Z (about 2 months ago)
- Topics: consensus, nodejs, paxos
- Language: JavaScript
- Homepage: https://bigeasy.github.io/conference/
- Size: 465 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/bigeasy/conference/actions)
[](https://codecov.io/gh/bigeasy/conference)
[](https://opensource.org/licenses/MIT)Reduce messages from an atomic log.
| What | Where |
| --- | --- |
| Discussion | https://github.com/bigeasy/conference/issues/1 |
| Documentation | https://bigeasy.github.io/conference |
| Source | https://github.com/bigeasy/conference |
| Issues | https://github.com/bigeasy/conference/issues |
| CI | https://travis-ci.org/bigeasy/conference |
| Coverage: | https://codecov.io/gh/bigeasy/conference |
| License: | MIT |Ascension installs from NPM.
```
npm install conference
```## Living `README.md`
This `README.md` is also a unit test using the
[Proof](https://github.com/bigeasy/proof) unit test framework. We'll use the
Proof `okay` function to assert out statements in the readme. A Proof unit test
generally looks like this.```javascript
require('proof')(4, okay => {
okay('always okay')
okay(true, 'okay if true')
okay(1, 1, 'okay if equal')
okay({ value: 1 }, { value: 1 }, 'okay if deep strict equal')
})
```You can run this unit test yourself to see the output from the various
code sections of the readme.```text
git clone [email protected]:bigeasy/conference.git
cd conference
npm install --no-package-lock --no-save
node test/readme.t.js
```## Overview
Require.
```javascript
const Conference = require('conference')
```Construct.
```javascript
const conference = new Conference
```Arrive.
```javascript
conference.arrive('1/0')
```Map.
```javascript
conference.map('x', { call: 1 })
```Reduce.
```javascript
const reduction = conference.reduce('x', '1/0', { response: 1 })
okay(reduction, [{
key: 'x',
map: { call: 1 },
reduce: { '1/0': { response: 1 } }
}], 'reduced')
```More meaningful if you can imagine multiple participants. You track each
arrival.```javascript
conference.arrive('2/0')
conference.arrive('3/0')
```Map is called once.
```javascript
conference.map('x', { call: 1 })
```Reduce is called once for each member.
```javascript
okay(conference.reduce('x', '1/0', { reduce: 1 }), [], 'only one of three responses')
okay(conference.reduce('x', '3/0', { reduce: 1 }), [], 'two of three responses')
const reduction = conference.reduce('x', '2/0', { reduce: 1 })
okay(reduction, [{
key: 'x',
map: { call: 1 },
reduce: {
'1/0': { reduce: 1 },
'2/0': { reduce: 1 },
'3/0': { reduce: 1 }
}
}], 'all responses')
```Convert ot array.
```javascript
okay(Conference.toArray(reduction[0]), [{
promise: '1/0', value: { reduce: 1 },
}, {
promise: '3/0', value: { reduce: 1 },
}, {
promise: '2/0', value: { reduce: 1 }
}], 'to array')
```Makes it easier to perform reduce-like actions with JavaScript array functions.
```javascript
const sum = Conference.toArray(reduction[0])
.map(reduced => reduced.value.reduce)
.reduce((sum, value) => sum + value, 0)
okay(sum, 3, 'summed')
``````javascript
conference.map('x', { call: 1 })
conference.map('y', { call: 2 })
``````javascript
conference.reduce('x', '1/0', { response: 1 })
conference.reduce('x', '3/0', { response: 1 })
conference.reduce('y', '1/0', { response: 2 })
conference.reduce('y', '3/0', { response: 2 })
``````javascript
const reduction = conference.depart('2/0')
okay(reduction, [{
key: 'x',
map: { call: 1 },
reduce: { '1/0': { response: 1 }, '3/0': { response: 1 } }
}, {
key: 'y',
map: { call: 2 },
reduce: { '1/0': { response: 2 }, '3/0': { response: 2 } }
}], 'reductions upon depart')
```