-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 83: Enable Python bindings for StreamManager and EventWriter. (#…
…104) Enable Python bindings
- Loading branch information
Showing
29 changed files
with
568 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ pravega-*.tgz | |
.vscode | ||
/shared/target/ | ||
.gradle | ||
*.log | ||
|
||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ version = "0.1.0" | |
edition = "2018" | ||
categories = ["Network programming"] | ||
keywords = ["streaming", "client", "pravega"] | ||
readme = "Readme.md" | ||
readme = "README.md" | ||
repository = "https://github.com/pravega/pravega-client-rust" | ||
license = "Apache-2.0" | ||
description = "A Rust client for Pravega. (Pravega.io)" | ||
|
@@ -15,7 +15,7 @@ authors = ["Tom Kaitchuck <[email protected]>", "Wenqi Mou <wenqi.mou@dell. | |
|
||
[workspace] | ||
members = [ | ||
"controller-client", "shared", "wire_protocol", "retry", "integration_test", "connection_pool", "channel", | ||
"controller-client", "shared", "wire_protocol", "retry", "integration_test", "connection_pool", "channel", "bindings" | ||
] | ||
|
||
[dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[package] | ||
name = "pravega-rust-client-bindings" | ||
version = "0.1.0" | ||
edition = "2018" | ||
categories = ["Network programming"] | ||
keywords = ["streaming", "client", "pravega"] | ||
readme = "Readme.md" | ||
repository = "https://github.com/pravega/pravega-client-rust" | ||
license = "Apache-2.0" | ||
description = "An internal library used by the Rust client for Pravega to generated language bindings for Python and WASM." | ||
authors = ["Tom Kaitchuck <[email protected]>", "Wenqi Mou <[email protected]>", | ||
"Sandeep Shridhar <[email protected]>", "Wenxiao Zhang <[email protected]>"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
name = "pravega_client" | ||
crate-type = ["cdylib"] | ||
|
||
[features] | ||
default = ["python_binding"] | ||
javascript_binding = ["wasm-bindgen"] | ||
python_binding = ["pyo3"] | ||
|
||
#Run tests for bindings using command cargo test --no-default-features | ||
|
||
[dependencies] | ||
log = "0.4" | ||
pravega-client-rust = { path = "../" } | ||
pravega-wire-protocol = { path = "../wire_protocol"} | ||
pravega-controller-client = { path = "../controller-client"} | ||
pravega-rust-client-shared = { path = "../shared"} | ||
pravega-rust-client-retry = {path = "../retry"} | ||
pravega-connection-pool = {path= "../connection_pool"} | ||
tokio = { version = "0.2.13", features = ["full"] } | ||
lazy_static = "1.4.0" | ||
uuid = {version = "0.8", features = ["v4"]} | ||
futures = "0.3.5" | ||
derive-new = "0.5" | ||
#Python bindings | ||
pyo3 = { features = ["extension-module"], optional = true, version = "0.10.1" } | ||
#WASM bindings | ||
wasm-bindgen = { version = "0.2.63", optional = true } | ||
cfg-if = "0.1.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Language Bindings | ||
|
||
This provides a way to generate multiple language bindings to interact with Pravega. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["maturin"] | ||
build-backend = "maturin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
|
||
#[macro_use] | ||
extern crate cfg_if; | ||
|
||
mod stream_manager; | ||
mod stream_writer; | ||
cfg_if! { | ||
if #[cfg(feature = "python_binding")] { | ||
use pyo3::prelude::*; | ||
use stream_manager::StreamManager; | ||
#[macro_use] | ||
extern crate derive_new; | ||
use stream_writer::StreamWriter; | ||
} | ||
} | ||
|
||
#[cfg(feature = "python_binding")] | ||
#[pymodule] | ||
/// A Python module implemented in Rust. | ||
fn pravega_client(_py: Python, m: &PyModule) -> PyResult<()> { | ||
m.add_class::<StreamManager>()?; | ||
m.add_class::<StreamWriter>()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
|
||
import unittest | ||
import pravega_client; | ||
|
||
class PravegaTest(unittest.TestCase): | ||
def test_writeEvent(self): | ||
print("Creating a Stream Manager, ensure pravega is running") | ||
stream_manager=pravega_client.StreamManager("127.0.0.1:9090") | ||
|
||
print("Creating a scope") | ||
scope_result=stream_manager.create_scope("testScope") | ||
self.assertEqual(True, scope_result, "Scope creation status") | ||
|
||
print("Creating a stream") | ||
stream_result=stream_manager.create_stream("testScope", "testStream", 1) | ||
self.assertEqual(True, stream_result, "Stream creation status") | ||
|
||
print("Creating a writer for Stream") | ||
w1=stream_manager.create_writer("testScope","testStream") | ||
|
||
print("Write events") | ||
w1.write_event("test event1") | ||
w1.write_event("test event2") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.