Skip to content

Commit 9ce5e8b

Browse files
committed
(WIP) Import TableView
1 parent e463ef3 commit 9ce5e8b

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

pulsar/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from pulsar.__about__ import __version__
5555

5656
from pulsar.exceptions import *
57+
from pulsar.tableview import TableView
5758

5859
from pulsar.functions.function import Function
5960
from pulsar.functions.context import Context

pulsar/tableview.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
"""
21+
The TableView implementation.
22+
"""
23+
24+
class TableView():
25+
26+
def __init__(self) -> None:
27+
pass

src/client.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ void export_client(py::module_& m) {
8989
.def("subscribe_topics", &Client_subscribe_topics)
9090
.def("subscribe_pattern", &Client_subscribe_pattern)
9191
.def("create_reader", &Client_createReader)
92+
.def("create_table_view", [](Client& client, const std::string& topic,
93+
const TableViewConfiguration& config) {
94+
return waitForAsyncValue<TableView>([&](TableViewCallback callback) {
95+
client.createTableViewAsync(topic, config, callback);
96+
});
97+
})
9298
.def("get_topic_partitions", &Client_getTopicPartitions)
9399
.def("get_schema_info", &Client_getSchemaInfo)
94100
.def("close", &Client_close)

src/pulsar.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void export_enums(Module& m);
3232
void export_authentication(Module& m);
3333
void export_schema(Module& m);
3434
void export_exceptions(Module& m);
35+
void export_table_view(Module& m);
3536

3637
PYBIND11_MODULE(_pulsar, m) {
3738
export_exceptions(m);
@@ -44,4 +45,5 @@ PYBIND11_MODULE(_pulsar, m) {
4445
export_enums(m);
4546
export_authentication(m);
4647
export_schema(m);
48+
export_table_view(m);
4749
}

src/table_view.cc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
#include <pybind11/pybind11.h>
20+
#include <pulsar/TableView.h>
21+
#include <pulsar/Schema.h>
22+
#include <pulsar/TableViewConfiguration.h>
23+
24+
namespace py = pybind11;
25+
using namespace pulsar;
26+
27+
void export_table_view(py::module_& m) {
28+
py::class_<TableViewConfiguration>(m, "TableViewConfiguration")
29+
.def(py::init<>())
30+
.def("subscription_name",
31+
[](TableViewConfiguration& config, const std::string& name) { config.subscriptionName = name; })
32+
.def("schema",
33+
[](TableViewConfiguration& config, const SchemaInfo& schema) { config.schemaInfo = schema; });
34+
35+
py::class_<TableView>(m, "TableView").def(py::init<>());
36+
}

0 commit comments

Comments
 (0)