Skip to content

Commit 94a2489

Browse files
committed
Example and scaffolding for sse-kafka
1 parent 397a1ee commit 94a2489

File tree

23 files changed

+2042
-14
lines changed

23 files changed

+2042
-14
lines changed

Diff for: COPYRIGHT-AklivityCommunity

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
/*
2-
* Copyright ${copyrightYears} Aklivity Inc
3-
*
4-
* Licensed under the Aklivity Community License (the "License"); you may not use
5-
* this file except in compliance with the License. You may obtain a copy of the
6-
* License at
7-
*
8-
* http://www.aklivity.io/aklivity-community-license
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12-
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
13-
* specific language governing permissions and limitations under the License.
14-
*/
1+
Copyright ${copyrightYears} Aklivity Inc
152

3+
Licensed under the Aklivity Community License (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at
6+
7+
https://www.aklivity.io/aklivity-community-license/
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
WARRANTIES OF ANY KIND, either express or implied. See the License for the
12+
specific language governing permissions and limitations under the License.

Diff for: examples/sse.kafka.proxy/README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# sse.kafka.proxy (incubator)
2+
Listens on https port `9090` and will stream back whatever is published to the `zilla` topic in Kafka.
3+
4+
### Requirements
5+
- JDK 11 or higher.
6+
- Incubator build
7+
8+
### Install modular Java runtime
9+
```bash
10+
$ ./zpmw clean
11+
$ ./zpmw install --exclude-remote-repositories
12+
...
13+
linked modules
14+
generated launcher
15+
```
16+
17+
### Start kafka broker
18+
```bash
19+
$ docker stack deploy -c stack.yml example
20+
Creating network example_net0
21+
Creating service example_kafka
22+
Creating service example_zookeeper
23+
```
24+
25+
### Start zilla engine
26+
```bash
27+
$ ./zilla start
28+
started
29+
```
30+
31+
### Install sse-cat client
32+
Requires Server-Sent Events client, such as `sse-cat`.
33+
```bash
34+
$ npm install sse-cat
35+
```
36+
37+
### Install kcat client
38+
Requires Kafka client, such as `kcat`.
39+
```bash
40+
$ brew install sse-cat
41+
```
42+
43+
### Verify behavior
44+
Connect `sse-cat` client first, then send `Hello, world` from `kcat` producer client.
45+
```bash
46+
$ sse-cat http://localhost:8080/zilla
47+
Hello, world
48+
```
49+
```bash
50+
$ echo "Hello, world" | kcat -P -b localhost:9092 -t zilla
51+
```

Diff for: examples/sse.kafka.proxy/localhost.p12

5.5 KB
Binary file not shown.

Diff for: examples/sse.kafka.proxy/stack.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: "3"
2+
3+
networks:
4+
net0:
5+
driver: overlay
6+
7+
services:
8+
9+
kafka:
10+
image: "bitnami/kafka:3"
11+
hostname: "kafka.local"
12+
networks:
13+
- net0
14+
environment:
15+
- ALLOW_PLAINTEXT_LISTENER=yes
16+
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
17+
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
18+
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
19+
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT
20+
- KAFKA_ZOOKEEPER_PROTOCOL=PLAINTEXT
21+
ports:
22+
- "9092:9092"
23+
24+
zookeeper:
25+
image: 'bitnami/zookeeper:3'
26+
hostname: "zookeeper.internal.net"
27+
networks:
28+
- net0
29+
environment:
30+
- ALLOW_ANONYMOUS_LOGIN=yes

Diff for: examples/sse.kafka.proxy/test-ca.crt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIFXjCCA0YCCQCuorYrG5wG+DANBgkqhkiG9w0BAQsFADBxMQswCQYDVQQGEwJV
3+
UzETMBEGA1UECAwKQ2FsaWZvcm5pYTESMBAGA1UEBwwJUGFsbyBBbHRvM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GSIb3DQEBCwUAA4IC
20+
AQDEzoEbCsHpae5M1I+vezg7w5NAItMU4WU9IccTylSB/gfIT+hWwIv9KiqTWjxw
21+
Y5Aj6XJ1mATHAMSQnNZCnP2Hw39/Nc3HcKmek2na2zK/TBSEFXudJmox8SK32r26
22+
nLstNlcYf7ixqJ5T7SOE2GJOcEUWpvTSbvQD0NvG81BVnSyUfX3FgkQLwwlyBoSE
23+
7FwFz+ybrbisUHHqzPVnSblEDbKv6T9ai3FjbBegzPVSd9RmtB/DzxhdSk+kL1oD
24+
VSEPweSHEqamEnq2RIgLb7rYhmfohl0fGF5W6I3LvLqqe0KLRRID9V/jwBUGyICG
25+
W3jGu+68jOIUqXA4+gfOwXNktd4F7So48ySbghgrY0Umr4KSs6CTHhvSZ4ZG8QO/
26+
ZyC+DjXsU3mihIBP/Q43YU7dYxFSdlCw79YnXvdWu7K7lZ1bIcbdH+RShcbvPcwg
27+
iM2qAvCgZBA8xHMDQeev8QdQjxtN+uBfee0mkvbzPbIh/0prywPHjAie/bXVBPVt
28+
VK6Gej2egPCIA5ThvGpmXh8kPd5Aqy1J++cmrzfYfPPsbmPGTLI0HFMhUuzIhFbd
29+
TzAV/Qj83r722s6f0v3KEEhfi3EZu3bRSGIyxVtebtOLGvEb2PjJrktyVJgivVFX
30+
uHHpz76QFOcLy1F962Hfj51NnIROOySyl12JkhPRTlMoiQ==
31+
-----END CERTIFICATE-----

Diff for: examples/sse.kafka.proxy/zilla.json

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"name": "example",
3+
"vaults":
4+
{
5+
"server":
6+
{
7+
"type": "filesystem",
8+
"options":
9+
{
10+
"keys":
11+
{
12+
"store": "localhost.p12",
13+
"type": "pkcs12",
14+
"password": "generated"
15+
}
16+
}
17+
}
18+
},
19+
"bindings":
20+
{
21+
"tcp0":
22+
{
23+
"type" : "tcp",
24+
"kind": "server",
25+
"options":
26+
{
27+
"host": "0.0.0.0",
28+
"port": 9090
29+
},
30+
"exit": "tls0"
31+
},
32+
"tcp1":
33+
{
34+
"type" : "tcp",
35+
"kind": "server",
36+
"options":
37+
{
38+
"host": "0.0.0.0",
39+
"port": 8080
40+
},
41+
"exit": "http0"
42+
},
43+
"tls0":
44+
{
45+
"type" : "tls",
46+
"kind": "server",
47+
"vault": "server",
48+
"options":
49+
{
50+
"keys": [ "localhost" ],
51+
"sni": [ "localhost" ]
52+
},
53+
"exit": "http0"
54+
},
55+
"http0":
56+
{
57+
"type" : "http",
58+
"kind": "server",
59+
"routes":
60+
[
61+
{
62+
"exit": "sse0",
63+
"when":
64+
[
65+
{
66+
"headers":
67+
{
68+
":scheme": "http",
69+
":authority": "localhost:8080"
70+
}
71+
},
72+
{
73+
"headers":
74+
{
75+
":scheme": "https",
76+
":authority": "localhost:9090"
77+
}
78+
}
79+
]
80+
}
81+
]
82+
},
83+
"sse0":
84+
{
85+
"type" : "sse",
86+
"kind": "server",
87+
"exit": "sse_kafka0"
88+
},
89+
"sse_kafka0":
90+
{
91+
"type" : "sse-kafka",
92+
"kind": "proxy",
93+
"routes":
94+
[
95+
{
96+
"exit": "kafka0",
97+
"when":
98+
[
99+
{
100+
"path": "/{topic}",
101+
"query":
102+
[
103+
"key={key}",
104+
"headerA={headerA}"
105+
]
106+
}
107+
],
108+
"with":
109+
{
110+
"topic": "${params.topic}",
111+
"filters":
112+
[
113+
{
114+
"key": "${params.key}",
115+
"headers":
116+
{
117+
"a": "${params.headerA}"
118+
}
119+
}
120+
]
121+
}
122+
}
123+
]
124+
},
125+
"kafka0":
126+
{
127+
"type" : "kafka",
128+
"kind": "client",
129+
"options":
130+
{
131+
"merged":
132+
[
133+
"zilla"
134+
]
135+
},
136+
"exit": "tcp2"
137+
},
138+
"tcp2":
139+
{
140+
"type" : "tcp",
141+
"kind": "client"
142+
}
143+
}
144+
}

Diff for: examples/sse.kafka.proxy/zpm.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"repositories":
3+
[
4+
"https://maven.packages.aklivity.io/",
5+
"https://repo.maven.apache.org/maven2/"
6+
],
7+
8+
"imports":
9+
[
10+
"io.aklivity.zilla:runtime:develop-SNAPSHOT",
11+
"io.aklivity.zilla:incubator:develop-SNAPSHOT"
12+
],
13+
14+
"dependencies":
15+
[
16+
"io.aklivity.zilla:engine",
17+
"io.aklivity.zilla:vault-filesystem",
18+
"io.aklivity.zilla:binding-kafka",
19+
"io.aklivity.zilla:binding-sse-kafka",
20+
"io.aklivity.zilla:binding-sse",
21+
"io.aklivity.zilla:binding-http",
22+
"io.aklivity.zilla:binding-tls",
23+
"io.aklivity.zilla:binding-tcp",
24+
"io.aklivity.zilla:command",
25+
"io.aklivity.zilla:command-start",
26+
"io.aklivity.zilla:command-tune",
27+
"io.aklivity.zilla:command-load",
28+
"io.aklivity.zilla:command-stop"
29+
]
30+
}

Diff for: examples/sse.kafka.proxy/zpmw

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
version="develop-SNAPSHOT"
3+
localPath="$HOME/.m2/repository/io/aklivity/zilla/manager/$version/manager-$version.jar"
4+
wrappedPath=".zpm/wrapper/manager-$version.jar"
5+
wrappedURL="https://maven.packages.aklivity.io/io/aklivity/zilla/manager/$version/manager-$version.jar"
6+
if [ ! -r "$wrappedPath" ]; then
7+
mkdir -p `dirname $wrappedPath`
8+
if [ -r "$localPath" ]; then
9+
echo $wrappedPath not found, copying from $localPath
10+
cp $localPath $wrappedPath
11+
else
12+
echo $wrappedPath not found, downloading from $wrappedURL
13+
if command -v wget > /dev/null; then
14+
wget -O "$wrappedPath" "$wrappedURL" -nv
15+
else
16+
echo wget missing, download failed
17+
fi
18+
fi
19+
fi
20+
java $JAVA_OPTIONS -jar "$wrappedPath" "$@"

Diff for: incubator/binding-sse-kafka.spec/COPYRIGHT

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright ${copyrightYears} Aklivity Inc
2+
3+
Licensed under the Aklivity Community License (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at
6+
7+
https://www.aklivity.io/aklivity-community-license/
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
WARRANTIES OF ANY KIND, either express or implied. See the License for the
12+
specific language governing permissions and limitations under the License.

0 commit comments

Comments
 (0)