Skip to content

Commit e2230be

Browse files
committed
sp: hub: Introduce hub proto
Add hub protocol. Protocol with star topology and send/receive guarantees. Protocol is compatible with pair0
1 parent cf8f5c6 commit e2230be

File tree

11 files changed

+1227
-0
lines changed

11 files changed

+1227
-0
lines changed

cmake/NNGOptions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
22
# Copyright 2020 Staysail Systems, Inc. <[email protected]>
3+
# Copyright 2022 Cogent Embedded, Inc.
34
#
45
# This software is supplied under the terms of the MIT License, a
56
# copy of which should be located in the distribution where this
@@ -46,6 +47,9 @@ mark_as_advanced(NNG_ENABLE_STATS)
4647
option (NNG_PROTO_BUS0 "Enable BUSv0 protocol." ON)
4748
mark_as_advanced(NNG_PROTO_BUS0)
4849

50+
option (NNG_PROTO_HUB0 "Enable HUBv0 protocol." ON)
51+
mark_as_advanced(NNG_PROTO_HUB0)
52+
4953
option (NNG_PROTO_PAIR0 "Enable PAIRv0 protocol." ON)
5054
mark_as_advanced(NNG_PROTO_PAIR0)
5155

docs/man/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ if (NNG_ENABLE_DOC)
8282
nng_aio_wait
8383
nng_alloc
8484
nng_bus_open
85+
nng_hub_open
8586
nng_close
8687
nng_ctx_close
8788
nng_ctx_get
@@ -379,6 +380,7 @@ if (NNG_ENABLE_DOC)
379380
set(NNG_MAN7
380381
nng
381382
nng_bus
383+
nng_hub
382384
nng_inproc
383385
nng_ipc
384386
nng_pair

docs/man/libnng.3.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Copyright 2018 Capitar IT Group BV <[email protected]>
55
// Copyright 2019 Devolutions <[email protected]>
66
// Copyright 2020 Dirac Research <[email protected]>
7+
// Copyright 2022 Cogent Embedded, Inc.
78
//
89
// This document is supplied under the terms of the MIT License, a
910
// copy of which should be located in the distribution where this
@@ -193,6 +194,7 @@ The following functions are used to construct a socket with a specific protocol:
193194

194195
|===
195196
|xref:nng_bus_open.3.adoc[nng_bus_open()]|open a bus socket
197+
|xref:nng_hub_open.3.adoc[nng_hub_open()]|open a hub socket
196198
|xref:nng_pair_open.3.adoc[nng_pair_open()]|open a pair socket
197199
|xref:nng_pub_open.3.adoc[nng_pub_open()]|open a pub socket
198200
|xref:nng_pull_open.3.adoc[nng_pull_open()]|open a pull socket

docs/man/nng.7.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
= nng(7)
22
//
3+
// Copyright 2022 Cogent Embedded, Inc.
34
// Copyright 2019 Staysail Systems, Inc. <[email protected]>
45
// Copyright 2018 Capitar IT Group BV <[email protected]>
56
//
@@ -54,6 +55,7 @@ other languages please check the http://nanomsg.org/[website].
5455

5556
[horizontal]
5657
xref:nng_bus.7.adoc[nng_bus(7)]:: Bus protocol
58+
xref:nng_hub.7.adoc[nng_hub(7)]:: Hub protocol
5759
xref:nng_pair.7.adoc[nng_pair(7)]:: Pair protocol
5860
xref:nng_pub.7.adoc[nng_pub(7)]:: Publisher side of publish/subscribe protocol
5961
xref:nng_pull.7.adoc[nng_pull(7)]:: Pull side of pipeline protocol

docs/man/nng_hub.7.adoc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
= nng_hub(7)
2+
//
3+
// Copyright 2022 Cogent Embedded, Inc.
4+
//
5+
// This document is supplied under the terms of the MIT License, a
6+
// copy of which should be located in the distribution where this
7+
// file was obtained (LICENSE.txt). A copy of the license may also be
8+
// found online at https://opensource.org/licenses/MIT.
9+
//
10+
11+
== NAME
12+
13+
nng_hub - hub protocol
14+
15+
== SYNOPSIS
16+
17+
[source,c]
18+
----
19+
#include <nng/protocol/hub0/hub.h>
20+
----
21+
22+
== DESCRIPTION
23+
24+
(((protocol, _hub_)))
25+
The ((_hub_ protocol)) provides for building star networks where
26+
all peers are connected to one peer.
27+
In this protocol, each message sent by a node is sent to every one of
28+
its directly connected peers.
29+
30+
All message delivery in this pattern is guaranteed.
31+
32+
This protocol is compatible with pair0
33+
34+
=== Socket Operations
35+
36+
The xref:nng_hub_open.3.adoc[`nng_hub0_open()`] functions create a hub socket.
37+
This socket may be used to send and receive messages.
38+
Sending messages will attempt to deliver to each connected peer.
39+
40+
=== Protocol Versions
41+
42+
Only version 0 of this protocol is supported.
43+
(At the time of writing, no other versions of this protocol have been defined.)
44+
45+
=== Protocol Options
46+
47+
The _hub_ protocol has no protocol-specific options.
48+
49+
=== Protocol Headers
50+
51+
No message headers are present.
52+
53+
== SEE ALSO
54+
55+
[.text-left]
56+
xref:nng_hub_open.3.adoc[nng_hub_open(3)],
57+
xref:nng_pair.7.adoc[nng_pair],
58+
xref:nng.7.adoc[nng(7)]

docs/man/nng_hub_open.3.adoc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
= nng_hub_open(3)
2+
//
3+
// Copyright 2022 Cogent Embedded, Inc.
4+
//
5+
// This document is supplied under the terms of the MIT License, a
6+
// copy of which should be located in the distribution where this
7+
// file was obtained (LICENSE.txt). A copy of the license may also be
8+
// found online at https://opensource.org/licenses/MIT.
9+
//
10+
11+
== NAME
12+
13+
nng_hub_open - create hub socket
14+
15+
== SYNOPSIS
16+
17+
[source,c]
18+
----
19+
#include <nng/nng.h>
20+
#include <nng/protocol/hub0/hub.h>
21+
22+
int nng_hub0_open(nng_socket *s);
23+
----
24+
25+
== DESCRIPTION
26+
27+
The `nng_hub0_open()` function creates a xref:nng_hub.7.adoc[_hub_] version 0
28+
xref:nng_socket.5.adoc[socket] and returns it at the location pointed to by _s_.
29+
30+
== RETURN VALUES
31+
32+
These functions return 0 on success, and non-zero otherwise.
33+
34+
== ERRORS
35+
36+
[horizontal]
37+
`NNG_ENOMEM`:: Insufficient memory is available.
38+
`NNG_ENOTSUP`:: The protocol is not supported.
39+
40+
== SEE ALSO
41+
42+
[.text-left]
43+
xref:nng_socket.5.adoc[nng_socket(5)],
44+
xref:nng_hub.7.adoc[nng_hub(7)],
45+
xref:nng.7.adoc[nng(7)]

include/nng/protocol/hub0/hub.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// Copyright 2022 Cogent Embedded, Inc.
3+
//
4+
// This software is supplied under the terms of the MIT License, a
5+
// copy of which should be located in the distribution where this
6+
// file was obtained (LICENSE.txt). A copy of the license may also be
7+
// found online at https://opensource.org/licenses/MIT.
8+
//
9+
#ifndef NNG_PROTOCOL_HUB0_HUB_H
10+
#define NNG_PROTOCOL_HUB0_HUB_H
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
#define NNG_HUB0_SELF 0x10
17+
#define NNG_HUB0_PEER 0x10
18+
#define NNG_HUB0_SELF_NAME "hub"
19+
#define NNG_HUB0_PEER_NAME "hub"
20+
21+
NNG_DECL int nng_hub0_open(nng_socket *);
22+
23+
#ifndef nng_hub_open
24+
#define nng_hub_open nng_hub0_open
25+
#endif
26+
27+
#ifdef __cplusplus
28+
}
29+
#endif
30+
31+
#endif /* NNG_PROTOCOL_HUB0_HUB_H_ */

src/sp/protocol/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
22
# Copyright 2020 Staysail Systems, Inc. <[email protected]>
3+
# Copyright 2022 Cogent Embedded, Inc.
34
#
45
# This software is supplied under the terms of the MIT License, a
56
# copy of which should be located in the distribution where this
@@ -11,6 +12,7 @@
1112
nng_directory(protocol)
1213

1314
add_subdirectory(bus0)
15+
add_subdirectory(hub0)
1416
add_subdirectory(pair0)
1517
add_subdirectory(pair1)
1618
add_subdirectory(pipeline0)

src/sp/protocol/hub0/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright 2022 Cogent Embedded, Inc.
3+
#
4+
# This software is supplied under the terms of the MIT License, a
5+
# copy of which should be located in the distribution where this
6+
# file was obtained (LICENSE.txt). A copy of the license may also be
7+
# found online at https://opensource.org/licenses/MIT.
8+
#
9+
10+
nng_directory(hub0)
11+
12+
nng_sources_if(NNG_PROTO_HUB0 hub.c)
13+
nng_headers_if(NNG_PROTO_HUB0 nng/protocol/hub0/hub.h)
14+
nng_defines_if(NNG_PROTO_HUB0 NNG_HAVE_HUB0)
15+
16+
nng_test(hub_test)

0 commit comments

Comments
 (0)