Skip to content

Commit

Permalink
Update subscription get message by id typo lederId to ledgerId (#1699)
Browse files Browse the repository at this point in the history
* Update subscription get message by id typo lederId to edgerId

* Adjust after merge, use ledgerID for get message by id
  • Loading branch information
Nikolajls authored Jan 15, 2025
1 parent eceaf14 commit b9416b7
Showing 1 changed file with 11 additions and 11 deletions.
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

0 comments on commit b9416b7

Please sign in to comment.