GithubHelp home page GithubHelp logo

pemrouz / fero Goto Github PK

View Code? Open in Web Editor NEW
174.0 8.0 10.0 1.08 MB

light, fast, scalable, streaming microservices made easy

JavaScript 100.00%
microservices kafka stream-processing scalable fast lightweight stateful

fero's Issues

Peering Examples

Hello and thanks for your fantastic work on fero - Still trying to get around the correct peering options from the test examples - Would you have an example handy for using it in a scenario with remote peers/networks or feeding from DHT discovery, or anything with a fixed set of peers?

Need more thorough examples in the docs

I'm having a hard time trying to figure out how to use Fero on my own.

For example, I'm trying to build a simple distributed user login system:

// server1.js
const fero = require('fero')

const users = []

const register = req => {
  users.push(req.value)
  return [200, 'ok']
}

const login = req => {
  const { user, password } = req.value

  if (users.find(u => user === u.user && password === u.password )) {
    return [200, 'ok']
  }

  return [401, 'not authorized']
}

async function bs () {
  const users = await fero('users', async req =>
      req.type == 'LOGIN'    ? login(req)
    : req.type == 'REGISTER' ? register(req)
                             : [405, 'method not allowed'])

  users.on('change')
    .map(({ key, value }) => console.log(key, value))
}

bs()
  .then(() => console.log('ready 1'))
// server2.js
const fero = require('fero')

async function bs () {
  const users = await fero('users')

  console.log('PEERS:', users.peers)

  const data = await users.peers.send({
    type: 'REGISTER',
    key: 'foo',
    value: {
      user: 'foo',
      password: '1234'
    }
  })

  console.log('DATA:', data)
}

bs()
  .then(() => console.log('ready 2'))

However, nothing happens, even though the peers are connected.

I'm sure there's something wrong, but I'm currently not able to make this work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.