@@ -37,7 +37,7 @@ type Record struct {
37
37
Offset int64
38
38
}
39
39
40
- type ReaderIfc interface {
40
+ type Reader interface {
41
41
Topic () string
42
42
Partition () int32
43
43
ConsumerGroup () string
@@ -91,8 +91,8 @@ func newReaderMetrics(r prometheus.Registerer) *readerMetrics {
91
91
}
92
92
}
93
93
94
- // Reader provides low-level access to Kafka partition reading operations
95
- type Reader struct {
94
+ // StdReader provides low-level access to Kafka partition reading operations
95
+ type StdReader struct {
96
96
client * kgo.Client
97
97
topic string
98
98
partitionID int32
@@ -101,13 +101,13 @@ type Reader struct {
101
101
logger log.Logger
102
102
}
103
103
104
- func NewReader (
104
+ func NewStdReader (
105
105
cfg kafka.Config ,
106
106
partitionID int32 ,
107
107
instanceID string ,
108
108
logger log.Logger ,
109
109
reg prometheus.Registerer ,
110
- ) (* Reader , error ) {
110
+ ) (* StdReader , error ) {
111
111
// Create a new Kafka client for this reader
112
112
clientMetrics := client .NewReaderClientMetrics ("partition-reader" , reg )
113
113
c , err := client .NewReaderClient (
@@ -120,7 +120,7 @@ func NewReader(
120
120
}
121
121
122
122
// Create the reader
123
- return newReader (
123
+ return newStdReader (
124
124
c ,
125
125
cfg .Topic ,
126
126
partitionID ,
@@ -130,16 +130,16 @@ func NewReader(
130
130
), nil
131
131
}
132
132
133
- // NewReader creates a new Reader instance
134
- func newReader (
133
+ // newStdReader creates a new StdReader instance
134
+ func newStdReader (
135
135
client * kgo.Client ,
136
136
topic string ,
137
137
partitionID int32 ,
138
138
consumerGroup string ,
139
139
logger log.Logger ,
140
140
reg prometheus.Registerer ,
141
- ) * Reader {
142
- return & Reader {
141
+ ) * StdReader {
142
+ return & StdReader {
143
143
client : client ,
144
144
topic : topic ,
145
145
partitionID : partitionID ,
@@ -150,22 +150,22 @@ func newReader(
150
150
}
151
151
152
152
// Topic returns the topic being read
153
- func (r * Reader ) Topic () string {
153
+ func (r * StdReader ) Topic () string {
154
154
return r .topic
155
155
}
156
156
157
157
// Partition returns the partition being read
158
- func (r * Reader ) Partition () int32 {
158
+ func (r * StdReader ) Partition () int32 {
159
159
return r .partitionID
160
160
}
161
161
162
162
// ConsumerGroup returns the consumer group
163
- func (r * Reader ) ConsumerGroup () string {
163
+ func (r * StdReader ) ConsumerGroup () string {
164
164
return r .consumerGroup
165
165
}
166
166
167
167
// FetchLastCommittedOffset retrieves the last committed offset for this partition
168
- func (r * Reader ) FetchLastCommittedOffset (ctx context.Context ) (int64 , error ) {
168
+ func (r * StdReader ) FetchLastCommittedOffset (ctx context.Context ) (int64 , error ) {
169
169
req := kmsg .NewPtrOffsetFetchRequest ()
170
170
req .Topics = []kmsg.OffsetFetchRequestTopic {{
171
171
Topic : r .topic ,
@@ -210,7 +210,7 @@ func (r *Reader) FetchLastCommittedOffset(ctx context.Context) (int64, error) {
210
210
}
211
211
212
212
// FetchPartitionOffset retrieves the offset for a specific position
213
- func (r * Reader ) FetchPartitionOffset (ctx context.Context , position SpecialOffset ) (int64 , error ) {
213
+ func (r * StdReader ) FetchPartitionOffset (ctx context.Context , position SpecialOffset ) (int64 , error ) {
214
214
partitionReq := kmsg .NewListOffsetsRequestTopicPartition ()
215
215
partitionReq .Partition = r .partitionID
216
216
partitionReq .Timestamp = int64 (position )
@@ -257,7 +257,7 @@ func (r *Reader) FetchPartitionOffset(ctx context.Context, position SpecialOffse
257
257
}
258
258
259
259
// Poll retrieves the next batch of records from Kafka
260
- func (r * Reader ) Poll (ctx context.Context ) ([]Record , error ) {
260
+ func (r * StdReader ) Poll (ctx context.Context ) ([]Record , error ) {
261
261
start := time .Now ()
262
262
fetches := r .client .PollFetches (ctx )
263
263
r .metrics .fetchWaitDuration .Observe (time .Since (start ).Seconds ())
@@ -303,14 +303,14 @@ func (r *Reader) Poll(ctx context.Context) ([]Record, error) {
303
303
return records , nil
304
304
}
305
305
306
- func (r * Reader ) SetOffsetForConsumption (offset int64 ) {
306
+ func (r * StdReader ) SetOffsetForConsumption (offset int64 ) {
307
307
r .client .AddConsumePartitions (map [string ]map [int32 ]kgo.Offset {
308
308
r .topic : {r .partitionID : kgo .NewOffset ().At (offset )},
309
309
})
310
310
}
311
311
312
312
// Commit commits an offset to the consumer group
313
- func (r * Reader ) Commit (ctx context.Context , offset int64 ) error {
313
+ func (r * StdReader ) Commit (ctx context.Context , offset int64 ) error {
314
314
admin := kadm .NewClient (r .client )
315
315
316
316
// Commit the last consumed offset.
0 commit comments