Skip to content

Commit

Permalink
kadm: break APIs for 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
twmb committed May 31, 2022
1 parent 7689d6f commit b279658
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
5 changes: 5 additions & 0 deletions pkg/kadm/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ type ACLBuilder struct {
pattern ACLPattern
}

// PrefixUser prefixes all allowed and denied principals with "User:".
func (b *ACLBuilder) PrefixUser() {
b.PrefixUserExcept()
}

// PrefixUserExcept prefixes all allowed and denied principals with "User:",
// unless they have any of the given except prefixes.
func (b *ACLBuilder) PrefixUserExcept(except ...string) {
Expand Down
9 changes: 6 additions & 3 deletions pkg/kadm/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"

"github.com/twmb/franz-go/pkg/kerr"
"github.com/twmb/franz-go/pkg/kgo"
"github.com/twmb/franz-go/pkg/kmsg"
)

Expand Down Expand Up @@ -454,9 +455,6 @@ func (os OffsetResponses) Keep(o Offsets) {
})
}

// Deprecated: Use Offsets; this will be removed in v1.0.
func (os OffsetResponses) Into() Offsets { return os.Offsets() }

// Offsets returns these offset responses as offsets.
func (os OffsetResponses) Offsets() Offsets {
i := make(Offsets)
Expand All @@ -466,6 +464,11 @@ func (os OffsetResponses) Offsets() Offsets {
return i
}

// KOffsets returns these offset responses as a kgo offset map.
func (os OffsetResponses) KOffsets() map[string]map[int32]kgo.Offset {
return os.Offsets().KOffsets()
}

// DeleteFunc keeps only the offsets for which fn returns true.
func (os OffsetResponses) KeepFunc(fn func(OffsetResponse) bool) {
for t, ps := range os {
Expand Down
15 changes: 7 additions & 8 deletions pkg/kadm/kadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ func (ps Partitions) TopicsList() TopicsList {
// OffsetsList wraps many offsets and is a helper for building Offsets.
type OffsetsList []Offset

// Deprecated: Use Offsets; this will be removed in v1.0.
func (l OffsetsList) Into() Offsets { return l.Offsets() }

// Offsets returns this list as the non-list Offsets. All fields in each
// Offset must be set properly.
func (l OffsetsList) Offsets() Offsets {
Expand All @@ -178,6 +175,11 @@ func (l OffsetsList) Offsets() Offsets {
return os
}

// KOffsets returns this list as a kgo offset map.
func (l OffsetsList) KOffsets() map[string]map[int32]kgo.Offset {
return l.Offsets().KOffsets()
}

// Offsets wraps many offsets and is the type used for offset functions.
type Offsets map[string]map[int32]Offset

Expand Down Expand Up @@ -284,11 +286,8 @@ func (os Offsets) Each(fn func(Offset)) {
}
}

// Deprecated: Use AsKgo; this will be removed in v1.0.
func (os Offsets) Into() map[string]map[int32]kgo.Offset { return os.AsKgo() }

// AsKgo returns these offsets as a kgo offset map.
func (os Offsets) AsKgo() map[string]map[int32]kgo.Offset {
// KOffsets returns these offsets as a kgo offset map.
func (os Offsets) KOffsets() map[string]map[int32]kgo.Offset {
tskgo := make(map[string]map[int32]kgo.Offset)
for t, ps := range os {
pskgo := make(map[int32]kgo.Offset)
Expand Down
15 changes: 8 additions & 7 deletions pkg/kadm/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ func (cl *Client) ListBrokers(ctx context.Context) (BrokerDetails, error) {
return m.Brokers, nil
}

// MetadataWithoutTopics issues a metadata request and returns it, and does not
// ask for any topics. This request is the counterpart to requesting all topics
// by default with the Metadata method.
// BrokerMetadata issues a metadata request and returns it, and does not ask
// for any topics.
//
// This returns an error if the request fails to be issued, or an *AuthErr.
func (cl *Client) MetadataWithoutTopics(ctx context.Context) (Metadata, error) {
func (cl *Client) BrokerMetadata(ctx context.Context) (Metadata, error) {
return cl.metadata(ctx, true, nil)
}

Expand Down Expand Up @@ -307,9 +306,6 @@ func (l ListedOffsets) Error() error {
return nil
}

// Deprecated: Use Offsets; this will be removed in v1.0.
func (l ListedOffsets) Into() Offsets { return l.Offsets() }

// Offsets returns these listed offsets as offsets.
func (l ListedOffsets) Offsets() Offsets {
o := make(Offsets)
Expand All @@ -324,6 +320,11 @@ func (l ListedOffsets) Offsets() Offsets {
return o
}

// KOffsets returns these listed offsets as a kgo offset map.
func (l ListedOffsets) KOffsets() map[string]map[int32]kgo.Offset {
return l.Offsets().KOffsets()
}

// ListStartOffsets returns the start (oldest) offsets for each partition in
// each requested topic. In Kafka terms, this returns the log start offset. If
// no topics are specified, all topics are listed.
Expand Down
10 changes: 5 additions & 5 deletions pkg/kadm/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import (
// topics to describe can be passed as additional arguments. If no topics are
// specified, all topics are requested. Internal topics are not returned unless
// specifically requested. To see all topics including internal topics, use
// ListInternalTopics.
// ListTopicsWithInternal.
//
// This returns an error if the request fails to be issued, or an *AuthError.
func (cl *Client) ListTopics(
ctx context.Context,
topics ...string,
) (TopicDetails, error) {
t, err := cl.ListInternalTopics(ctx, topics...)
t, err := cl.ListTopicsWithInternal(ctx, topics...)
if err != nil {
return nil, err
}
t.FilterInternal()
return t, nil
}

// ListInternalTopics is the same as ListTopics, but does not filter internal
// topics before returning.
func (cl *Client) ListInternalTopics(
// ListTopicsWithInternal is the same as ListTopics, but does not filter
// internal topics before returning.
func (cl *Client) ListTopicsWithInternal(
ctx context.Context,
topics ...string,
) (TopicDetails, error) {
Expand Down

0 comments on commit b279658

Please sign in to comment.