@@ -37,7 +37,7 @@ pub struct Workload {
3737 pub domain : String ,
3838 pub last_reported_event : Option < String > ,
3939 #[ sqlx( json) ]
40- pub heartbeats : Option < WorkloadHeartbeats > ,
40+ pub heartbeat : Option < WorkloadHeartbeat > ,
4141}
4242
4343impl Workload {
@@ -73,7 +73,7 @@ impl fmt::Debug for Workload {
7373 enabled : running,
7474 docker_credentials,
7575 last_reported_event,
76- heartbeats ,
76+ heartbeat ,
7777 } = self ;
7878 // Hide this one since it can have sensitive data
7979 let environment_variables: BTreeMap < _ , _ > = env_vars. keys ( ) . map ( |key| ( key, "..." ) ) . collect ( ) ;
@@ -94,14 +94,14 @@ impl fmt::Debug for Workload {
9494 . field ( "running" , running)
9595 . field ( "docker_credentials" , docker_credentials)
9696 . field ( "last_reported_event" , last_reported_event)
97- . field ( "heartbeats " , heartbeats )
97+ . field ( "heartbeat " , heartbeat )
9898 . finish ( )
9999 }
100100}
101101
102102#[ serde_as]
103103#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
104- pub struct WorkloadHeartbeats {
104+ pub struct WorkloadHeartbeat {
105105 #[ serde_as( as = "Option<Hex>" ) ]
106106 pub wallet_public_key : Option < Vec < u8 > > ,
107107
@@ -135,10 +135,10 @@ pub trait WorkloadRepository: Send + Sync {
135135 async fn set_enabled ( & mut self , id : Uuid , value : bool ) -> Result < ( ) , WorkloadRepositoryError > ;
136136
137137 /// Set the `heartbeats` column for a workload.
138- async fn set_heartbeats (
138+ async fn set_heartbeat (
139139 & mut self ,
140140 id : Uuid ,
141- heartbeats : Option < WorkloadHeartbeats > ,
141+ heartbeats : Option < WorkloadHeartbeat > ,
142142 ) -> Result < ( ) , WorkloadRepositoryError > ;
143143
144144 /// Set the `gpus` column for a workload.
@@ -221,7 +221,7 @@ INSERT INTO workloads (
221221 ports,
222222 domain,
223223 last_reported_event,
224- heartbeats ,
224+ heartbeat ,
225225 enabled,
226226 created_at
227227)
@@ -244,7 +244,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $
244244 domain,
245245 last_reported_event,
246246 enabled,
247- heartbeats ,
247+ heartbeat ,
248248 } = workload;
249249
250250 sqlx:: query ( query)
@@ -263,7 +263,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $
263263 . bind ( sqlx:: types:: Json ( ports) )
264264 . bind ( domain)
265265 . bind ( last_reported_event)
266- . bind ( sqlx:: types:: Json ( heartbeats ) )
266+ . bind ( sqlx:: types:: Json ( heartbeat ) )
267267 . bind ( enabled)
268268 . bind ( Utc :: now ( ) )
269269 . execute ( & mut * self . ctx )
@@ -299,13 +299,13 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $
299299 Ok ( ( ) )
300300 }
301301
302- async fn set_heartbeats (
302+ async fn set_heartbeat (
303303 & mut self ,
304304 id : Uuid ,
305- heartbeats : Option < WorkloadHeartbeats > ,
305+ heartbeat : Option < WorkloadHeartbeat > ,
306306 ) -> Result < ( ) , WorkloadRepositoryError > {
307- let query = "UPDATE workloads SET heartbeats = ? WHERE id = ?" ;
308- sqlx:: query ( query) . bind ( sqlx:: types:: Json ( heartbeats ) ) . bind ( id) . execute ( & mut * self . ctx ) . await ?;
307+ let query = "UPDATE workloads SET heartbeat = ? WHERE id = ?" ;
308+ sqlx:: query ( query) . bind ( sqlx:: types:: Json ( heartbeat ) ) . bind ( id) . execute ( & mut * self . ctx ) . await ?;
309309 Ok ( ( ) )
310310 }
311311
@@ -368,7 +368,7 @@ mod tests {
368368 domain : "example.com" . into ( ) ,
369369 last_reported_event : None ,
370370 enabled : true ,
371- heartbeats : None ,
371+ heartbeat : None ,
372372 } ;
373373 repo. create ( & workload) . await . expect ( "failed to insert" ) ;
374374
@@ -385,15 +385,15 @@ mod tests {
385385 repo. set_enabled ( workload. id , false ) . await . expect ( "failed to update" ) ;
386386 assert_eq ! ( repo. find( workload. id) . await . expect( "failed to find" ) . enabled, false ) ;
387387
388- repo. set_heartbeats (
388+ repo. set_heartbeat (
389389 workload. id ,
390- Some ( WorkloadHeartbeats { wallet_public_key : Some ( vec ! [ 1 , 2 , 3 ] ) , measurement_hash_url : "a" . into ( ) } ) ,
390+ Some ( WorkloadHeartbeat { wallet_public_key : Some ( vec ! [ 1 , 2 , 3 ] ) , measurement_hash_url : "a" . into ( ) } ) ,
391391 )
392392 . await
393393 . expect ( "failed to update" ) ;
394394 assert_eq ! (
395- repo. find( workload. id) . await . expect( "failed to find" ) . heartbeats ,
396- Some ( WorkloadHeartbeats { wallet_public_key: Some ( vec![ 1 , 2 , 3 ] ) , measurement_hash_url: "a" . into( ) } )
395+ repo. find( workload. id) . await . expect( "failed to find" ) . heartbeat ,
396+ Some ( WorkloadHeartbeat { wallet_public_key: Some ( vec![ 1 , 2 , 3 ] ) , measurement_hash_url: "a" . into( ) } )
397397 ) ;
398398
399399 repo. set_gpus ( workload. id , & [ "cc:dd" . into ( ) ] ) . await . expect ( "failed to update" ) ;
0 commit comments