Coder Social home page Coder Social logo

phobosjs-mock's Introduction

phobosjs-mock

Some simple ideas in code how we could be using phobos in practice.

The core ideas are

  • No multiprocessing, keep it simple.
    • No need to farm out resources on each node, assume micro instances
    • This alone should greatly reduce complexity of the Phobos code and make it easier to understand/contribute
    • Instead, scale horizontally
    • One service instance <=> one consumer <=> one configuration
  • Avoid meta programming and implicit contracts between users' services and phobos
    • The user is in control
    • The code written in services should be simple and readable, even if you don't know kafka (or even phobos!) you should still be able to understand
  • Move as much config as possible to .phobosjs
  • Require as little config as possible inside the users' services, if any.
  • Consider possibility of support such as

phobosjs-mock's People

Contributors

klippx avatar

Watchers

 avatar  avatar

phobosjs-mock's Issues

Some ideas

app.on('messageReceived', (message) => {

It should use async functions for the messageReceived so it allows users to fetch data from external APIs or query databases, etc

app.on('messageReceived', async (message) => {
  const decodedMessage = avro.fromBuffer(message)
  const statement = createStatement(decodedMessage.data())
})

Maybe we should drop the event syntax altogether and go directly to functions, like:

app.onMessage(async (message, metadata) => {
  // metadata => { retryCount, retryTime, etc }
  const decodedMessage = avro.fromBuffer(message)
  const statement = createStatement(decodedMessage.data())
})

Maybe some hooks for errors so the app developer can track/measure the errors

app.onError(async error => {})

beforeConsume: (payload) => {

I would use keySerializer and valueSerializer instead of before* and have them as async functions.

const app = createConsumer({
  topic: 'statement_available',
  keySerializer: async key => key.toString(),
  valueSerializer: async value => await avro.fromBuffer(value)
})

Last comments. This library could use a .phobojs javascript file instead of JSON. The js file can have comments and support interpolation, etc.

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.