-
Notifications
You must be signed in to change notification settings - Fork 21
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
Disable sdv.databroker.v1 by default #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ const CLI_COMMANDS: &[(&str, &str, &str)] = &[ | |
"<QUERY>", | ||
"Subscribe to signals with QUERY, if you use kuksa feature comma separated list", | ||
), | ||
("feed", "<PATH> <VALUE>", "Publish signal value"), | ||
("publish", "<PATH> <VALUE>", "Publish signal value"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. provide? |
||
( | ||
"metadata", | ||
"[PATTERN]", | ||
|
@@ -351,9 +351,6 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> { | |
cmd, | ||
format!("{} is not an actuator.", metadata.name), | ||
)?; | ||
cli::print_info( | ||
"If you want to provide the signal value, use `feed`.", | ||
)?; | ||
continue; | ||
} | ||
|
||
|
@@ -404,7 +401,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> { | |
} | ||
} | ||
} | ||
"feed" => { | ||
"publish" => { | ||
interface.add_history_unique(line.clone()); | ||
|
||
let (path, value) = cli::split_first_word(args); | ||
|
@@ -916,7 +913,7 @@ impl<Term: Terminal> Completer<Term> for CliCompleter { | |
Some(compls) | ||
} | ||
// Complete command parameters | ||
Some("set") | Some("feed") => { | ||
Some("set") | Some("publish") => { | ||
if words.count() == 0 { | ||
self.complete_entry_path(word) | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,12 @@ pub enum ServerTLS { | |
Enabled { tls_config: ServerTlsConfig }, | ||
} | ||
|
||
#[derive(PartialEq)] | ||
pub enum Api { | ||
KuksaValV1, | ||
SdvDatabrokerV1, | ||
} | ||
|
||
impl tonic::service::Interceptor for Authorization { | ||
fn call( | ||
&mut self, | ||
|
@@ -93,6 +99,7 @@ pub async fn serve<F>( | |
addr: impl Into<std::net::SocketAddr>, | ||
broker: broker::DataBroker, | ||
#[cfg(feature = "tls")] server_tls: ServerTLS, | ||
apis: &[Api], | ||
authorization: Authorization, | ||
signal: F, | ||
) -> Result<(), Box<dyn std::error::Error>> | ||
|
@@ -124,6 +131,7 @@ where | |
broker, | ||
#[cfg(feature = "tls")] | ||
server_tls, | ||
apis, | ||
authorization, | ||
signal, | ||
) | ||
|
@@ -134,6 +142,7 @@ pub async fn serve_with_incoming_shutdown<F>( | |
listener: TcpListener, | ||
broker: broker::DataBroker, | ||
#[cfg(feature = "tls")] server_tls: ServerTLS, | ||
apis: &[Api], | ||
authorization: Authorization, | ||
signal: F, | ||
) -> Result<(), Box<dyn std::error::Error>> | ||
|
@@ -146,15 +155,15 @@ where | |
} | ||
|
||
let incoming = TcpListenerStream::new(listener); | ||
let mut builder = Server::builder() | ||
let mut server = Server::builder() | ||
.http2_keepalive_interval(Some(Duration::from_secs(10))) | ||
.http2_keepalive_timeout(Some(Duration::from_secs(20))); | ||
|
||
#[cfg(feature = "tls")] | ||
match server_tls { | ||
ServerTLS::Enabled { tls_config } => { | ||
info!("Using TLS"); | ||
builder = builder.tls_config(tls_config)?; | ||
server = server.tls_config(tls_config)?; | ||
} | ||
ServerTLS::Disabled => { | ||
info!("TLS is not enabled") | ||
|
@@ -165,23 +174,35 @@ where | |
info!("Authorization is not enabled."); | ||
} | ||
|
||
builder | ||
.add_service( | ||
let kuksa_val_v1 = { | ||
if apis.contains(&Api::KuksaValV1) { | ||
Some(kuksa::val::v1::val_server::ValServer::with_interceptor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. val_server can maybe cause confusion with old kuksa_val_server in c++? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not changed as part of this commit. It is referencing generated code, which having a protobuf service definition like this: service VAL {
...
} will generate code |
||
broker.clone(), | ||
authorization.clone(), | ||
)) | ||
} else { | ||
None | ||
} | ||
}; | ||
|
||
let mut router = server.add_optional_service(kuksa_val_v1); | ||
|
||
if apis.contains(&Api::SdvDatabrokerV1) { | ||
router = router.add_optional_service(Some( | ||
sdv::databroker::v1::broker_server::BrokerServer::with_interceptor( | ||
broker.clone(), | ||
authorization.clone(), | ||
), | ||
) | ||
.add_service( | ||
)); | ||
router = router.add_optional_service(Some( | ||
sdv::databroker::v1::collector_server::CollectorServer::with_interceptor( | ||
broker.clone(), | ||
authorization.clone(), | ||
authorization, | ||
), | ||
) | ||
.add_service(kuksa::val::v1::val_server::ValServer::with_interceptor( | ||
broker.clone(), | ||
authorization, | ||
)) | ||
)); | ||
} | ||
|
||
router | ||
.serve_with_incoming_shutdown(incoming, shutdown(broker, signal)) | ||
.await?; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that crossed my mind as well. I'm not against it, but my idea is that
publish
is that act of publishing a single signal value, while "provide" might be better suited for describing the act of continuously providing a signal. "publish" would then be the logical counterpart to "subscribe".I suppose we will have a discussion around this in the API design rounds. I just couldn't stand having
feed
still there 🥲