@@ -165,6 +165,26 @@ impl ChromaError for GrpcSealLogError {
165
165
}
166
166
}
167
167
168
+ #[ derive( Error , Debug ) ]
169
+ pub enum GrpcMigrateLogError {
170
+ #[ error( "Failed to migrate collection: {0}" ) ]
171
+ FailedToMigrate ( #[ from] tonic:: Status ) ,
172
+ #[ error( transparent) ]
173
+ ClientAssignerError ( #[ from] ClientAssignmentError ) ,
174
+ #[ error( "not supported by this service" ) ]
175
+ NotSupported ,
176
+ }
177
+
178
+ impl ChromaError for GrpcMigrateLogError {
179
+ fn code ( & self ) -> ErrorCodes {
180
+ match self {
181
+ GrpcMigrateLogError :: FailedToMigrate ( status) => status. code ( ) . into ( ) ,
182
+ GrpcMigrateLogError :: ClientAssignerError ( e) => e. code ( ) ,
183
+ GrpcMigrateLogError :: NotSupported => ErrorCodes :: Unimplemented ,
184
+ }
185
+ }
186
+ }
187
+
168
188
type LogClient = LogServiceClient < chroma_tracing:: GrpcTraceService < tonic:: transport:: Channel > > ;
169
189
170
190
#[ derive( Clone , Debug ) ]
@@ -176,7 +196,7 @@ pub struct GrpcLog {
176
196
177
197
impl GrpcLog {
178
198
#[ allow( clippy:: type_complexity) ]
179
- pub ( crate ) fn new (
199
+ pub fn new (
180
200
config : GrpcLogConfig ,
181
201
client : LogClient ,
182
202
alt_client_assigner : Option < ClientAssigner < LogClient > > ,
@@ -190,7 +210,7 @@ impl GrpcLog {
190
210
}
191
211
192
212
#[ derive( Error , Debug ) ]
193
- pub ( crate ) enum GrpcLogError {
213
+ pub enum GrpcLogError {
194
214
#[ error( "Failed to connect to log service" ) ]
195
215
FailedToConnect ( #[ from] tonic:: transport:: Error ) ,
196
216
}
@@ -639,19 +659,43 @@ impl GrpcLog {
639
659
}
640
660
}
641
661
642
- pub ( super ) async fn seal_log (
662
+ pub async fn seal_log (
643
663
& mut self ,
644
- tenant : & str ,
645
664
collection_id : CollectionUuid ,
646
665
) -> Result < ( ) , GrpcSealLogError > {
666
+ // NOTE(rescrv): Seal log only goes to the go log service, so use the classic connection.
647
667
let _response = self
648
- . client_for ( tenant , collection_id ) ?
668
+ . client
649
669
. seal_log ( chroma_proto:: SealLogRequest {
650
670
collection_id : collection_id. to_string ( ) ,
651
671
} )
652
672
. await ?;
653
673
Ok ( ( ) )
654
674
}
675
+
676
+ pub async fn migrate_log (
677
+ & mut self ,
678
+ collection_id : CollectionUuid ,
679
+ ) -> Result < ( ) , GrpcMigrateLogError > {
680
+ // NOTE(rescrv): Migrate log only goes to the rust log service, so use alt client assigner.
681
+ if let Some ( client_assigner) = self . alt_client_assigner . as_mut ( ) {
682
+ let mut client = client_assigner
683
+ . clients ( & collection_id. to_string ( ) ) ?
684
+ . drain ( ..)
685
+ . next ( )
686
+ . ok_or ( ClientAssignmentError :: NoClientFound (
687
+ "Impossible state: no client found for collection" . to_string ( ) ,
688
+ ) ) ?;
689
+ client
690
+ . migrate_log ( chroma_proto:: MigrateLogRequest {
691
+ collection_id : collection_id. to_string ( ) ,
692
+ } )
693
+ . await ?;
694
+ Ok ( ( ) )
695
+ } else {
696
+ Err ( GrpcMigrateLogError :: NotSupported )
697
+ }
698
+ }
655
699
}
656
700
657
701
#[ cfg( test) ]
0 commit comments