Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset metadata #353

Merged
merged 3 commits into from
Jul 8, 2019
Merged

Offset metadata #353

merged 3 commits into from
Jul 8, 2019

Conversation

damour
Copy link
Contributor

@damour damour commented Jul 8, 2019

Added ability to commit offset with metadata that represents the state of the partition consumer at that point in time. The metadata string can be used by another consumer to restore that state, so it can resume consumption.

@ghost
Copy link

ghost commented Jul 8, 2019

It looks like @damour hasn't signed our Contributor License Agreement, yet.

The purpose of a CLA is to ensure that the guardian of a project's outputs has the necessary ownership or grants of rights over all contributions to allow them to distribute under the chosen licence.
Wikipedia

You can read and sign our full Contributor License Agreement here.

Once you've signed reply with [clabot:check] to prove it.

Appreciation of efforts,

clabot

@damour
Copy link
Contributor Author

damour commented Jul 8, 2019

[clabot:check]

@ghost
Copy link

ghost commented Jul 8, 2019

It looks like @damour hasn't signed our Contributor License Agreement, yet.

The purpose of a CLA is to ensure that the guardian of a project's outputs has the necessary ownership or grants of rights over all contributions to allow them to distribute under the chosen licence.
Wikipedia

You can read and sign our full Contributor License Agreement here.

Once you've signed reply with [clabot:check] to prove it.

Appreciation of efforts,

clabot

@damour
Copy link
Contributor Author

damour commented Jul 8, 2019

[clabot:check]

@ghost
Copy link

ghost commented Jul 8, 2019

@confluentinc It looks like @damour just signed our Contributor License Agreement. 👍

Always at your service,

clabot

kafka/kafka.go Show resolved Hide resolved

_, err = c.CommitOffsets([]kafka.TopicPartition{{
Topic: &topic,
Partition: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use the provided partition

// when using localhost brokers on OSX, since the OSX resolver
// will return the IPv6 addresses first.
// You typically don't need to specify this configuration property.
"broker.address.family": "v4",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

"group.id": group,
"session.timeout.ms": 6000,
"enable.auto.commit": "false",
"auto.offset.reset": "earliest"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the last three since you're not actually consuming or subscribing to anything.

@@ -0,0 +1,103 @@
// Example function-based high-level Apache Kafka consumer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is incorrect

* limitations under the License.
*/

// consumer_offset_metadata implements a consumer that commit offset with metadata that represents the state of the partition consumer at that point in time. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to keep lines < 80 columns

package main

/**
* Copyright 2016 Confluent Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019

examples/README Show resolved Hide resolved
func main() {

if len(os.Args) < 6 {
fmt.Fprintf(os.Stderr, "Usage: %s <broker> <group> <topic> <partition> <offset> \"<metadata>\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about having two modes:

  • if offset and metadata specified: commit and show committed offset
  • if offset and metadata not specified: just show the committed offset

I think that would make it even more useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Done, PTAL.

kafka/kafka.go Outdated
}

return cparts
}

// Go string to C string without null character.
func convertToCStringNoNull(s string) unsafe.Pointer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use C.CString() instead of adding this function, the extra nul byte doesn't matter, just make sure metadata_size does not include it.

@edenhill edenhill merged commit 7167b61 into confluentinc:master Jul 8, 2019
@edenhill
Copy link
Contributor

edenhill commented Jul 8, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants