Part 3 : Backend Definition



Several backends are used in the project but we wanted to keep the implementation flexible, so you can easly adjust the Daemon backend to fit your needs.

The defined Backend can adjust :
  • The kind of socket to be used (Unix Socket, ZMQ, NetMQ, RabbitMQ, etc)
  • The kind of clock to be used (clock, chrono, with different precision)
Both backends can be used in three different modes :
  • The normal mode (or NO_MOCK) uses the defined official backend (Unix Socket, ZMQ, NetMQ, RabbitMQ, etc)
  • The mock mode (or MOCK) uses the mock to play a recorded sequence of data (exchange of a socket, time calls to clock, etc)
  • The record mode (or MOCK_RECORD) where the official backend is used but the mock backend is recording what the official backend does


Since we do not want to impose our choices to you, we add Backend to let you choose.

The DaemonEmptyBackend.h is the perfect starting point.

The struct DaemonEmptyBackend defines the backends which are used by the Daemon.
1
2
3
4
5
6
7
8
9
10
11
12
///@brief Simple, default backend of the Daemon to manage Socket and Clock
struct DaemonEmptyBackend{
	///Define the socket backend
	typedef PEmptyBackend SocketBackend;
	///Define the socket mock
	typedef PMockBackend SocketMock;
	
	///Socket manager with no official backend 
	PGenericSocketManager<PString, SocketBackend, SocketMock> socketManager;
	///Clock backend
	PGenericClock<PClockNsBackend, PClockMock> clock;
};


The Socket backend defines the socketManager, here the PEmptyBackend is a dummy backend, which could be replaced by PZmqBackend defined in PhoenixZMQ if you want to use ZMQ. Typedefs SocketBackend and SocketMock are needed by the Daemon to initialise sockets with proper url and ports.

Finally the clock backend uses PClockNsBackend which is the backend of PClockNs, a clock with a nano second precision, so it can run for 60 years