Skip to content

Commit 76f38fd

Browse files
authored
make client classes internal (#888)
* make client classes internal * updated changelog
1 parent 5516eba commit 76f38fd

14 files changed

+82
-26
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# 1.0.0-RC5
22

3+
## New Features
4+
5+
- Added DependentAdminClientBuilder class.
6+
7+
38
## Changes
49

510
- Reverted RC4 changes.
@@ -9,6 +14,7 @@
914
- Removed IAsyncDeserializer setter overloads from the ConsumerBuilder class.
1015
- Renamed Producer.BeginProduce to Producer.Produce.
1116
- Produce throws an exception if used when async serializers are configured.
17+
- Made AdminClient, Producer, and Consumer classes internal.
1218

1319

1420
# 1.0.0-RC4

src/Confluent.Kafka/AdminClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Confluent.Kafka
3030
/// <summary>
3131
/// Implements an Apache Kafka admin client.
3232
/// </summary>
33-
public class AdminClient : IAdminClient
33+
internal class AdminClient : IAdminClient
3434
{
3535
private int cancellationDelayMaxMs;
3636

@@ -425,7 +425,7 @@ private SafeKafkaHandle kafkaHandle
425425
/// make broker requests. It is valid to provide either a Consumer, Producer
426426
/// or AdminClient handle.
427427
/// </param>
428-
public AdminClient(Handle handle)
428+
internal AdminClient(Handle handle)
429429
{
430430
this.ownedClient = null;
431431
this.handle = handle;

src/Confluent.Kafka/AdminClientBuilder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace Confluent.Kafka
2222
{
2323
/// <summary>
24-
/// A builder for <see cref="AdminClient" /> instances.
24+
/// A builder for <see cref="IAdminClient" />.
2525
/// </summary>
2626
public class AdminClientBuilder
2727
{
@@ -33,17 +33,17 @@ public class AdminClientBuilder
3333
/// <summary>
3434
/// The configured error handler.
3535
/// </summary>
36-
internal protected Action<AdminClient, Error> ErrorHandler { get; set; }
36+
internal protected Action<IAdminClient, Error> ErrorHandler { get; set; }
3737

3838
/// <summary>
3939
/// The configured log handler.
4040
/// </summary>
41-
internal protected Action<AdminClient, LogMessage> LogHandler { get; set; }
41+
internal protected Action<IAdminClient, LogMessage> LogHandler { get; set; }
4242

4343
/// <summary>
4444
/// The configured statistics handler.
4545
/// </summary>
46-
internal protected Action<AdminClient, string> StatisticsHandler { get; set; }
46+
internal protected Action<IAdminClient, string> StatisticsHandler { get; set; }
4747

4848
/// <summary>
4949
/// Initialize a new <see cref="AdminClientBuilder" /> instance.
@@ -73,7 +73,7 @@ public AdminClientBuilder(IEnumerable<KeyValuePair<string, string>> config)
7373
/// Executes on the poll thread (a background thread managed by
7474
/// the admin client).
7575
/// </remarks>
76-
public AdminClientBuilder SetStatisticsHandler(Action<AdminClient, string> statisticsHandler)
76+
public AdminClientBuilder SetStatisticsHandler(Action<IAdminClient, string> statisticsHandler)
7777
{
7878
if (this.StatisticsHandler != null)
7979
{
@@ -93,7 +93,7 @@ public AdminClientBuilder SetStatisticsHandler(Action<AdminClient, string> stati
9393
/// Executes on the poll thread (a background thread managed by the admin
9494
/// client).
9595
/// </remarks>
96-
public AdminClientBuilder SetErrorHandler(Action<AdminClient, Error> errorHandler)
96+
public AdminClientBuilder SetErrorHandler(Action<IAdminClient, Error> errorHandler)
9797
{
9898
if (this.ErrorHandler != null)
9999
{
@@ -119,7 +119,7 @@ public AdminClientBuilder SetErrorHandler(Action<AdminClient, Error> errorHandle
119119
/// Confluent.Kafka APIs from within a log handler or perform any
120120
/// prolonged operations.
121121
/// </remarks>
122-
public AdminClientBuilder SetLogHandler(Action<AdminClient, LogMessage> logHandler)
122+
public AdminClientBuilder SetLogHandler(Action<IAdminClient, LogMessage> logHandler)
123123
{
124124
if (this.LogHandler != null)
125125
{

src/Confluent.Kafka/Consumer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Confluent.Kafka
3232
/// Implements a high-level Apache Kafka consumer with
3333
/// deserialization capability.
3434
/// </summary>
35-
public class Consumer<TKey, TValue> : IConsumer<TKey, TValue>, IClient
35+
internal class Consumer<TKey, TValue> : IConsumer<TKey, TValue>, IClient
3636
{
3737
internal class Config
3838
{

src/Confluent.Kafka/ConsumerBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
namespace Confluent.Kafka
2828
{
2929
/// <summary>
30-
/// A builder class for <see cref="Consumer{TKey,TValue}" /> instances.
30+
/// A builder class for <see cref="IConsumer{TKey,TValue}" />.
3131
/// </summary>
3232
public class ConsumerBuilder<TKey, TValue>
3333
{
@@ -353,7 +353,7 @@ public ConsumerBuilder<TKey, TValue> SetOffsetsCommittedHandler(Action<IConsumer
353353
}
354354

355355
/// <summary>
356-
/// Build a new Consumer instance.
356+
/// Build a new IConsumer implementation instance.
357357
/// </summary>
358358
public virtual IConsumer<TKey, TValue> Build()
359359
{
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2019 Confluent Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// Refer to LICENSE for more information.
16+
17+
using System;
18+
using System.Collections.Generic;
19+
20+
21+
namespace Confluent.Kafka
22+
{
23+
/// <summary>
24+
/// A builder class for <see cref="IAdminClient" /> instance
25+
/// implementations that leverage an existing client handle.
26+
/// </summary>
27+
public class DependentAdminClientBuilder
28+
{
29+
/// <summary>
30+
/// The configured client handle.
31+
/// </summary>
32+
public Handle Handle { get; set; }
33+
34+
/// <summary>
35+
/// An underlying librdkafka client handle that the AdminClient.
36+
/// </summary>
37+
public DependentAdminClientBuilder(Handle handle)
38+
{
39+
this.Handle = handle;
40+
}
41+
42+
/// <summary>
43+
/// Build a new IAdminClient implementation instance.
44+
/// </summary>
45+
public virtual IAdminClient Build()
46+
{
47+
return new AdminClient(this.Handle);
48+
}
49+
}
50+
}

src/Confluent.Kafka/DependentProducerBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
namespace Confluent.Kafka
2222
{
2323
/// <summary>
24-
/// A builder class for <see cref="Producer{TKey, TValue}" /> instances
25-
/// that leverage an existing client handle.
24+
/// A builder class for <see cref="IProducer{TKey, TValue}" /> instance
25+
/// implementations that leverage an existing client handle.
2626
/// </summary>
2727
public class DependentProducerBuilder<TKey, TValue>
2828
{
@@ -99,7 +99,7 @@ public DependentProducerBuilder<TKey, TValue> SetValueSerializer(IAsyncSerialize
9999
}
100100

101101
/// <summary>
102-
/// Build a new Producer instance.
102+
/// Build a new IProducer implementation instance.
103103
/// </summary>
104104
public virtual IProducer<TKey, TValue> Build()
105105
{

src/Confluent.Kafka/Producer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Confluent.Kafka
2929
/// <summary>
3030
/// A high level producer with serialization capability.
3131
/// </summary>
32-
public class Producer<TKey, TValue> : IProducer<TKey, TValue>, IClient
32+
internal class Producer<TKey, TValue> : IProducer<TKey, TValue>, IClient
3333
{
3434
internal class Config
3535
{

src/Confluent.Kafka/ProducerBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace Confluent.Kafka
2222
{
2323
/// <summary>
24-
/// A builder class for <see cref="Producer{TKey, TValue}" /> instances.
24+
/// A builder class for <see cref="IProducer{TKey,TValue}" />.
2525
/// </summary>
2626
public class ProducerBuilder<TKey, TValue>
2727
{
@@ -217,7 +217,7 @@ public ProducerBuilder<TKey, TValue> SetValueSerializer(IAsyncSerializer<TValue>
217217
}
218218

219219
/// <summary>
220-
/// Build a new Producer instance.
220+
/// Build a new IProducer implementation instance.
221221
/// </summary>
222222
public virtual IProducer<TKey, TValue> Build()
223223
{

test/Confluent.Kafka.IntegrationTests/Tests/AddBroker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void AddBrokers(string bootstrapServers)
3838
var producerConfig = new ProducerConfig { BootstrapServers = "localhost:65533" };
3939

4040
using (var producer = new ProducerBuilder<Null, string>(producerConfig).Build())
41-
using (var adminClient = new AdminClient(producer.Handle))
41+
using (var adminClient = new DependentAdminClientBuilder(producer.Handle).Build())
4242
{
4343
try
4444
{

0 commit comments

Comments
 (0)