db575083a2d207fff88febdb0816a9cdf8cbed04
[ric-plt/lib/rmr.git] / docs / developer-guide.rst
1  
2 .. This work is licensed under a Creative Commons Attribution 4.0 International License. 
3 .. SPDX-License-Identifier: CC-BY-4.0 
4 .. CAUTION: this document is generated from source in doc/src/rtd. 
5 .. To make changes edit the source and recompile the document. 
6 .. Do NOT make changes directly to .rst or .md files. 
7  
8  
9 RMR Developer Guide 
10 ============================================================================================ 
11  
12 The RIC Message Router (RMR) is a library for peer-to-peer 
13 communication. Applications use the library to send and 
14 receive messages where the message routing and endpoint 
15 selection is based on the message type rather than DNS host 
16 name-IP port combinations. 
17  
18 This document contains information that developers need to 
19 know to contribute to the RMR project. 
20  
21 Language 
22 -------------------------------------------------------------------------------------------- 
23  
24 RMR is written in C, and thus a contributing developer to the 
25 core library should have an excellent working knowledge of C. 
26 There currently is one set of cross-languages bindings 
27 supporting Python, and a developer wishing to contribute to 
28 the bindings source should be familiar with Python (version 
29 3.7+) and with the Python *ctypes* library. 
30  
31 Code Structure 
32 -------------------------------------------------------------------------------------------- 
33  
34 RMR is designed to provide an insulation layer between user 
35 applications and the actual transport mechanism. Initially 
36 RMR was built on top of the third-party library Nanosmg, 
37 shortly after was ported to the third-party library NNG 
38 (Nanomsg Next Generation), and then was ported to an 
39 internally developed socket library called SI95. RMR presents 
40 the same API to the user application regardless of the 
41 underlying transport library, but the resulting output when 
42 compiling RMR is always a transport-specific library. As an 
43 example, librmr_nng.a is the library generated for use with 
44 the NNG transport. 
45  
46 As such the library source is organised into multiple 
47 components: 
48  
49  
50 common 
51    
52   Source in the common directory is agnostic to the 
53   underlying transport mechanism (Nanomsg, NNG, SI95, ..), 
54   and thus can be used when generating either library. 
55  
56 nano 
57    
58   Source which is tightly coupled with the underlying 
59   Nanomsg library. (Nanomsg has been deprecated, but the RMR 
60   source remains as an example.) 
61  
62 nng 
63    
64   Source which is tightly coupled with the underlying NNG 
65   library. (NNG has been deprecated, but the RMR source 
66   remains as an example.) 
67  
68 si 
69    
70   Source which is tightly coupled with the underlying SI95 
71   library. 
72  
73  
74  
75 Internal Function Exposure 
76 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
77  
78 The decision to limit as much as practical the exposure of 
79 truly internal RMR functions was made, and as a result most 
80 of the RMR functions carry a static label. In order to 
81 modularise the code as much as possible, this means that the 
82 primary module (e.g. rmr_nng.c) directly includes other RMR 
83 modules, rather than depending on referencing the internal 
84 functions during linking. While this is an infrequently used 
85 approach, it does mean that there are very few functions 
86 visible for the user application to reference, all of them 
87 having the prefix rmr\_. This allows internal functions to 
88 have shorter names while still being meaningful. 
89  
90 Coding Style 
91 -------------------------------------------------------------------------------------------- 
92  
93 There is a list of coding style guidelines in the top level 
94 directory, and as such they are not expanded upon here. The 
95 general practice is to follow the style when editing an 
96 existing module, respect the author's choice where style 
97 alternatives are not frowned upon. When creating new modules, 
98 select a style that fits the guidelines and is easy for you 
99 to work with. There are a few things that the RMR maintainers 
100 insist on, but for the most part style is up to the creator 
101 of a module. 
102  
103 Building 
104 -------------------------------------------------------------------------------------------- 
105  
106 RMR is constructed using CMake. While CMake's project 
107 description can be more cumbersome than most typical 
108 Makefiles, the tool provides convenience especially when it 
109 comes to creating DEB/RPM packages.