@@ -33,12 +33,12 @@ use tokio_util::sync::CancellationToken;
3333
3434use tracing:: { Instrument , debug} ;
3535
36- use crate :: services:: card:: CardService ;
36+ use crate :: services:: HasAll ;
37+ use crate :: services:: card_interest:: CardInterestIndex ;
3738use crate :: services:: golem_config:: {
3839 AgentStatusFlushConfig , FilesystemStorageConfig , MemoryConfig ,
3940} ;
4041use crate :: services:: resource_limits:: AtomicResourceEntry ;
41- use crate :: services:: { HasAll , HasCardService } ;
4242use crate :: worker:: Worker ;
4343use crate :: worker:: status_flusher:: AgentStatusFlushQueue ;
4444use crate :: workerctx:: WorkerCtx ;
@@ -71,7 +71,7 @@ impl RegisteredConcurrentAccount {
7171/// Holds the metadata and wasmtime structures of currently active Golem workers
7272pub struct ActiveWorkers < Ctx : WorkerCtx > {
7373 workers : Cache < AgentId , ( ) , Arc < Worker < Ctx > > , WorkerExecutorError > ,
74- card_service : Arc < dyn CardService > ,
74+ card_interest_index : Arc < CardInterestIndex > ,
7575 worker_memory : Arc < Semaphore > ,
7676 worker_filesystem_storage : Arc < FilesystemStorageSemaphore > ,
7777 concurrent_agents : Arc < ConcurrentAgentsScheduler > ,
@@ -120,7 +120,6 @@ impl<Ctx: WorkerCtx> ActiveWorkers<Ctx> {
120120 memory_config : & MemoryConfig ,
121121 storage_config : & FilesystemStorageConfig ,
122122 agent_status_flush_config : & AgentStatusFlushConfig ,
123- card_service : Arc < dyn CardService > ,
124123 shutdown_token : CancellationToken ,
125124 ) -> Self {
126125 let worker_memory_size = memory_config. worker_memory ( ) ;
@@ -131,7 +130,7 @@ impl<Ctx: WorkerCtx> ActiveWorkers<Ctx> {
131130 BackgroundEvictionMode :: None ,
132131 "active_workers" ,
133132 ) ,
134- card_service ,
133+ card_interest_index : Arc :: new ( CardInterestIndex :: new ( ) ) ,
135134 worker_memory : Arc :: new ( Semaphore :: new ( worker_memory_size) ) ,
136135 worker_filesystem_storage : Arc :: new ( FilesystemStorageSemaphore :: new (
137136 storage_config. worker_filesystem_storage ( ) ,
@@ -167,7 +166,7 @@ impl<Ctx: WorkerCtx> ActiveWorkers<Ctx> {
167166 principal : Principal ,
168167 ) -> Result < Arc < Worker < Ctx > > , WorkerExecutorError >
169168 where
170- T : HasAll < Ctx > + HasCardService + Clone + Send + Sync + ' static ,
169+ T : HasAll < Ctx > + Clone + Send + Sync + ' static ,
171170 {
172171 let agent_id = owned_agent_id. agent_id ( ) ;
173172
@@ -179,6 +178,7 @@ impl<Ctx: WorkerCtx> ActiveWorkers<Ctx> {
179178 Box :: pin ( async move {
180179 let worker = Worker :: new (
181180 & deps,
181+ self . card_interest_index . clone ( ) ,
182182 owned_agent_id. clone ( ) ,
183183 worker_env,
184184 worker_agent_config,
@@ -203,15 +203,15 @@ impl<Ctx: WorkerCtx> ActiveWorkers<Ctx> {
203203
204204 pub async fn remove ( & self , agent_id : & AgentId ) {
205205 if let Some ( worker) = self . workers . get ( agent_id) . await {
206- self . card_service
206+ self . card_interest_index
207207 . set_card_interest ( worker. owned_agent_id ( ) . clone ( ) , & [ ] )
208208 . await ;
209209 }
210210 self . workers . remove ( agent_id) . await
211211 }
212212
213- pub async fn record_revoked_cards ( & self , card_ids : & [ CardId ] ) {
214- let affected_agent_cards = self . card_service . record_revoked_cards ( card_ids) . await ;
213+ pub async fn notify_revoked_cards ( & self , card_ids : & [ CardId ] ) {
214+ let affected_agent_cards = self . card_interest_index . interested_agents ( card_ids) . await ;
215215
216216 for ( owned_agent_id, affected_card_ids) in affected_agent_cards {
217217 let Some ( worker) = self . try_get ( & owned_agent_id) . await else {
0 commit comments