1- use apollo_http_server_config:: config:: HTTP_SERVER_PORT ;
2- use apollo_monitoring_endpoint_config:: config:: MONITORING_ENDPOINT_DEFAULT_PORT ;
31use apollo_node_config:: component_execution_config:: DEFAULT_INVALID_PORT ;
4- use serde:: { Deserialize , Serialize } ;
2+ use serde:: Serialize ;
53use static_assertions:: const_assert_ne;
6- use strum:: { EnumDiscriminants , EnumIter , IntoEnumIterator } ;
4+ use strum:: EnumIter ;
75use strum_macros:: { AsRefStr , Display } ;
86
97#[ cfg( test) ]
108#[ path = "deployment_definitions_test.rs" ]
119mod deployment_definitions_test;
1210
13- // TODO(Tsabary): check if these ports are required.
14- pub ( crate ) const CONSENSUS_P2P_PORT : u16 = 53080 ;
15- pub ( crate ) const MEMPOOL_P2P_PORT : u16 = 53200 ;
16-
1711pub ( crate ) const CONFIG_BASE_DIR : & str = "crates/apollo_deployments/resources/" ;
18-
19- const BASE_APP_CONFIGS_DIR_PATH : & str = "crates/apollo_deployments/resources/app_configs" ;
20-
2112pub ( crate ) const INFRA_PORT_PLACEHOLDER : u16 = 1 ;
2213const_assert_ne ! ( INFRA_PORT_PLACEHOLDER , DEFAULT_INVALID_PORT ) ;
2314
24- #[ derive( Clone , Debug , Serialize , PartialEq ) ]
25- pub struct StateSyncConfig {
26- #[ serde( rename = "state_sync_config.central_sync_client_config.#is_none" ) ]
27- state_sync_config_central_sync_client_config_is_none : bool ,
28- #[ serde( rename = "state_sync_config.p2p_sync_client_config.#is_none" ) ]
29- state_sync_config_p2p_sync_client_config_is_none : bool ,
30- #[ serde( rename = "state_sync_config.network_config.#is_none" ) ]
31- state_sync_config_network_config_is_none : bool ,
32- }
33-
34- #[ derive( Clone , Debug , Serialize , Deserialize ) ]
35- pub enum StateSyncType {
36- Central ,
37- P2P ,
38- }
39-
40- impl StateSyncType {
41- pub fn get_state_sync_config ( & self ) -> StateSyncConfig {
42- match self {
43- StateSyncType :: Central => StateSyncConfig {
44- state_sync_config_central_sync_client_config_is_none : false ,
45- state_sync_config_p2p_sync_client_config_is_none : true ,
46- state_sync_config_network_config_is_none : true ,
47- } ,
48- StateSyncType :: P2P => StateSyncConfig {
49- state_sync_config_central_sync_client_config_is_none : true ,
50- state_sync_config_p2p_sync_client_config_is_none : false ,
51- state_sync_config_network_config_is_none : false ,
52- } ,
53- }
54- }
55- }
56-
57- #[ derive( Clone , Copy , Debug , EnumIter , Display , Serialize , Ord , PartialEq , Eq , PartialOrd ) ]
58- pub enum BusinessLogicServicePort {
59- ConsensusP2p ,
60- HttpServer ,
61- MempoolP2p ,
62- MonitoringEndpoint ,
63- }
64-
65- impl BusinessLogicServicePort {
66- pub fn get_port ( & self ) -> u16 {
67- match self {
68- BusinessLogicServicePort :: ConsensusP2p => CONSENSUS_P2P_PORT ,
69- BusinessLogicServicePort :: HttpServer => HTTP_SERVER_PORT ,
70- BusinessLogicServicePort :: MempoolP2p => MEMPOOL_P2P_PORT ,
71- BusinessLogicServicePort :: MonitoringEndpoint => MONITORING_ENDPOINT_DEFAULT_PORT ,
72- }
73- }
74- }
75-
76- // TODO(Tsabary): check if the InfraServicePort and BusinessLogicServicePort enums are needed.
15+ const BASE_APP_CONFIGS_DIR_PATH : & str = "crates/apollo_deployments/resources/app_configs" ;
7716
7817// TODO(Nadin): Integrate this logic with `ComponentConfigInService` once the merge from main-14.0
7918// is complete.
19+
8020#[ derive( Clone , Copy , Debug , EnumIter , Display , Serialize , Ord , PartialEq , Eq , PartialOrd ) ]
8121pub enum InfraServicePort {
8222 Batcher ,
@@ -97,39 +37,6 @@ impl InfraServicePort {
9737 }
9838}
9939
100- #[ derive( Clone , Copy , Debug , Display , Ord , PartialEq , Eq , PartialOrd , EnumDiscriminants ) ]
101- pub enum ServicePort {
102- Infra ( InfraServicePort ) ,
103- BusinessLogic ( BusinessLogicServicePort ) ,
104- }
105-
106- impl serde:: Serialize for ServicePort {
107- fn serialize < S > ( & self , serializer : S ) -> std:: result:: Result < S :: Ok , S :: Error >
108- where
109- S : serde:: Serializer ,
110- {
111- match self {
112- ServicePort :: Infra ( port) => serde:: Serialize :: serialize ( port, serializer) ,
113- ServicePort :: BusinessLogic ( port) => serde:: Serialize :: serialize ( port, serializer) ,
114- }
115- }
116- }
117-
118- impl ServicePort {
119- pub fn get_port ( & self ) -> u16 {
120- match self {
121- ServicePort :: Infra ( inner) => inner. get_port ( ) ,
122- ServicePort :: BusinessLogic ( inner) => inner. get_port ( ) ,
123- }
124- }
125-
126- pub fn iter ( ) -> impl Iterator < Item = ServicePort > {
127- InfraServicePort :: iter ( )
128- . map ( ServicePort :: Infra )
129- . chain ( BusinessLogicServicePort :: iter ( ) . map ( ServicePort :: BusinessLogic ) )
130- }
131- }
132-
13340#[ derive(
13441 Hash , Clone , Debug , Display , Serialize , PartialEq , Eq , PartialOrd , Ord , EnumIter , AsRefStr ,
13542) ]
0 commit comments