@@ -15,7 +15,6 @@ use sift_rs::ingestion_configs::v2::{ingestion_config_service_server::IngestionC
1515use sift_rs:: ping:: v1:: { PingRequest , PingResponse , ping_service_server:: PingService } ;
1616use std:: io:: stdout;
1717use std:: sync:: atomic:: AtomicBool ;
18- use std:: time:: Duration ;
1918use std:: {
2019 collections:: HashMap ,
2120 sync:: {
@@ -25,6 +24,7 @@ use std::{
2524} ;
2625use tokio:: sync:: mpsc:: Sender ;
2726use tokio:: sync:: watch;
27+ use tokio:: time:: Duration ;
2828use tokio_stream:: StreamExt ;
2929use tonic:: { Request , Response , Status , Streaming } ;
3030use uuid:: Uuid ;
@@ -61,7 +61,9 @@ impl TestServer {
6161 shutdown : & mut watch:: Receiver < bool > ,
6262 metrics_tx : Sender < Metrics > ,
6363 streaming_enabled : bool ,
64+ plain_output : bool ,
6465 ) -> AnyhowResult < ( ) > {
66+ let mut interval = tokio:: time:: interval ( Duration :: from_secs ( 1 ) ) ;
6567 let mut stdout = stdout ( ) ;
6668
6769 let mut last_total_num_bytes_read: u64 = 0 ;
@@ -75,7 +77,7 @@ impl TestServer {
7577 return AnyhowOk ( ( ) ) ;
7678 }
7779
78- _ = tokio :: time :: sleep ( Duration :: from_secs ( 1 ) ) => {
80+ _ = interval . tick ( ) => {
7981 let current_total_num_bytes_read = self . total_num_bytes_read. load( Relaxed ) ;
8082 let current_total_num_messages = self . total_num_messages. load( Relaxed ) ;
8183 let current_total_num_streams = self . total_num_streams. load( Relaxed ) ;
@@ -85,16 +87,21 @@ impl TestServer {
8587 last_total_num_bytes_read = current_total_num_bytes_read;
8688 last_total_num_messages = current_total_num_messages;
8789
88- // Clear terminal and print metrics.
89- stdout
90- . execute( terminal:: Clear ( terminal:: ClearType :: All ) )
91- . context( "failed to clear terminal" ) ?;
92- stdout. execute( cursor:: MoveTo ( 0 , 0 ) )
93- . context( "failed to move terminal cursor" ) ?;
94- stdout. execute( cursor:: MoveUp ( 5 ) )
95- . context( "failed to move terminal cursor" ) ?;
96- stdout. execute( terminal:: Clear ( terminal:: ClearType :: FromCursorDown ) )
97- . context( "failed to move terminal cursor" ) ?;
90+ if !plain_output {
91+ // Clear terminal and print metrics.
92+ stdout
93+ . execute( terminal:: Clear ( terminal:: ClearType :: All ) )
94+ . context( "failed to clear terminal" ) ?;
95+ stdout. execute( cursor:: MoveTo ( 0 , 0 ) )
96+ . context( "failed to move terminal cursor" ) ?;
97+ stdout. execute( cursor:: MoveUp ( 5 ) )
98+ . context( "failed to move terminal cursor" ) ?;
99+ stdout. execute( terminal:: Clear ( terminal:: ClearType :: FromCursorDown ) )
100+ . context( "failed to move terminal cursor" ) ?;
101+ } else {
102+ Output :: new( ) . line( format!( "-----" ) ) . print( ) ;
103+ Output :: new( ) . line( format!( "{}" , chrono:: Local :: now( ) . to_rfc3339( ) ) ) . print( ) ;
104+ }
98105
99106 Output :: new( ) . line( format!( "Total num streams: {current_total_num_streams}" ) ) . print( ) ;
100107 Output :: new( ) . line( format!( "Total num bytes: {current_total_num_bytes_read}" ) ) . print( ) ;
@@ -159,9 +166,7 @@ impl AssetService for TestServer {
159166 & self ,
160167 _request : Request < sift_rs:: assets:: v1:: DeleteAssetRequest > ,
161168 ) -> Result < Response < sift_rs:: assets:: v1:: DeleteAssetResponse > , Status > {
162- Ok ( Response :: new (
163- sift_rs:: assets:: v1:: DeleteAssetResponse :: default ( ) ,
164- ) )
169+ unimplemented ! ( )
165170 }
166171
167172 /// No-op.
@@ -179,19 +184,15 @@ impl AssetService for TestServer {
179184 & self ,
180185 _request : Request < sift_rs:: assets:: v1:: UpdateAssetRequest > ,
181186 ) -> Result < Response < sift_rs:: assets:: v1:: UpdateAssetResponse > , Status > {
182- Ok ( Response :: new (
183- sift_rs:: assets:: v1:: UpdateAssetResponse :: default ( ) ,
184- ) )
187+ unimplemented ! ( )
185188 }
186189
187190 /// No-op.
188191 async fn archive_asset (
189192 & self ,
190193 _request : Request < sift_rs:: assets:: v1:: ArchiveAssetRequest > ,
191194 ) -> Result < Response < sift_rs:: assets:: v1:: ArchiveAssetResponse > , Status > {
192- Ok ( Response :: new (
193- sift_rs:: assets:: v1:: ArchiveAssetResponse :: default ( ) ,
194- ) )
195+ unimplemented ! ( )
195196 }
196197}
197198
@@ -209,11 +210,7 @@ impl IngestionConfigService for TestServer {
209210 . ok_or ( Status :: not_found ( "ingestion config not found" ) ) ?;
210211
211212 Ok ( Response :: new ( GetIngestionConfigResponse {
212- ingestion_config : Some ( IngestionConfig {
213- ingestion_config_id : ingestion_config. ingestion_config_id . clone ( ) ,
214- asset_id : ingestion_config. asset_id . clone ( ) ,
215- client_key : ingestion_config. client_key . clone ( ) ,
216- } ) ,
213+ ingestion_config : Some ( ingestion_config. clone ( ) ) ,
217214 } ) )
218215 }
219216
0 commit comments