Coder Social home page Coder Social logo

reactor's Introduction

Reactor

An extension for Speedment that make it possible to react to changes in a database and creating Materialized Object Views.

How it works

The extension consists of two classes. The Reactor polls the database at a regular interval, downloading modifications to one specific table in batches. The changes are then parsed so that a set of listeners can act on them. The second class is the MaterializedView class. It can act as a listener on a Reactor, merging the changes into one materialized view. That view can then be queried to get a current state of the database without causing additional statements to be sent.

Installation

To add reactivity to your Speedment project, simply add the following dependency to your pom.xml-file:

<dependency>
    <groupId>com.github.pyknic</groupId>
    <artifactId>reactor</artifactId>
    <version>1.0.1</version>
</dependency>

Usage

To set up a materialized view of a table article_event, do the following once (after initiating Speedment):

final MaterializedView<ArticleEvent> articlesView 
    = new MaterializedView<>(ArticleEvent.ARTICLE_ID);

final Reactor<ArticleEvent> reactor = 
    Reactor.builder(speedment.managerOf(ArticleEvent.class), ArticleEvent.ARTICLE_ID)
        .withListener(articlesView)
        .build(); // Automatically starts the reactor

A materialized view must always have a particular field that events should be merged on. This is different than the primary key. Rows that have the same value of this field, in this case ARTICLE_ID, will be considered the same entity and will be merged in the view.

License

This project is made available under the Apache 2 license.

reactor's People

Stargazers

 avatar

Watchers

James Cloos avatar Emil Forslund avatar

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.