Code Monkey home page Code Monkey logo

test_tremor's Introduction

Passthrough

The passthrough example is the simplest possible configuration of thremor. It shows the very basic building blocks: Onramp, Offramp, Binding, Mapping and Pipeline.

Environment

The onramp we use is a websocket onramp listening on port 4242, it receives JSON formatted messages.

onramp:
  - id: input          # A unique id for binding/mapping
    type: ws              # The unique type descriptor for the onramp ( websocket server here)
    codec: json           # The underlying data format expected for application payload data
    config:
      port: 4242          # The TCP port to listen on
      host: '0.0.0.0'     # The IP address to bind on ( all interfaces in this case )

It connects to the pipeline example in the example.trickle file using the trickle query language to express its logic.

The offramp we used is a console offramp producing to standard output. It receives JSON formatted messages.

offramp:
  - id: stdout-output     # The unique id for binding/mapping
    type: stdout          # The unique type descriptor for the offramp ( stdout here )
    codec: json           # The underlying data format expected for application payload data
    config:
      prefix: '>> '       # A prefix for data emitted on standard output by this offramp

The binding expresses those relations and gives the graph of onramp, pipeline and offramp.

binding:
  - id: passthrough                                 # The unique name of this binding template
    links:
      '/onramp/input/{instance}/out':            # Connect the inpunt to the pipeline
       - '/pipeline/example/{instance}/in'
      '/pipeline/example/{instance}/out':           # Connect the pipeline to the output
       - '/offramp/stdout-output/{instance}/in'

Finally the mapping instanciates the binding with the given name and instance variable to activate the elements of the binding.

Business Logic

select event from in into out

Command line testing during logic development

Execute a the passthrough query against a sample input.json

$ tremor-query -e input.json example.trickle
>> {"hello": "world"}

Deploy the solution into a docker environment

$ docker-compose up
>> {"hello": "world", "selected": false}
>> {"hello": "again", "selected": true}

Inject test messages via websocat

Note: Can be installed via cargo install websocat for the lazy/impatient amongst us

$ cat inputs.txt | websocat ws://localhost:4242
...

test_tremor's People

Contributors

0xdeafbeef avatar ernadh 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.