@@ -207,6 +207,23 @@ private List<DeleteAclsReport> extractDeleteAclsReports(IntPtr resultPtr)
207
207
} ) . ToList ( ) ;
208
208
}
209
209
210
+ private DeleteConsumerGroupOffsetsReport extractDeleteConsumerGroupOffsetsReports ( IntPtr resultPtr )
211
+ {
212
+ IntPtr groupsOffsetsResultPtr = Librdkafka . DeleteConsumerGroupOffsets_result_groups ( resultPtr , out UIntPtr resultCount ) ;
213
+ int groupsOffsetsResultCount = ( int ) resultCount ;
214
+ IntPtr [ ] groupsOffsetsResultArr = new IntPtr [ groupsOffsetsResultCount ] ;
215
+ Marshal . Copy ( groupsOffsetsResultPtr , groupsOffsetsResultArr , 0 , groupsOffsetsResultCount ) ;
216
+
217
+ return new DeleteConsumerGroupOffsetsReport
218
+ {
219
+ Group = PtrToStringUTF8 ( Librdkafka . group_result_name ( groupsOffsetsResultArr [ 0 ] ) ) ,
220
+ Error = new Error ( Librdkafka . group_result_error ( groupsOffsetsResultArr [ 0 ] ) , false ) ,
221
+ Partitions = SafeKafkaHandle . GetTopicPartitionOffsetErrorList ( Librdkafka . group_result_partitions ( groupsOffsetsResultArr [ 0 ] ) )
222
+ . Select ( a => new TopicPartitionOffsetError ( a . Topic , a . Partition , a . Offset , a . Error ) )
223
+ . ToList ( )
224
+ } ;
225
+ }
226
+
210
227
private Task StartPollTask ( CancellationToken ct )
211
228
=> Task . Factory . StartNew ( ( ) =>
212
229
{
@@ -445,6 +462,39 @@ private Task StartPollTask(CancellationToken ct)
445
462
}
446
463
}
447
464
break ;
465
+
466
+ case Librdkafka . EventType . DeleteConsumerGroupOffsets_Result :
467
+ {
468
+ if ( errorCode != ErrorCode . NoError )
469
+ {
470
+ Task . Run ( ( ) =>
471
+ ( ( TaskCompletionSource < DeleteConsumerGroupOffsetsResult > ) adminClientResult ) . TrySetException (
472
+ new KafkaException ( kafkaHandle . CreatePossiblyFatalError ( errorCode , errorStr ) ) ) ) ;
473
+ break ;
474
+ }
475
+
476
+ var result = extractDeleteConsumerGroupOffsetsReports ( eventPtr ) ;
477
+
478
+ if ( result . Error . IsError || result . Partitions . Any ( r => r . Error . IsError ) )
479
+ {
480
+ Task . Run ( ( ) =>
481
+ ( ( TaskCompletionSource < DeleteConsumerGroupOffsetsResult > ) adminClientResult ) . TrySetException (
482
+ new DeleteConsumerGroupOffsetsException ( result ) ) ) ;
483
+ }
484
+ else
485
+ {
486
+ Task . Run ( ( ) =>
487
+ ( ( TaskCompletionSource < DeleteConsumerGroupOffsetsResult > ) adminClientResult ) . TrySetResult (
488
+ new DeleteConsumerGroupOffsetsResult
489
+ {
490
+ Group = result . Group ,
491
+ Partitions = result . Partitions . Select ( r => new TopicPartition ( r . Topic , r . Partition ) ) . ToList ( ) ,
492
+ Error = result . Error // internal, not exposed in success case.
493
+ } ) ) ;
494
+ }
495
+ }
496
+ break ;
497
+
448
498
case Librdkafka . EventType . CreateAcls_Result :
449
499
{
450
500
if ( errorCode != ErrorCode . NoError )
@@ -567,6 +617,7 @@ private Task StartPollTask(CancellationToken ct)
567
617
{ Librdkafka . EventType . AlterConfigs_Result , typeof ( TaskCompletionSource < List < AlterConfigsReport > > ) } ,
568
618
{ Librdkafka . EventType . CreatePartitions_Result , typeof ( TaskCompletionSource < List < CreatePartitionsReport > > ) } ,
569
619
{ Librdkafka . EventType . DeleteRecords_Result , typeof ( TaskCompletionSource < List < DeleteRecordsResult > > ) } ,
620
+ { Librdkafka . EventType . DeleteConsumerGroupOffsets_Result , typeof ( TaskCompletionSource < DeleteConsumerGroupOffsetsResult > ) } ,
570
621
{ Librdkafka . EventType . DeleteGroups_Result , typeof ( TaskCompletionSource < List < DeleteGroupReport > > ) } ,
571
622
{ Librdkafka . EventType . CreateAcls_Result , typeof ( TaskCompletionSource < Null > ) } ,
572
623
{ Librdkafka . EventType . DescribeAcls_Result , typeof ( TaskCompletionSource < DescribeAclsResult > ) } ,
@@ -657,6 +708,19 @@ public Task DeleteGroupsAsync(IList<string> groups, DeleteGroupsOptions options
657
708
return completionSource . Task ;
658
709
}
659
710
711
+ /// <summary>
712
+ /// Refer to <see cref="Confluent.Kafka.IAdminClient.DeleteConsumerGroupOffsetsAsync(String, IEnumerable{TopicPartition}, DeleteConsumerGroupOffsetsOptions)" />
713
+ /// </summary>
714
+ public Task < DeleteConsumerGroupOffsetsResult > DeleteConsumerGroupOffsetsAsync ( String group , IEnumerable < TopicPartition > partitions , DeleteConsumerGroupOffsetsOptions options = null )
715
+ {
716
+ var completionSource = new TaskCompletionSource < DeleteConsumerGroupOffsetsResult > ( ) ;
717
+ var gch = GCHandle . Alloc ( completionSource ) ;
718
+ Handle . LibrdkafkaHandle . DeleteConsumerGroupOffsets (
719
+ group , partitions , options , resultQueue ,
720
+ GCHandle . ToIntPtr ( gch ) ) ;
721
+ return completionSource . Task ;
722
+ }
723
+
660
724
/// <summary>
661
725
/// Refer to <see cref="Confluent.Kafka.IAdminClient.CreatePartitionsAsync(IEnumerable{PartitionsSpecification}, CreatePartitionsOptions)" />
662
726
/// </summary>
0 commit comments