Skip to content

Commit

Permalink
Merge pull request #17 from linkall-labs/dev
Browse files Browse the repository at this point in the history
docs: update sink-http README
  • Loading branch information
JieDing committed Jun 14, 2022
2 parents 6cab092 + d9e8fb3 commit 91a3d71
Showing 1 changed file with 35 additions and 42 deletions.
77 changes: 35 additions & 42 deletions connectors/sink-http/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
# HTTP-Sink
# HTTP Sink

## Overview

An HTTP-Source which transforms HTTP requests to CloudEvents and deliver them to the target URI.

A [Vance Connector][vc] which receives CloudEvents and deliver specific data to the target URL.
## User guidelines

### Connector introduction

This HTTP-Source is a [Vance Connector][vc] which aims to wrap incoming HTTP requests in a way that wrapping all headers and body of the
original request into the `data` field of a new CloudEvent.
The HTTP Sink is a [Vance Connector][vc] which aims to handle incoming CloudEvents in a way that extracts the `data` part of the
original event and deliver these extracted `data` to the target URL.

For example, if an original request looks like:
For example, if the incoming CloudEvent looks like:

```http
> POST /payload HTTP/2
> Host: localhost:8080
> User-Agent: VanceCDK-HttpClient/1.0.0
> Content-Type: application/json
> Content-Length: 39
> {
> "myData" : "simulation event data <1>"
> }
```

This POST HTTP request will be transformed into a CloudEvent looks like:

``` json
{
"id" : "42d5b039-daef-4071-8584-e61df8fc1354",
"source" : "vance-http-source",
Expand All @@ -37,33 +21,38 @@ This POST HTTP request will be transformed into a CloudEvent looks like:
"datacontenttype" : "application/json",
"time" : "2022-05-17T18:44:02.681+08:00",
"data" : {
"headers" : {
"user-agent" : "VanceCDK-HttpClient/1.0.0",
"content-type" : "application/json",
"content-length" : "39",
"host" : "localhost:8080"
},
"body" : {
"myData" : "simulation event data <1>"
}
"myData" : "simulation event data <1>"
}
}
```

**Users of this connector are supposed to transform any HTTP requests into CloudEvents.**
The HTTP Sink will POST an HTTP request looks like:

## Specify user configs
``` json
> POST /payload HTTP/2

> Host: localhost:8080
> User-Agent: VanceCDK-HttpClient/1.0.0
> Content-Type: application/json
> Content-Length: 39

> {
> "myData" : "simulation event data <1>"
> }
```

## Vance Connector Configs

Users can specify their configs by either setting environments variables or mount a config.json to
`/vance/config/config.json` when they run the container.
`/vance/config/config.json` when they run the connector.

### Set environments variables for HTTP-Source
### Set environments variables for HTTP Sink

```
//use V_TARGET to specify the target URI HTTP-Source will send CloudEvents to
//use V_TARGET to specify the target URI HTTP Sink will send CloudEvents to
--env "V_TARGET"="http://localhost:8081"
//use V_PORT to specify the port HTTP-Source is listening on
//use V_PORT to specify the port HTTP Sink is listening on
--env "V_PORT"="8080"
```

Expand All @@ -73,8 +62,8 @@ Users can specify their configs by either setting environments variables or moun

```json
{
//use V_TARGET to specify the target URI HTTP-Source will send CloudEvents to.
//use V_PORT to specify the port HTTP-Source is listening on.
//use V_TARGET to specify the target URI HTTP Sink will send CloudEvents to.
//use V_PORT to specify the port HTTP Sink is listening on.
//JSON standard does not allow comments. Remember to delete these comments when you copy configs.
"v_target": "http://localhost:8081",
"v_port": "8080"
Expand All @@ -83,21 +72,25 @@ Users can specify their configs by either setting environments variables or moun

⚠️ **NOTE: json keys MUST be lowercase** ⚠️

## Run HTTP-Source image
## HTTP Source Image

> docker.io/vancehub/sink-http
## Local Development

## Local development
You can run the source codes of the HTTP Source locally as well.

### Building via Maven

```shell
$ cd source-http
$ cd sink-http
$ mvn clean package
```

### Running via Maven

```shell
$ mvn exec:java -Dexec.mainClass="com.linkall.source.mysql.Entrance"
$ mvn exec:java -Dexec.mainClass="com.linkall.sink.http.Entrance"
```

[vc]: https://github.com/JieDing/vance-docs/blob/main/docs/concept.md

0 comments on commit 91a3d71

Please sign in to comment.