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

Support pgsql-kafka binding #1245

Merged
merged 23 commits into from
Sep 18, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

---
name: test
catalogs:
catalog0:
type: test
options:
url: http://localhost:8081

bindings:
app0:
type: pgsql-kafka
kind: proxy
catalog:
catalog0:
- strategy: topic
exit: app1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"op": "add",
"path": "/$defs/binding/properties/type/enum/-",
"value": "pgsql-kafka"
},
{
"op": "add",
"path": "/$defs/binding/allOf/-",
"value":
{
"if":
{
"properties":
{
"type":
{
"const": "pgsql-kafka"
}
}
},
"then":
{
"properties":
{
"type":
{
"const": "pgsql-kafka"
},
"kind":
{
"enum": [ "proxy" ]
},
"vault": false,
"options": false,
"routes": false,
"required":
[
"exit"
]
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

connect "zilla://streams/app1"
option zilla:window 8192
option zilla:transmission "half-duplex"

write zilla:begin.ext ${kafka:beginEx()
.typeId(zilla:id("kafka"))
.request()
.createTopics()
.topic()
.name("dev.cities")
.partitionCount(1)
.replicas(1)
.assignment(0, 0)
.config("cleanup.policy", "compact")
.build()
.timeout(0)
.validateOnly("false")
.build()
.build()}

connected

read zilla:begin.ext ${kafka:matchBeginEx()
.typeId(zilla:id("kafka"))
.response()
.createTopics()
.throttle(0)
.topic()
.name("dev.cities")
.error(0)
.build()
.build()
.build()}

read closed
write close
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

property serverAddress "zilla://streams/app1"

accept ${serverAddress}
option zilla:window 8192
option zilla:transmission "half-duplex"

accepted

read zilla:begin.ext ${kafka:matchBeginEx()
.typeId(zilla:id("kafka"))
.request()
.createTopics()
.topic()
.name("dev.cities")
.partitionCount(1)
.replicas(1)
.assignment(0, 0)
.config("cleanup.policy", "compact")
.build()
.timeout(0)
.validateOnly("false")
.build()
.build()}

connected

write zilla:begin.ext ${kafka:beginEx()
.typeId(zilla:id("kafka"))
.response()
.createTopics()
.throttle(0)
.topic()
.name("dev.cities")
.error(0)
.build()
.build()
.build()}

write close
read closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

connect "zilla://streams/app1"
option zilla:window 8192
option zilla:transmission "half-duplex"

write zilla:begin.ext ${kafka:beginEx()
.typeId(zilla:id("kafka"))
.request()
.deleteTopics()
.topic("dev.cities")
.timeout(0)
.build()
.build()}

connected

read zilla:begin.ext ${kafka:matchBeginEx()
.typeId(zilla:id("kafka"))
.response()
.deleteTopics()
.throttle(0)
.topic()
.name("dev.cities")
.error(0)
.build()
.build()
.build()}

read closed
write close
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

property serverAddress "zilla://streams/app1"

accept ${serverAddress}
option zilla:window 8192
option zilla:transmission "half-duplex"

accepted

read zilla:begin.ext ${kafka:matchBeginEx()
.typeId(zilla:id("kafka"))
.request()
.deleteTopics()
.topic("dev.cities")
.timeout(0)
.build()
.build()}

connected

write zilla:begin.ext ${kafka:beginEx()
.typeId(zilla:id("kafka"))
.response()
.deleteTopics()
.throttle(0)
.topic()
.name("dev.cities")
.error(0)
.build()
.build()
.build()}

write close
read closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

connect "zilla://streams/app0"
option zilla:window 8192
option zilla:transmission "duplex"


write zilla:begin.ext ${pgsql:beginEx()
.typeId(zilla:id("pgsql"))
.parameter("user", "root")
.parameter("database", "dev")
.parameter("application_name", "psql")
.parameter("client_encoding", "UTF8")
.build()}

connected

write zilla:data.ext ${pgsql:dataEx()
.typeId(zilla:id("pgsql"))
.query()
.build()
.build()}
write "CREATE TOPIC IF NOT EXISTS cities "
"(description VARCHAR, id VARCHAR, name VARCHAR, PRIMARY KEY (id));"
[0x00]
write flush

read advised zilla:flush ${pgsql:flushEx()
.typeId(zilla:id("pgsql"))
.completion()
.tag("CREATE_TOPIC")
.build()
.build()}

read advised zilla:flush ${pgsql:flushEx()
.typeId(zilla:id("pgsql"))
.ready()
.status("IDLE")
.build()
.build()}

read closed
write close
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# Copyright 2021-2023 Aklivity Inc
#
# Licensed under the Aklivity Community License (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://www.aklivity.io/aklivity-community-license/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

accept "zilla://streams/app0"
option zilla:window 8192
option zilla:transmission "duplex"

accepted

read zilla:begin.ext ${pgsql:beginEx()
.typeId(zilla:id("pgsql"))
.parameter("user", "root")
.parameter("database", "dev")
.parameter("application_name", "psql")
.parameter("client_encoding", "UTF8")
.build()}

connected

read zilla:data.ext ${pgsql:dataEx()
.typeId(zilla:id("pgsql"))
.query()
.build()
.build()}
read "CREATE TOPIC IF NOT EXISTS cities "
"(description VARCHAR, id VARCHAR, name VARCHAR, PRIMARY KEY (id));"
[0x00]

write advise zilla:flush ${pgsql:flushEx()
.typeId(zilla:id("pgsql"))
.completion()
.tag("CREATE_TOPIC")
.build()
.build()}

write notify CREATE_TOPIC_COMPLETED

write advise zilla:flush ${pgsql:flushEx()
.typeId(zilla:id("pgsql"))
.ready()
.status("IDLE")
.build()
.build()}
Loading