Skip to content

Commit 58853ee

Browse files
Cleanup IceStorm/clock demo (#261)
1 parent 03416b8 commit 58853ee

File tree

11 files changed

+293
-355
lines changed

11 files changed

+293
-355
lines changed

swift/IceStorm/clock/README.md

Lines changed: 58 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,131 @@
1-
Overview
2-
========
1+
# IceStorm Clock
2+
3+
## Overview
34

45
This demo shows how to use [IceStorm][1].
56

67
To run the demo, start the IceStorm service:
78

8-
```
9+
```shell
910
icebox --Ice.Config=config.icebox
1011
```
1112

12-
This configuration assumes there is a subdirectory named db in the
13-
current working directory.
13+
This configuration assumes there is a subdirectory named db in the current working directory.
1414

1515
In a separate window:
1616

17-
```
18-
./Build/subscriber
17+
```shell
18+
swift run Subscriber
1919
```
2020

2121
In another window:
2222

23-
```
24-
./Build/publisher
23+
```shell
24+
swift run Publisher
2525
```
2626

27-
While the publisher continues to run, "tick" messages should be
28-
displayed in the subscriber window.
27+
While the publisher continues to run, "tick" messages should be displayed in the subscriber window.
2928

30-
Options
31-
=======
29+
## Options
3230

33-
Both the subscriber and publisher take an optional topic name as a
34-
final argument. The default value for this topic is "time".
31+
Both the subscriber and publisher take an optional topic name as a final argument. The default value for this topic
32+
is "time".
3533

36-
Through the use of command-line options, both the subscriber and
37-
publisher can use different QoS for sending and receiving messages.
34+
Through the use of command-line options, both the subscriber and publisher can use different QoS for sending and
35+
receiving messages.
3836

39-
Subscriber Options
40-
------------------
37+
## Subscriber Options
4138

42-
```
43-
./Build/subscriber --oneway
39+
```shell
40+
swift run Subscriber --oneway
4441
```
4542

46-
The subscriber receives events as oneway messages. This is the
47-
default.
43+
The subscriber receives events as oneway messages. This is the default.
4844

49-
```
50-
./Build/subscriber --datagram
45+
```shell
46+
swift run Subscriber --datagram
5147
```
5248

5349
The subscriber receives events as datagrams.
5450

55-
```
56-
./Build/subscriber --twoway
51+
```shell
52+
swift run Subscriber --twoway
5753
```
5854

5955
The subscriber receives events as twoway messages.
6056

61-
```
62-
./Build/subscriber --ordered
57+
```shell
58+
swift run Subscriber --ordered
6359
```
6460

65-
The subscriber receives events as twoway messages with guaranteed
66-
ordering.
61+
The subscriber receives events as twoway messages with guaranteed ordering.
6762

68-
```
69-
./Build/subscriber --batch
63+
```shell
64+
swift run Subscriber --batch
7065
```
7166

72-
This is an additional flag that forwards datagram and oneway events
73-
to the subscriber in batches.
67+
This is an additional flag that forwards datagram and oneway events to the subscriber in batches.
7468

75-
```
76-
./Build/subscriber --id <id>
69+
```shell
70+
swift run Subscriber --id <id>
7771
```
7872

79-
This option specifies a unique identity for this subscriber. When
80-
you use this option, you should also run the subscriber on a fixed
81-
port by setting the `Clock.Subscriber.Endpoints` property. For
82-
example:
73+
This option specifies a unique identity for this subscriber. When you use this option, you should also run the
74+
subscriber on a fixed port by setting the `Clock.Subscriber.Endpoints` property. For example:
8375

84-
```
85-
./Build/subscriber --Clock.Subscriber.Endpoints="tcp -p <port> -h <host>"
76+
```shell
77+
swift run Subscriber --Clock.Subscriber.Endpoints="tcp -p <port>"
8678
```
8779

8880
Replace "tcp" with "udp" when using the --datagram option.
8981

90-
```
91-
./Build/subscriber --retryCount <count>
82+
```shell
83+
swift run Subscriber --retryCount <count>
9284
```
9385

94-
This option sets the retry count for a subscriber. This option
95-
should be used in conjunction with the --id option. Setting
96-
retryCount changes the default subscriber QoS to twoway.
86+
This option sets the retry count for a subscriber. This option should be used in conjunction with the --id option.
87+
Setting retryCount changes the default subscriber QoS to twoway.
9788

98-
Publisher Options
99-
-----------------
89+
## Publisher Options
10090

101-
```
102-
./Build/publisher --oneway
91+
```shell
92+
swift run Publisher --oneway
10393
```
10494

10595
The publisher sends events as oneway messages. This is the default.
10696

107-
```
108-
./Build/publisher --datagram
97+
```shell
98+
swift run Publisher --datagram
10999
```
110100

111101
The publisher sends events as datagrams.
112102

113-
```
114-
./Build/publisher --twoway
103+
```shell
104+
swift run Publisher --twoway
115105
```
116106

117107
The publisher sends events as twoway messages.
118108

119-
Running the demo on several hosts
120-
=================================
109+
## Running the demo on several hosts
121110

122-
You must modify several configuration files in order to run the
123-
publisher, subscriber, and IceStorm service on separate hosts. For
124-
the sake of discussion, let us assume that the processes are running
125-
on the following hosts:
111+
You must modify several configuration files in order to run the publisher, subscriber, and IceStorm service on
112+
separate hosts. Let us assume that IceStorm is running on host `<I>`. Replace `<I>` with the appropriate hostname or
113+
IP address in the steps below:
126114

127-
- Host `<P>`: publisher
128-
- Host `<S>`: subscriber
129-
- Host `<I>`: IceStorm
115+
1. Edit the subscriber's configuration file, `config.sub`, and change the `TopicManager.Proxy` property to
130116

131-
Replace `<P>`, `<S>`, and `<I>` with the appropriate host names or IP
132-
addresses in the steps below:
133-
134-
1. Edit the subscriber's configuration file, `config.sub`, and change
135-
the `TopicManager.Proxy` property to
136-
```
117+
```text
137118
TopicManager.Proxy=DemoIceStorm/TopicManager:default -h <I> -p 10000
138119
```
139120

140-
2. Edit the publisher's configuration file, `Publisher/config.pub`, and change
141-
the `TopicManager.Proxy` property to
142-
```
143-
TopicManager.Proxy=DemoIceStorm/TopicManager:default -h <I> -p 10000
144-
```
121+
2. Edit the publisher's configuration file, `config.pub`, and change the `TopicManager.Proxy` property to
145122

146-
3. Since the default configurations for the subscriber and IceStorm
147-
endpoints listen only to localhost, you must also modify the Endpoints
148-
properties to explicitly include the host machine's name or IP
149-
address.
150-
151-
In `Subscriber/config.sub`:
152-
```
153-
Clock.Subscriber.Endpoints=tcp -h <S>:udp -h <S>
154-
```
155-
156-
In `config.service`:
157-
```
158-
IceStorm.TopicManager.Endpoints=default -h <I> -p 10000
159-
IceStorm.Publish.Endpoints=tcp -h <I> -p 10001:udp -h <I> -p 10001
123+
```text
124+
TopicManager.Proxy=DemoIceStorm/TopicManager:default -h <I> -p 10000
160125
```
161126

162-
If you experience any network delays or errors, edit all of the
163-
configuration files and enable the `Ice.Trace.Network` property. Running
164-
the processes with this property enabled displays a log of Ice's
165-
network activity and may help you to identify the problem more
166-
quickly.
127+
If you experience any network delays or errors, edit all of the configuration files and enable the `Ice.Trace.Network`
128+
property. Running the processes with this property enabled displays a log of Ice's network activity and may help you to
129+
identify the problem more quickly.
167130

168131
[1]: https://doc.zeroc.com/ice/3.7/ice-services/icestorm
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) ZeroC, Inc.
2+
3+
#pragma once
4+
5+
module Demo
6+
{
7+
/// The interface implemented by the subscriber. It accepts time updates.
8+
interface Clock
9+
{
10+
/// Sends the current time to the clock.
11+
/// @param time The current time.
12+
void tick(string time);
13+
}
14+
}

0 commit comments

Comments
 (0)