Code Monkey home page Code Monkey logo

akka-dynamic-sources-poc's Introduction

akka-dynamic-sources-poc

POC of managing a graph where the number of sources is varying, and sources can move from graph to graph

Demonstration

Consider the following state:

flowchart TD
    Entity1 --> Source1
    Entity1 --> Source2
    Entity2 --> Source3
Loading

We want to be able to move Source2 from Entity1 to Entity2, like so:

flowchart TD
    Entity1 --> Source1
    Entity2 --> Source2
    Entity2 --> Source3
Loading

To achieve that, we'll use the following structure of actors:

flowchart
    subgraph Pauseable Source 1
        Source1 --> Valve1 -- KillSwitch1 --> BroadcastHub1
    end

    subgraph Pauseable Source 2
        Source2 --> Valve2 -- KillSwitch2 --> BroadcastHub2
    end

    subgraph Pauseable Source 3
        Source3 --> Valve3 -- KillSwitch3 --> BroadcastHub3
    end
    
    BroadcastHub1 -- BCH_KillSwitch1 --> MergeHub
    BroadcastHub2 -- BCH_KillSwitch2 --> MergeHub
    BroadcastHub3 -- BCH_KillSwitch3 --> MergeHub

    MergeHub --> ProcessorStage

    ProcessorStage --> OutputSink[Output Sink]
Loading

Explanation

"Pauseable Source" components

  • Source: is the actual source of data. Can be Source.range(), an AmpqSource.committableSource, or otherwise
  • Valve: allows easy pause-and-resume on sources, for example, when you move the source from one graph to another, so that you'd be able to resume from the same place when you open the valve again.
  • [KillSwitch]: this is for when you actually want to kill the origin source, when you don't want it's data anymore.
  • [BroadcastHub]: Although allows for 0-N consumers, we use it for 0-1, as it plays as a consumer (pulling from the source) while it is disconnected from a graph, and then you can re-attach the BroadcastHub to another graph.

Rest of the graph

  • [MergeHub]: allows for variable amount of producers, which is important when you want to move producers from a graph to another
  • [BCH_KillSwitch]: it's a KillSwitch between the BroadcastHub and the MergeHub, and it is how you "disconnect" the PauseableSource from a graph.

The rest of the components are up to the implementation, in our case we have a GraphStage that processes the input from all the sources, and outputs to a Sink which writes to Kafka.

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.