forked from segmentio/kafka-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add CommitMessages documentation (segmentio#58)
* add CommitMessages documentation * Revisit sync commits (segmentio#59) * revisit sync commits * drop commit request chan capacity * remove error prone check * shorter code
- Loading branch information
1 parent
61718eb
commit 7619f5f
Showing
3 changed files
with
110 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package kafka | ||
|
||
// A commit represents the instruction of publishing an update of the last | ||
// offset read by a program for a topic and partition. | ||
type commit struct { | ||
topic string | ||
partition int | ||
offset int64 | ||
} | ||
|
||
// makeCommit builds a commit value from a message, the resulting commit takes | ||
// its topic, partition, and offset from the message. | ||
func makeCommit(msg Message) commit { | ||
return commit{ | ||
topic: msg.Topic, | ||
partition: msg.Partition, | ||
offset: msg.Offset, | ||
} | ||
} | ||
|
||
// makeCommits generates a slice of commits from a list of messages, it extracts | ||
// the topic, partition, and offset of each message and builds the corresponding | ||
// commit slice. | ||
func makeCommits(msgs ...Message) []commit { | ||
commits := make([]commit, len(msgs)) | ||
|
||
for i, m := range msgs { | ||
commits[i] = makeCommit(m) | ||
} | ||
|
||
return commits | ||
} | ||
|
||
// commitRequest is the data type exchanged between the CommitMessages method | ||
// and internals of the reader's implementation. | ||
type commitRequest struct { | ||
commits []commit | ||
errch chan<- error | ||
} |
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