@@ -99,6 +99,7 @@ mod cfg {
9999
100100 pub ( super ) fn make_config ( params : Params ) -> PrimaryConfig {
101101 PrimaryConfig {
102+ id : AGENT_ID ,
102103 cycle_time : params. feo_cycle_time ,
103104 activity_dependencies : activity_dependencies ( ) ,
104105 // With only one agent, we cannot attach a recorder
@@ -113,51 +114,91 @@ mod cfg {
113114#[ cfg( feature = "signalling_direct_tcp" ) ]
114115mod cfg {
115116 use super :: { check_ids, Duration , Params , AGENT_ID } ;
116- use feo:: agent:: NodeAddress ;
117- use feo:: ids:: AgentId ;
118- use mini_adas:: config:: { activity_dependencies, agent_assignments, BIND_ADDR } ;
119- use std:: collections:: HashSet ;
117+ use feo:: {
118+ agent:: NodeAddress ,
119+ ids:: { ActivityId , AgentId , WorkerId } ,
120+ } ;
121+ use mini_adas:: config:: {
122+ activity_dependencies, agent_assignments, worker_agent_map, BIND_ADDR ,
123+ } ;
124+ use std:: collections:: { HashMap , HashSet } ;
120125
121126 pub ( super ) use feo:: agent:: direct:: primary:: { Primary , PrimaryConfig } ;
122127
123128 pub ( super ) fn make_config ( params : Params ) -> PrimaryConfig {
124129 let agent_ids: HashSet < AgentId > = agent_assignments ( ) . keys ( ) . copied ( ) . collect ( ) ;
125130 check_ids ( & params. recorder_ids , & agent_ids) ;
126131
132+ let activity_worker_map: HashMap < ActivityId , WorkerId > = agent_assignments ( )
133+ . values ( )
134+ . flat_map ( |vec| {
135+ vec. iter ( )
136+ . flat_map ( move |( wid, aid_b) | aid_b. iter ( ) . map ( |v| ( v. 0 , * wid) ) )
137+ } )
138+ . collect ( ) ;
139+
127140 PrimaryConfig {
141+ id : AGENT_ID ,
128142 cycle_time : params. feo_cycle_time ,
129143 activity_dependencies : activity_dependencies ( ) ,
130144 recorder_ids : params. recorder_ids ,
131145 worker_assignments : agent_assignments ( ) . remove ( & AGENT_ID ) . unwrap ( ) ,
132146 timeout : Duration :: from_secs ( 10 ) ,
133147 connection_timeout : Duration :: from_secs ( 10 ) ,
134148 endpoint : NodeAddress :: Tcp ( BIND_ADDR ) ,
149+ activity_agent_map : activity_worker_map
150+ . iter ( )
151+ . map ( |( activity_id, worker_id) | {
152+ let agent_id = worker_agent_map ( ) . get ( worker_id) . copied ( ) . unwrap ( ) ;
153+ ( * activity_id, agent_id)
154+ } )
155+ . collect ( ) ,
135156 }
136157 }
137158}
138159
139160#[ cfg( feature = "signalling_direct_unix" ) ]
140161mod cfg {
141162 use super :: { check_ids, Duration , Params , AGENT_ID } ;
142- use feo:: agent:: NodeAddress ;
143- use feo:: ids:: AgentId ;
144- use mini_adas:: config:: { activity_dependencies, agent_assignments, socket_paths} ;
145- use std:: collections:: HashSet ;
163+ use feo:: {
164+ agent:: NodeAddress ,
165+ ids:: { ActivityId , AgentId , WorkerId } ,
166+ } ;
167+ use mini_adas:: config:: {
168+ activity_dependencies, agent_assignments, socket_paths, worker_agent_map,
169+ } ;
170+ use std:: collections:: { HashMap , HashSet } ;
146171
147172 pub ( super ) use feo:: agent:: direct:: primary:: { Primary , PrimaryConfig } ;
148173
149174 pub ( super ) fn make_config ( params : Params ) -> PrimaryConfig {
150175 let agent_ids: HashSet < AgentId > = agent_assignments ( ) . keys ( ) . copied ( ) . collect ( ) ;
151176 check_ids ( & params. recorder_ids , & agent_ids) ;
152177
178+ let activity_worker_map: HashMap < ActivityId , WorkerId > = agent_assignments ( )
179+ . values ( )
180+ . flat_map ( |vec| {
181+ vec. iter ( )
182+ . flat_map ( move |( wid, aid_b) | aid_b. iter ( ) . map ( |v| ( v. 0 , * wid) ) )
183+ } )
184+ . collect ( ) ;
185+
153186 PrimaryConfig {
187+ id : AGENT_ID ,
154188 cycle_time : params. feo_cycle_time ,
155189 activity_dependencies : activity_dependencies ( ) ,
156190 recorder_ids : params. recorder_ids ,
157191 worker_assignments : agent_assignments ( ) . remove ( & AGENT_ID ) . unwrap ( ) ,
158192 timeout : Duration :: from_secs ( 10 ) ,
159193 connection_timeout : Duration :: from_secs ( 10 ) ,
160194 endpoint : NodeAddress :: UnixSocket ( socket_paths ( ) . 0 ) ,
195+ activity_agent_map : activity_worker_map
196+ . iter ( )
197+ . map ( |( activity_id, worker_id) | {
198+ let agent_id = worker_agent_map ( ) . get ( worker_id) . copied ( ) . unwrap ( ) ;
199+ ( * activity_id, agent_id)
200+ } )
201+ . collect ( ) ,
161202 }
162203 }
163204}
0 commit comments