1 /*********************************************************************************************************************************** 2 Protocol Helper 3 ***********************************************************************************************************************************/ 4 #ifndef PROTOCOL_HELPER_H 5 #define PROTOCOL_HELPER_H 6 7 #include "common/type/stringId.h" 8 9 /*********************************************************************************************************************************** 10 Protocol storage type enum 11 ***********************************************************************************************************************************/ 12 typedef enum 13 { 14 protocolStorageTypePg = STRID5("pg", 0xf00), 15 protocolStorageTypeRepo = STRID5("repo", 0x7c0b20), 16 } ProtocolStorageType; 17 18 #include "protocol/client.h" 19 20 /*********************************************************************************************************************************** 21 Constants 22 ***********************************************************************************************************************************/ 23 #define PROTOCOL_SERVICE_LOCAL "local" 24 STRING_DECLARE(PROTOCOL_SERVICE_LOCAL_STR); 25 #define PROTOCOL_SERVICE_REMOTE "remote" 26 STRING_DECLARE(PROTOCOL_SERVICE_REMOTE_STR); 27 28 /*********************************************************************************************************************************** 29 Getters/Setters 30 ***********************************************************************************************************************************/ 31 // Is pg local? 32 bool pgIsLocal(unsigned int pgIdx); 33 34 // Error if PostgreSQL is not local, i.e. pg-host is set 35 void pgIsLocalVerify(void); 36 37 // Is the repository local? 38 bool repoIsLocal(unsigned int repoIdx); 39 40 // Error if the repository is not local 41 void repoIsLocalVerify(void); 42 void repoIsLocalVerifyIdx(unsigned int repoIdx); 43 44 /*********************************************************************************************************************************** 45 Functions 46 ***********************************************************************************************************************************/ 47 // Send keepalives to all remotes 48 void protocolKeepAlive(void); 49 50 // Local protocol client 51 ProtocolClient *protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostId, unsigned int protocolId); 52 53 // Free (shutdown) a local 54 void protocolLocalFree(unsigned int protocolId); 55 56 // Remote protocol client 57 ProtocolClient *protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId); 58 59 // Free (shutdown) a remote 60 void protocolRemoteFree(unsigned int hostId); 61 62 /*********************************************************************************************************************************** 63 Destructor 64 ***********************************************************************************************************************************/ 65 void protocolFree(void); 66 67 #endif 68