Skip to content

Conversation

@zymap
Copy link
Member

@zymap zymap commented Sep 16, 2019

Master issue: #2

all commands

Operations about subscription(s)

Usage: pulsarctl subscriptions [flags]

Commands:
  create      Create subscription on a topic from latest
  delete      Delete a subscription on a topic
  expire-messages  Expiring messages that older than given expire time (in seconds)
  list        list all existing subscriptions under a topic
  reset-cursor  Reset the cursor to position closest to timestamp or messageId
  skip-messages  Skip messages for the subscription under a topic

Aliases: subscriptions, subscription

Common flags:
  -s, --admin-service-url string    The admin web service url that pulsarctl connects to. (default "http://localhost:8080")
      --auth-params string          Authentication parameters are used to configure the public and private key files required by tls
                                     For example: "tlsCertFile:val1,tlsKeyFile:val2"
  -C, --color string                toggle colorized logs (true,false,fabulous) (default "true")
  -h, --help                        help for this command
      --tls-allow-insecure          Allow TLS insecure connection
      --tls-trust-cert-pat string   Allow TLS trust cert file path
  -v, --verbose int                 set log level, use 0 to silence, 4 for debugging (default 3)

Use 'pulsarctl subscriptions [command] --help' for more information about a command.

create

USED FOR:
    This command is used for creating a subscription on a topic.

REQUIRED PERMISSION:
    This command requires tenant admin and namespace produce or consume permissions.

EXAMPLES:
    #Create a subscription <subscription-name> on a topic <topic-name> from latest
    pulsarctl subscription create <topic-name> <subscription-name>

    #Create a subscription <subscription-name> on a topic <topic-name> from the specified position <position>
    pulsarctl subscription create --messageId <position> <topic-name> <subscription-name>

OUTPUT:
    #normal output
    Create subscription <subscription-name> on topic <topic-name> from <position> successfully

    #the topic name and(or) the subscription name is not specified
    [✖]  need to specified the topic name and the subscription name

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special charsthe alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special charsthe  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

    #the split of message id is not valid
    [✖]  Invalid message id string. <message-id>

    #the ledger id is not valid
    [✖]  Invalid ledger id string. <message-id>

    #the entry id is not valid
    [✖]  Invalid entry id string. <message-id>

Usage: pulsarctl subscriptions create [flags]

Create Subscription flags:
  -m, --messageId string   message id where to create the subscription. It can be either 'latest', 'earliest or (ledgerId:entryId) (default "latest")

delete

USED FOR:
    This command is used for deleting a durable subscription from a topic.

REQUIRED PERMISSION:
    This command requires tenant admin and namespace consume permissions.

EXAMPLES:
    #Delete a subscription <subscription-name> from a topic <topic-name>
    pulsarctl subscription delete <topic-name> <subscription-name>

OUTPUT:
    #normal output
    Delete subscription %s on the topic %s  successfully

    #the topic name and(or) the subscription name is not specified
    [✖]  need to specified the topic name and the subscription name

    #the specified subscription is not exist
    [✖]  code: 404 reason: Subscription not found

    #the specified topic is not exist
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special charsthe alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special charsthe  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl subscriptions delete [flags]

list

USED FOR:
    This command is used for listing all existing subscriptions under a topic.

REQUIRED PERMISSION:
    This command requires tenant admin and namespace produce or consume permissions.

EXAMPLES:
    #List all existing subscriptions under a topic <topic-name>
    pulsarctl subscriptions list <topic-name>

OUTPUT:
    #normal output
    +----------------------+
    |    SUBSCRIPTIONS     |
    +----------------------+
    +----------------------+


    #the topic name is not specified
    [✖]  only one argument is allowed to be used as a name

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special charsthe alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special charsthe  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl subscriptions list [flags]

expire-messages

USED FOR:
    This command is used for expiring messages that older than given expiry time (in seconds) for the subscription.

REQUIRED PERMISSION:
    This command requires tenant admin and namespace produce or consume permissions.

EXAMPLES:
    #Expire messages that older than given expire time (in seconds) <expire-time> for the subscription <subscription-name> under a topic <topic-name>
    pulsarctl subscription expire-messages --expire-time <expire-time> <topic-name> <subscription-name>

    #Expire message that older than given expire time (in second) <expire-time> for all subscriptions under a topic <topic-name>
    pulsarctl subscriptions expire-messages --expire-time <expire-time> <topic-name> all

OUTPUT:
    #normal output
    Expire messages after <time>(s) for subscription <subscription-name> of topic <topic-name> successfully

    #the topic name and(or) the subscription name is not specified
    [✖]  need to specified the topic name and the subscription name

    #the specified topic is not exist
    [✖]  code: 404 reason: Topic not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special charsthe alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special charsthe  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl subscriptions expire-messages [flags]

Aliases: expire-messages, expire

ExpireMessages flags:
  -t, --expire-time int   Expire messages older than time in seconds

reset-cursor

USED FOR:
    This command is used for resetting position for subscription to position closest to timestamp or messageId

REQUIRED PERMISSION:
    This command requires tenant admin and namespace produce or consume permissions

EXAMPLES:
    #Reset position for subscription <subscription-name> to position closest to timestamp <time>
    pulsarctl reset --time <time> <topic-name> <subscription-name>

    #Reset position for subscription <subscription-name> to position closest to message id <message-id>
    pulsarctl reset --message-id <message-id> <topic-name> <subscription-name>

OUTPUT:
    #normal output
    Reset the cursor to <time>/<message-id> successfully

    #the topic name and(or) the subscription name is not specified
    [✖]  need to specified the topic name and the subscription name

    #the time is not specified or the message id is not specified
    [✖]  The reset position must be specified

    #the specified topic is not exist
    [✖]  code: 404 reason: Topic not found

    #the specified subscription is not exist
    [✖]  code: 404 reason: Subscription not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special charsthe alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special charsthe  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl subscriptions reset-cursor [flags]

skip-messages

USED FOR:
    This command is used for skipping messages for the subscription.

REQUIRED PERMISSION:
    This command requires tenant admin and namespace produce or consume permissions.

EXAMPLES:
    #Skip <count> messages for the subscription <subscription-name> under the topic <topic-name>
    pulsarctl subscription skip-messages --count <count> <topic-name> <subscription-name>

    #Skip all messages for  the subscription <subscription-name> under the topic <topic-name> (clear-backlog)
    pulsarctl subscription skip-messages --count -1 <topic-name> <subscription-name>

OUTPUT:
    #normal output
    Subscription <subscription-name> skip <count> messages on topic <topic-name> successfully

    #the topic name and(or) the subscription name is not specified
    [✖]  need to specified the topic name and the subscription name

    #the specified topic is not exist
    [✖]  code: 404 reason: Topic not found

    #the specified subscription is not exist
    [✖]  code: 404 reason: Subscription not found

    #the topic name is not in the format of <tenant>/<namespace>/<topic> or <topic>
    [✖]  Invalid short topic name '<topic-name>', it should be in the format of <tenant>/<namespace>/<topic> or <topic>

    #the topic name is not in the format of <domain>://<tenant>/<namespace>/<topic>
    [✖]  Invalid complete topic name '<topic-name>', it should be in the format of <domain>://<tenant>/<namespace>/<topic>

    #the topic name is not in the format of <tenant>/<namespace>/<topic>
    [✖]  Invalid topic name '<topic-name>', it should be in the format of<tenant>/<namespace>/<topic>

    #the namespace name is not in the format of <tenant>/<namespace>
    [✖]  The complete name of namespace is invalid. complete name : <namespace-complete-name>

    #the tenant name and(or) namespace name is empty
    [✖]  Invalid tenant or namespace. [<tenant>/<namespace>]

    #the tenant name contains unsupported special charsthe alphanumeric (a-zA-Z0-9) and the special chars (-=:.%)  is allowed
    [✖]  Tenant name include unsupported special chars. tenant : [<namespace>]

    #the namespace name contains unsupported special charsthe  alphanumeric (a-zA-Z0-9) and the special chars (-=:.%) is allowed
    [✖]  Namespace name include unsupported special chars. namespace : [<namespace>]

Usage: pulsarctl subscriptions skip-messages [flags]

Aliases: skip-messages, skip

Skip Messages flags:
  -n, --count int   number of messages to skip (default -1)

func CreateCmd(vc *cmdutils.VerbCmd) {
var desc LongDescription
desc.CommandUsedFor = "This command is used for creating a subscription on a topic."
desc.CommandPermission = "This command requires tenant admin and namespace produce or consume permissions."
Copy link
Member

Choose a reason for hiding this comment

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

two questions:

  1. why do you need produce permission?
  2. doesn't a tenant admin has permissions to produce or consume a topic under this tenant?

@sijie sijie mentioned this pull request Sep 18, 2019
29 tasks
@sijie
Copy link
Member

sijie commented Oct 3, 2019

please address my comments

@zymap
Copy link
Member Author

zymap commented Oct 11, 2019

@sijie PTAL. Thanks

@sijie sijie added this to the 0.0.1 milestone Oct 12, 2019
@zymap
Copy link
Member Author

zymap commented Oct 14, 2019

@sijie PTAL. Thanks

@sijie sijie merged commit ed56d5b into master Oct 14, 2019
@sijie sijie deleted the subscription-commands branch October 14, 2019 06:55
tisonkun pushed a commit to tisonkun/pulsar-client-go that referenced this pull request Aug 15, 2023
tisonkun pushed a commit to apache/pulsar-client-go that referenced this pull request Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants