-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: extract reader interface in order to tests and enable distribu…
…ted tracing support
- Loading branch information
1 parent
cdd2454
commit 12bf4be
Showing
3 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package kafka | ||
|
||
import ( | ||
"context" | ||
|
||
segmentio "github.com/segmentio/kafka-go" | ||
) | ||
|
||
type readerWrapper struct { | ||
r *segmentio.Reader | ||
} | ||
|
||
func NewReaderWrapper(reader *segmentio.Reader) Reader { | ||
return &readerWrapper{r: reader} | ||
} | ||
|
||
// ReadMessage returns pointer of kafka message because we will support distributed tracing in the near future | ||
func (s *readerWrapper) ReadMessage(ctx context.Context) (*segmentio.Message, error) { | ||
message, err := s.r.ReadMessage(ctx) | ||
return &message, err | ||
} | ||
|
||
func (s *readerWrapper) Close() error { | ||
return s.r.Close() | ||
} |