Skip to content

Commit

Permalink
Add update cmd for Pulsar Functions (#33)
Browse files Browse the repository at this point in the history
Add update cmd for Pulsar Functions, output as follows:

```
USED FOR:
    Update a Pulsar Function that has been deployed to a Pulsar cluster.

REQUIRED PERMISSION:
    This command requires super-user permissions.

EXAMPLES:
    #Update output topic of Pulsar Function
    pulsarctl functions update
	--tenant public
	--namespace default
	--name update-function
	--output test-output-topic

    #Update function config yaml file of Pulsar Function
    pulsarctl functions update
	--function-config-file <the path of function config yaml file>
	--jar <the path of user code jar>

    #Update log topic of Pulsar Function
    pulsarctl functions update
	--log-topic persistent://public/default/test-log-topic
	# Other function parameters

    #Update dead letter topic of Pulsar Function
    pulsarctl functions update
	--dead-letter-topic persistent://public/default/test-dead-letter-topic
	--max-message-retries 10
	# Other function parameters

    #Update user config of Pulsar Function
    pulsarctl functions update
	--user-config "{"publishTopic":"publishTopic", "key":"pulsar"}"
	# Other function parameters

    #Update custom schema of inputs topic for Pulsar Function
    pulsarctl functions update
	--custom-schema-inputs "{"topic-1":"schema.STRING", "topic-2":"schema.JSON"}"
	# Other function parameters

    #Update schema type of output topic for Pulsar Function
    pulsarctl functions update
	--schema-type schema.STRING
	# Other function parameters

    #Update parallelism of Pulsar Function
    pulsarctl functions update
	--parallelism 1
	# Other function parameters

    #Update resource of Pulsar Function
    pulsarctl functions update
	--ram 5656565656
	--disk 8080808080808080
	--cpu 5.0
	# Other function parameters

    #Update window functions config of Pulsar Function
    pulsarctl functions update
	--window-length-count 10
	--window-length-duration-ms 1000
	--sliding-interval-count 3
	--sliding-interval-duration-ms 1000
	# Other function parameters

OUTPUT:
    #normal output
    Updated successfully

    #Update contains no change
    [✖]  code: 400 reason: Update contains no change

    #The name of Pulsar Functions doesn't exist, please check the --name args
    [✖]  code: 404 reason: Function <your function name> doesn't exist

Usage: pulsarctl functions update [flags]

Aliases: update, update
```
  • Loading branch information
wolfstudy authored and sijie committed Sep 5, 2019
1 parent 46dba74 commit 18e5897
Show file tree
Hide file tree
Showing 14 changed files with 750 additions and 13 deletions.
10 changes: 8 additions & 2 deletions pkg/ctl/functions/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func createFunctionsCmd(vc *cmdutils.VerbCmd) {
var out []pulsar.Output
successOut := pulsar.Output{
Desc: "normal output",
Out: "Created successfully",
Out: "Created <the name of a Pulsar Function> successfully",
}

out = append(out, successOut)
Expand Down Expand Up @@ -382,7 +382,7 @@ func createFunctionsCmd(vc *cmdutils.VerbCmd) {
flagSet.BoolVar(
&functionData.AutoAck,
"auto-ack",
false,
true,
"Whether or not the framework acknowledges messages automatically")

flagSet.Int64Var(
Expand Down Expand Up @@ -412,6 +412,12 @@ func doCreateFunctions(vc *cmdutils.VerbCmd, funcData *pulsar.FunctionData) erro
return err
}

err = validateFunctionConfigs(funcData.FuncConf)
if err != nil {
vc.Command.Help()
return err
}

admin := cmdutils.NewPulsarClientWithApiVersion(pulsar.V3)

if isFunctionPackageUrlSupported(funcData.Jar) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/functions/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func deleteFunctionsCmd(vc *cmdutils.VerbCmd) {
var out []pulsar.Output
successOut := pulsar.Output{
Desc: "normal output",
Out: "Deleted successfully",
Out: "Deleted <the name of a Pulsar Function> successfully",
}

failOut := pulsar.Output{
Expand Down
1 change: 1 addition & 0 deletions pkg/ctl/functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func Command(flagGrouping *cmdutils.FlagGrouping) *cobra.Command {
cmdutils.AddVerbCmd(flagGrouping, resourceCmd, restartFunctionsCmd)
cmdutils.AddVerbCmd(flagGrouping, resourceCmd, listFunctionsCmd)
cmdutils.AddVerbCmd(flagGrouping, resourceCmd, getFunctionsCmd)
cmdutils.AddVerbCmd(flagGrouping, resourceCmd, updateFunctionsCmd)

return resourceCmd
}
2 changes: 1 addition & 1 deletion pkg/ctl/functions/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func restartFunctionsCmd(vc *cmdutils.VerbCmd) {
var out []pulsar.Output
successOut := pulsar.Output{
Desc: "normal output",
Out: "Restarted successfully",
Out: "Restarted <the name of a Pulsar Function> successfully",
}

failOut := pulsar.Output{
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/functions/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func startFunctionsCmd(vc *cmdutils.VerbCmd) {
var out []pulsar.Output
successOut := pulsar.Output{
Desc: "normal output",
Out: "Started successfully",
Out: "Started <the name of a Pulsar Function> successfully",
}

failOut := pulsar.Output{
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/functions/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func stopFunctionsCmd(vc *cmdutils.VerbCmd) {
var out []pulsar.Output
successOut := pulsar.Output{
Desc: "normal output",
Out: "Stopped successfully",
Out: "Stopped <the name of a Pulsar Function> successfully",
}

failOut := pulsar.Output{
Expand Down
Loading

0 comments on commit 18e5897

Please sign in to comment.