Git Product home page Git Product logo

vertx-engine's Introduction

Making Documents with Vert.X

Assemble a json document via a variety of steps, functions, and filters, using Vert.X and reactive programming.

Build status

build status Coverage Status

The basic idea

An input document provides a seed for a completed document. Our motivation for development is preparing search queries and indexing documents for search, but we see broader opportunities for the general system.

A pipeline provides a set of instructions for how to transform an input document into its final result. The Engine class is responsible for executing a pipeline. Pipelines consist of Sections and Steps. The Steps in a section will execute as soon as their prerequisites are ready.

The EnginePool manages a collection of pipelines that might do different things - for use in developing pipelines and/or organizing pipelines.

Writing a pipeline

See the abstract-step-test-pipeline.json for the basics. A pipeline consists of a tacit or declared outer section, which includes a list of steps. The steps are executed in the order they are ready (which may not be their order of appearance in the pipeline). Variables for each step are processed by the step, and they are evaluated through the Jinja template engine before use.

Steps carry out core functionality for construction of the document. Logically lighter weight activities may be carried out as fiilters and functions within the Jinja template engine. For example, a step would call out to a search engine, while a set of filters might manipulate a query string in preparation for it.

The step environment

When a step executes, AbstractStep assembles its environment with the variables provided in the "vars" block and some standard keys:

Key Explanation
doc The data initially provided and all values registered subsequently
system System variables (-D java options, environment variables, and config file values)

Values not in system and doc (vars), are evaluated with Jinja templating.

Jinjava provides a number of filters and functions.

Additional functions built in to this project are re:m(string, pattern) which returns the first match of the string, and re:s(string, pattern, replacement) which replaces all occurrences of pattern with replacement.

Filter reMatch(pattern) returns the first match of the pattern in the string piped in, and reSub(pattern,replacement) replaces all occurrences of pattern with replacement.

You can write your own steps, functions, and filters, too.

Writing a step

Extend AbstractStep (you could use the Step interface, but AbstractStep has a whole lot of basic functionality to it) and annotate your class with this:

import org.kohsuke.MetaInfServices;

@MetaInfServices(Step.class)

Writing a Jinja function

Implement JinjaFunctionDefinition and annotate your class with this:

import com.redhat.vertx.pipeline.templates.JinjaFunctionDefinition
import org.kohsuke.MetaInfServices;

@MetaInfServices(JinjaFunctionDefinition.class)

Annotate your public static methods with @ELFunction(value,namespace), where "value" is the name of the function and "namespace" will come before, like re:match("foobar","[fo]*"). Namespace may be left blank.

Writing a Jinja filter

Implement a Jinja Filter and annotate your class with this:

import com.hubspot.jinjava.lib.filter.Filter;
import org.kohsuke.MetaInfServices;

@MetaInfServices(Filter.class)

vertx-engine's People

Contributors

lightguard avatar ke4roh avatar

Watchers

James Cloos avatar  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.