Skip to content

Commit

Permalink
client: add ForceMetadataRefresh
Browse files Browse the repository at this point in the history
If you CreatePartitions, you may want to trigger a metadata update
quickly.
  • Loading branch information
twmb committed Mar 1, 2022
1 parent 1593adc commit e8495bb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/kgo/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ func (m *metawait) signal() {
m.c.Broadcast()
}

// ForceMetadataRefresh triggers the client to update the metadata that is
// currently used for producing & consuming.
//
// Internally, the client already properly triggers metadata updates whenever a
// partition is discovered to be out of date (leader moved, epoch is old, etc).
// However, when partitions are added to a topic through a CreatePartitions
// request, it may take up to MetadataMaxAge for the new partitions to be
// discovered. In this case, you may want to forcefully refresh metadata
// manually to discover these new partitions sooner.
func (cl *Client) ForceMetadataRefresh() {
cl.triggerUpdateMetadataNow("from user ForceMetadataRefresh")
}

// waitmeta returns immediately if metadata was updated within the last second,
// otherwise this waits for up to wait for a metadata update to complete.
func (cl *Client) waitmeta(ctx context.Context, wait time.Duration, why string) {
Expand Down

0 comments on commit e8495bb

Please sign in to comment.