Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Main changes: * zenoh-net API uses RBuf * zenoh-net API uses Streams * Queries/Replies handling and routing optimizations * Session lease and close timeout * Pass startup arguments to plugins * Plugins no longer establish a co-localized TCP session * Implemetation of TCP_LINGER option * Implementation of pull * Implementation of HTTP plugin * Implementation of Admin space Co-authored-by: Olivier Hécart <olivier.hecart@adlinktech.com> Co-authored-by: Luca Cominardi <3995219+Mallets@users.noreply.github.com>
- Loading branch information
1 parent
15f7756
commit 7e96c10
Showing
65 changed files
with
3,060 additions
and
1,331 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
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 @@ | ||
# | ||
# Copyright (c) 2017, 2020 ADLINK Technology Inc. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Eclipse Public License 2.0 which is available at | ||
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
# which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
# | ||
# Contributors: | ||
# ADLINK zenoh team, <zenoh@adlink-labs.tech> | ||
# | ||
[package] | ||
name = "zplugin-http" | ||
version = "0.5.0" | ||
authors = ["kydos <angelo@icorsaro.net>", | ||
"Julien Enoch <julien@enoch.fr>", | ||
"Olivier Hécart <olivier.hecart@adlinktech.com", | ||
"Luca Cominardi <luca.cominardi@adlinktech.com>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
name = "zplugin_http" | ||
crate-type = ["cdylib"] | ||
|
||
|
||
[dependencies] | ||
zenoh = { version = "0.5.0", path = "../../zenoh" } | ||
zenoh-router = { version = "0.5.0", path = "../../zenoh-router" } | ||
zenoh-protocol = { version = "0.5.0", path = "../../zenoh-protocol" } | ||
futures = "0.3.5" | ||
clap = "2" | ||
log = "0.4" | ||
env_logger = "0.7.1" | ||
tide = "0.11.0" | ||
|
||
[dependencies.async-std] | ||
version = "~1.6.0" | ||
features = ["unstable"] | ||
|
||
[[example]] | ||
name = "zn_serve_sse" | ||
path = "examples/zenoh-net/zn_serve_sse.rs" |
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,76 @@ | ||
// | ||
// Copyright (c) 2017, 2020 ADLINK Technology Inc. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// | ||
// Contributors: | ||
// ADLINK zenoh team, <zenoh@adlink-labs.tech> | ||
// | ||
#![feature(async_closure)] | ||
|
||
use clap::{App, Arg}; | ||
use futures::prelude::*; | ||
use zenoh::net::*; | ||
use zenoh::net::queryable::EVAL; | ||
use zenoh_protocol::proto::{encoding, kind}; | ||
|
||
const HTML: &'static str = | ||
"<div id=\"result\"></div>\ | ||
<script>\ | ||
if(typeof(EventSource) !== \"undefined\") {\ | ||
var source = new EventSource(\"/demo/sse/event\");\ | ||
source.addEventListener(\"PUT\", function(e) {\ | ||
document.getElementById(\"result\").innerHTML += e.data + \"<br>\";\ | ||
}, false);\ | ||
} else {\ | ||
document.getElementById(\"result\").innerHTML = \"Sorry, your browser does not support server-sent events...\";\ | ||
}\ | ||
</script>"; | ||
|
||
#[async_std::main] | ||
async fn main() { | ||
// initiate logging | ||
env_logger::init(); | ||
|
||
let args = App::new("zenoh-net ssl server example") | ||
.arg(Arg::from_usage("-l, --locator=[LOCATOR] 'Sets the locator used to initiate the zenoh session'")) | ||
.get_matches(); | ||
|
||
let locator = args.value_of("locator").unwrap_or("").to_string(); | ||
let path = "/demo/sse"; | ||
let value = "Pub from sse server!"; | ||
|
||
println!("Openning session..."); | ||
let session = open(&locator, None).await.unwrap(); | ||
|
||
println!("Declaring Queryable on {}", path); | ||
let queryable = session.declare_queryable(&path.clone().into(), EVAL).await.unwrap(); | ||
|
||
async_std::task::spawn( | ||
queryable.for_each(async move |(_res_name, _predicate, replies_sender)|{ | ||
replies_sender.send((path.to_string(), HTML.as_bytes().into(), None)).await; | ||
}) | ||
); | ||
|
||
let event_path = [path, "/event"].concat(); | ||
|
||
print!("Declaring Resource {}", event_path); | ||
let rid = session.declare_resource(&event_path.into()).await.unwrap(); | ||
println!(" => RId {}", rid); | ||
|
||
println!("Declaring Publisher on {}", rid); | ||
let _publ = session.declare_publisher(&rid.into()).await.unwrap(); | ||
|
||
println!("Writing Data periodically ('{}': '{}')...", rid, value); | ||
|
||
println!("Data updates are accessible through HTML5 SSE at http://<hostname>:8000{}", path); | ||
loop { | ||
session.write_wo(&rid.into(), value.as_bytes().into(), encoding::TEXT_PLAIN, kind::PUT).await.unwrap(); | ||
async_std::task::sleep(std::time::Duration::new(1, 0)).await; | ||
} | ||
} |
Oops, something went wrong.