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

Update subscription get message by id typo lederId to ledgerId #1699

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pkg/ctl/subscription/get_message_by_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,41 @@ import (

func GetMessageByIDCmd(vc *cmdutils.VerbCmd) {
var desc cmdutils.LongDescription
desc.CommandUsedFor = "This command is used for getting messages by the given legerID and entryID" +
desc.CommandUsedFor = "This command is used for getting messages by the given ledgerID and entryID" +
" for a subscription."
desc.CommandPermission = "This command requires tenant admin and namespace produce or consume permissions."

var examples []cmdutils.Example
examples = append(examples, cmdutils.Example{
Desc: "Get message by the given legerID an entryID",
Command: "pulsarctl subscription get-message-by-id --leger-id (leger-id) --entry-id (entry-id) (topic-name)",
Desc: "Get message by the given ledgerID an entryID",
Command: "pulsarctl subscription get-message-by-id --ledger-id (ledger-id) --entry-id (entry-id) (topic-name)",
})
desc.CommandExamples = examples

vc.SetDescription(
"get-message-by-id",
"Getting messages by the given legerID and entryID",
"Getting messages by the given ledgerID and entryID",
desc.ToString(),
desc.ExampleToString(),
)

var legerID int64
var ledgerID int64
var entryID int64

vc.SetRunFuncWithNameArg(func() error {
return doGetMessageByID(vc, legerID, entryID)
return doGetMessageByID(vc, ledgerID, entryID)
}, "the topic name is not specified or the topic name is specified more than one")

vc.FlagSetGroup.InFlagSet("GetMessageByID", func(set *pflag.FlagSet) {
set.Int64VarP(&legerID, "leger-id", "l", 0, "ledger id pointing to the desired ledger")
cobra.MarkFlagRequired(set, "leger-id")
set.Int64VarP(&ledgerID, "ledger-id", "l", 0, "ledger id pointing to the desired ledger")
cobra.MarkFlagRequired(set, "ledger-id")
set.Int64VarP(&entryID, "entry-id", "e", 0, "entry id pointing to the desired entry")
cobra.MarkFlagRequired(set, "entry-id")
})
vc.EnableOutputFlagSet()
}

func doGetMessageByID(vc *cmdutils.VerbCmd, legerID int64, entryID int64) error {
func doGetMessageByID(vc *cmdutils.VerbCmd, ledgerID int64, entryID int64) error {
// for testing
if vc.NameError != nil {
return vc.NameError
Expand All @@ -77,12 +77,12 @@ func doGetMessageByID(vc *cmdutils.VerbCmd, legerID int64, entryID int64) error
}

client := cmdutils.NewPulsarClient()
messages, err := client.Subscriptions().GetMessagesByID(*topic, legerID, entryID)
messages, err := client.Subscriptions().GetMessagesByID(*topic, ledgerID, entryID)
if err != nil {
return err
}
if len(messages) == 0 {
return fmt.Errorf("no message found with the given legerID and entryID")
return fmt.Errorf("no message found with the given ledgerID and entryID")
}
message := messages[0]
propertiesJSON, err := json.Marshal(message.GetProperties())
Expand Down
Loading