Giter Club home page Giter Club logo

stepflow_source_swagger's Introduction

stepflow_source_swagger

Application that implement REST, Websocket and TCP API endpoints as source for steflow.

Example

          +------------------------------------------------------------------+
          |                              Agent 1                             |
User      |                                                                  |
 |        |     Source <---------------> Channel <--------> Sink             |
 +------->| (tcp, REST, Websocket)     (rabbitmq)       (echo on console)    |
   POST   |                                                                  |
   Events +------------------------------------------------------------------+
 [<<"hello">>]
$ rebar3 shell --sname pippo --apps stepflow_source_swagger

1> SrcCtx = {[{stepflow_interceptor_counter, #{header => mycounter}}, {stepflow_interceptor_echo, #{}}], #{}}.
2> Input = {stepflow_source_swagger_source, SrcCtx}.
3> {ok, SkCtx2} = stepflow_sink:config(stepflow_sink_echo, #{}, [{stepflow_interceptor_echo, #{}}]).
4> ChCtx2 = {stepflow_channel_rabbitmq, #{}, SkCtx2}.
5> Output = [ChCtx2].
6> {PidSub, PidS, PidC} = stepflow_agent_sup:new(Input, Output).

Append a new event via REST

$ echo '[{"body": "hello"}]' |  http POST http://0.0.0.0:8080/api/events

Append a new event via TCP socket

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('0.0.0.0', 12345))
s.send('{"path": "/events", "method": "post", "events": [{"body": "hello"}]}')

Append a new event via Websocket

$ open ws://0.0.0.0:8080/websocket

Send `{"path": "/events", "method": "post", "events": [{"body": "hello"}]}`
Receive `{"context":{},"result":"ok"}`

Note

You can run rabbitmq with docker:

$ docker run --rm --hostname my-rabbit --name some-rabbit -p 5672:5672 -p 15672:15672 rabbitmq:3-management

And open the web interface:

$ firefox http://0.0.0.0:15672/#/

stepflow_source_swagger's People

Watchers

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