Skip to content

Commit f94e34e

Browse files
authored
feat: Adding features for SystemD and RPC (#195)
* feat: Adding features for SystemD and RPC * fix: patch examples
1 parent e4ec906 commit f94e34e

File tree

17 files changed

+55
-31
lines changed

17 files changed

+55
-31
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ members = [
2727
]
2828

2929
[workspace.package]
30-
version = "0.7.0"
30+
version = "0.8.0"

core/launcher/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
[package]
1919
name = "launcher"
20-
version = "0.7.0"
20+
version = "0.8.0"
2121
edition = "2021"
2222

2323
# See more keys and their definitions at https:#doc.rust-lang.org/cargo/reference/manifest.html

core/main/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
[package]
1919
name = "main"
20-
version = "0.7.0"
20+
version = "0.8.0"
2121
edition = "2021"
2222
repository = "https://github.com/rdkcentral/Ripple"
2323
build = "build.rs"
@@ -28,8 +28,12 @@ build = "build.rs"
2828
name = "ripple"
2929
path = "src/main.rs"
3030

31+
[features]
32+
local_dev=[]
33+
sysd=["dep:sd-notify"]
34+
3135
[dependencies]
32-
ripple_sdk = { path = "../sdk" }
36+
ripple_sdk = { path = "../sdk", features = ["full"] }
3337
jsonrpsee = { version = "0.9.0", features = ["macros", "ws-server"] }
3438
futures-channel = "0.3.21"
3539
futures = "0.3.21"
@@ -40,6 +44,7 @@ arrayvec = "0.7.2"
4044
regex = "=1.7.3"
4145
serde_json = "1.0"
4246
base64 = "0.13.0"
47+
sd-notify = { version = "0.4.1", optional = true }
4348

4449
[build-dependencies]
4550
vergen = "1"

core/main/src/bootstrap/start_fbgateway_step.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@ impl Bootstep<BootstrapState> for FireboltGatewayStep {
100100
.get_client()
101101
.add_request_processor(RpcGatewayProcessor::new(state.platform_state.get_client()));
102102
debug!("Adding RPC gateway processor");
103+
#[cfg(feature = "sysd")]
104+
if let Ok(_) = sd_notify::booted() {
105+
if let Err(_) = sd_notify::notify(false, &[sd_notify::NotifyState::Ready]) {
106+
return Err(RippleError::BootstrapError);
107+
}
108+
}
109+
103110
gateway.start().await;
104-
debug!("Handlers initialized");
105111
Ok(())
106112
}
107113
}

core/sdk/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717

1818
[package]
1919
name = "ripple_sdk"
20-
version = "0.7.0"
20+
version = "0.8.0"
2121
edition = "2021"
2222
repository = "https://github.com/rdkcentral/Ripple"
2323
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2424

25+
[features]
26+
default=[]
27+
rpc=["dep:jsonrpsee-core"]
28+
full=["rpc"]
29+
sysd=[]
30+
2531
[dependencies]
2632
serde = { version = "1.0", features = ["derive"] }
2733
serde_json = "1.0"
@@ -36,5 +42,5 @@ crossbeam = "0.8.2"
3642
tokio = { version = "1.16.1", features = ["macros", "sync", "rt-multi-thread", "signal", "time"] }
3743
uuid = { version = "1.1.2", features = ["serde", "v5", "v4"] }
3844
futures = "0.3.21"
39-
jsonrpsee-core = { version = "0.9.0", features = ["server"] }
45+
jsonrpsee-core = { version = "0.9.0", features = ["server"], optional = true }
4046
regex = "=1.7.3"

core/sdk/src/api/apps.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,6 @@ pub enum AppError {
199199
AppNotReady,
200200
}
201201

202-
impl From<AppError> for jsonrpsee_core::Error {
203-
fn from(err: AppError) -> Self {
204-
jsonrpsee_core::Error::Custom(format!("Internal failure: {:?}", err))
205-
}
206-
}
207-
208202
#[derive(Debug, Clone)]
209203
pub enum AppMethod {
210204
Launch(LaunchRequest),

core/sdk/src/api/device/device_peristence.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use crate::{
2020
framework::ripple_contract::RippleContract,
2121
};
2222
use chrono::Utc;
23-
use jsonrpsee_core::Serialize;
24-
use serde::Deserialize;
23+
use serde::{Deserialize, Serialize};
2524
use serde_json::Value;
2625

2726
use super::device_request::DeviceRequest;

core/sdk/src/api/firebolt/fb_authentication.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
// SPDX-License-Identifier: Apache-2.0
1616
//
1717

18-
use jsonrpsee_core::Serialize;
19-
use serde::Deserialize;
18+
use serde::{Deserialize, Serialize};
2019

2120
use crate::{
2221
api::session::TokenType,

core/sdk/src/extn/ffi/ffi_jsonrpsee.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// SPDX-License-Identifier: Apache-2.0
1616
//
1717

18-
use crate::extn::client::extn_sender::ExtnSender;
18+
use crate::{api::apps::AppError, extn::client::extn_sender::ExtnSender};
1919
use crossbeam::channel::Receiver as CReceiver;
2020
use jsonrpsee_core::server::rpc_module::Methods;
2121
use libloading::{Library, Symbol};
@@ -57,3 +57,9 @@ pub unsafe fn load_jsonrpsee_methods(lib: &Library) -> Option<Box<JsonRpseeExtnB
5757
}
5858
None
5959
}
60+
61+
impl From<AppError> for jsonrpsee_core::Error {
62+
fn from(err: AppError) -> Self {
63+
jsonrpsee_core::Error::Custom(format!("Internal failure: {:?}", err))
64+
}
65+
}

core/sdk/src/extn/ffi/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//
1717

1818
pub mod ffi_channel;
19+
#[cfg(feature = "rpc")]
1920
pub mod ffi_jsonrpsee;
2021
pub mod ffi_library;
2122
pub mod ffi_message;

0 commit comments

Comments
 (0)