Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update sink-http README #17

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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