Skip to content

Commit 2325534

Browse files
committed
[#687] Add port examples
1 parent 8c17897 commit 2325534

File tree

5 files changed

+59
-5
lines changed

5 files changed

+59
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ fn main() -> Result<(), Box<dyn core::error::Error>> {
259259
Ok(())
260260
}
261261
```
262+
262263
This example is a simplified version of the
263264
[request response example](examples/rust/request_response/). You can execute it
264265
by opening two terminals and calling:

iceoryx2/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
//! ## Request-Reponse
119119
//!
120120
//! This is a simple request-response example where a client sends a request, and the server
121-
//! responds with multiple replies.
121+
//! responds with multiple replies until the processes are gracefully terminated by the user
122+
//! with `CTRL+C`
122123
//!
123124
//! **Client (Process 1)**
124125
//!

iceoryx2/src/port/client.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
//! # Example
1414
//!
15+
//! ## Typed API
16+
//!
1517
//! ```
1618
//! use iceoryx2::prelude::*;
1719
//!
@@ -23,7 +25,10 @@
2325
//! .request_response::<u64, u64>()
2426
//! .open_or_create()?;
2527
//!
26-
//! let client = service.client_builder().create()?;
28+
//! let client = service.client_builder()
29+
//! // defines behavior when server queue is full in an non-overflowing service
30+
//! .unable_to_deliver_strategy(UnableToDeliverStrategy::DiscardSample)
31+
//! .create()?;
2732
//!
2833
//! let request = client.loan_uninit()?;
2934
//! let request = request.write_payload(1829);

iceoryx2/src/service/mod.rs

+44-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
//!
1515
//! ## Publish-Subscribe
1616
//!
17+
//! For a detailed documentation see the
18+
//! [`publish_subscribe::Builder`](crate::service::builder::publish_subscribe::Builder)
19+
//!
1720
//! ```
1821
//! use iceoryx2::prelude::*;
1922
//!
@@ -39,8 +42,42 @@
3942
//! # }
4043
//! ```
4144
//!
45+
//! ## Request-Response
46+
//!
47+
//! For a detailed documentation see the
48+
//! [`request_response::Builder`](crate::service::builder::request_response::Builder)
49+
//!
50+
//! ```
51+
//! use iceoryx2::prelude::*;
52+
//!
53+
//! # fn main() -> Result<(), Box<dyn core::error::Error>> {
54+
//! let node = NodeBuilder::new().create::<ipc::Service>()?;
55+
//!
56+
//! let service = node.service_builder(&"ReqResQos".try_into()?)
57+
//! .request_response::<u64, u64>()
58+
//! // various QoS
59+
//! .request_payload_alignment(Alignment::new(128).unwrap())
60+
//! .response_payload_alignment(Alignment::new(128).unwrap())
61+
//! .enable_safe_overflow_for_requests(true)
62+
//! .enable_safe_overflow_for_responses(true)
63+
//! .enable_fire_and_forget_requests(true)
64+
//! .max_active_requests_per_client(2)
65+
//! .max_loaned_requests(1)
66+
//! .max_response_buffer_size(4)
67+
//! .max_servers(2)
68+
//! .max_clients(10)
69+
//! // if the service already exists, open it, otherwise create it
70+
//! .open_or_create()?;
71+
//!
72+
//! # Ok(())
73+
//! # }
74+
//! ```
75+
//!
4276
//! ## Event
4377
//!
78+
//! For a detailed documentation see the
79+
//! [`event::Builder`](crate::service::builder::event::Builder)
80+
//!
4481
//! ```
4582
//! use iceoryx2::prelude::*;
4683
//!
@@ -66,6 +103,10 @@
66103
//!
67104
//! ## Service With Custom Configuration
68105
//!
106+
//! A individual [`Config`](crate::config::Config) can be attached when the
107+
//! [`Node`](crate::node::Node) is created and it will be used for every construct created using
108+
//! this [`Node`](crate::node::Node).
109+
//!
69110
//! ```
70111
//! use iceoryx2::prelude::*;
71112
//! use iceoryx2_bb_system_types::path::*;
@@ -87,7 +128,9 @@
87128
//! # }
88129
//! ```
89130
//!
90-
//! ## Publish-Subscribe With Custom Service Attributes
131+
//! ## Service With Custom Service Attributes
132+
//!
133+
//! Every [`Service`](crate::service::Service) can be created with a set of attributes.
91134
//!
92135
//! ```
93136
//! use iceoryx2::prelude::*;

iceoryx2/src/service/port_factory/server.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
//! # Example
1414
//!
15+
//! ## Typed API
16+
//!
1517
//! ```
1618
//! use iceoryx2::prelude::*;
1719
//!
@@ -22,8 +24,10 @@
2224
//! .open_or_create()?;
2325
//!
2426
//! let server = request_response
25-
//! .server_builder()
26-
//! .create()?;
27+
//! .server_builder()
28+
//! // defines behavior when client queue is full in an non-overflowing service
29+
//! .unable_to_deliver_strategy(UnableToDeliverStrategy::DiscardSample)
30+
//! .create()?;
2731
//!
2832
//! # Ok(())
2933
//! # }

0 commit comments

Comments
 (0)