Skip to content

Commit

Permalink
fix issue #68
Browse files Browse the repository at this point in the history
  • Loading branch information
niclaslind authored and carlmartus committed Jan 13, 2022
1 parent 040d8f2 commit 1535d5f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
8 changes: 4 additions & 4 deletions examples/grpc/rust/beamybroker-pubsub-example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "beamy-broker-client-example"
name = "beamy-broker-pubsub-example"
version = "0.1.0"
authors = ["Lind, Niclas <[email protected]>"]
edition = "2021"
Expand All @@ -13,9 +13,9 @@ name = "pub_client"
path = "src/pub_client/main.rs"

[dependencies]
tonic = "0.6.2"
prost = "0.9.0"
tokio = { version = "1.14.0", features = ["rt-multi-thread", "time", "fs", "macros", "net"] }
tonic = "0.6.2"

[build-dependencies]
tonic-build = "0.6.2"
# local lib
lib-helper = { path = "../helper" }
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
use beamy_broker_client_example::beamy_api::base::network_service_client::NetworkServiceClient;
use beamy_broker_client_example::beamy_api::base::{
signal::Payload::Integer, ClientId, NameSpace, PublisherConfig, Signal, SignalId, Signals,
};
use std::io::Write;

use lib_helper::{
beamy_api::base::{
network_service_client::NetworkServiceClient, signal::Payload::Integer,
system_service_client::SystemServiceClient, ClientId, NameSpace, PublisherConfig, Signal,
SignalId, Signals,
},
check_license, reload_configuration, upload_folder,
};
use tonic::transport::Channel;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = Channel::from_static("http://localhost:50051")
.connect()
.await?;
let mut client = NetworkServiceClient::new(channel);

let mut system_stub = SystemServiceClient::new(channel.clone());
let mut network_stub = NetworkServiceClient::new(channel);

check_license(&mut system_stub).await?;
upload_folder(&mut system_stub, "configuration").await?;
reload_configuration(&mut system_stub).await?;

// Publish 10 messages
for _ in 0..=10 {
Expand All @@ -35,7 +46,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
frequency: 0,
};

let result = client.publish_signals(publisher_config).await?;
let result = network_stub.publish_signals(publisher_config).await?;
println!("{:#?}", result.metadata());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
use beamy_broker_client_example::beamy_api::base::network_service_client::NetworkServiceClient;
use beamy_broker_client_example::beamy_api::base::{
ClientId, NameSpace, SignalId, SignalIds, SubscriberConfig,
};
use tonic::transport::Channel;

use lib_helper::{
beamy_api::base::{
network_service_client::NetworkServiceClient, system_service_client::SystemServiceClient,
ClientId, NameSpace, SignalId, SignalIds, SubscriberConfig,
},
check_license, reload_configuration, upload_folder,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = Channel::from_static("http://localhost:50051")
.connect()
.await?;
let mut client = NetworkServiceClient::new(channel);
let mut system_stub = SystemServiceClient::new(channel.clone());
let mut network_stub = NetworkServiceClient::new(channel);

check_license(&mut system_stub).await?;
upload_folder(&mut system_stub, "configuration").await?;
reload_configuration(&mut system_stub).await?;

let client_id = Some(ClientId {
id: "rusty_subscriber".to_string(),
Expand All @@ -23,7 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
on_change: true,
};

let mut result = client
let mut result = network_stub
.subscribe_to_signals(subscriber_config)
.await?
.into_inner();
Expand Down

0 comments on commit 1535d5f

Please sign in to comment.