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

[feature][functions] Add admin CLI command to get available built-in functions #16822

Merged
merged 1 commit into from
Aug 28, 2022

Conversation

cbornet
Copy link
Contributor

@cbornet cbornet commented Jul 27, 2022

Motivation

Same as sinks available-sinks and sources available-sources but for Functions.

Modifications

  • Add HTTP endpoints admin/v3/functions/builtins to broker and function worker.
  • Add Java admin SDK function getBuiltInFunctions and getBuiltInFunctionsAsync methods.
  • Add admin CLI command functions available-functions

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change added tests and can be verified as follows:

There are no tests for the builtin sinks/source. Shouldn't we add it in another PR ?

Does this pull request potentially affect one of the following parts:

yes

If yes was chosen, please highlight the changes

  • The public API: yes
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no
  • The rest endpoints: yes
  • The admin cli options: yes
  • Anything that affects deployment: no

Documentation

Check the box below or label this PR directly.

Need to update docs?

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

@cbornet cbornet force-pushed the list-functions branch 2 times, most recently from b6ff1ec to a9055c4 Compare July 27, 2022 15:26
private final AsyncHttpClient asyncHttpClient;

public FunctionsImpl(WebTarget web, Authentication auth, AsyncHttpClient asyncHttpClient, long readTimeoutMs) {
super(auth, readTimeoutMs);
this.functions = web.path("/admin/v3/functions");
this.worker = web.path("/admin/v2/worker");
Copy link
Contributor Author

@cbornet cbornet Jul 27, 2022

Choose a reason for hiding this comment

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

Should available-functions be a command of pulsar-admin workers instead ?
For now, I've put it in pulsar-admin functions for consistency with sinks and sources.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for pulsar-admin functions. However it's a bit weird that the rest endpoint is under "/worker"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because we have the list of connectors under /worker.
Now we also have the list of sinks under /sinks and the list of sources under /sources.
So I think we can indeed have the list of functions under /functions

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

It seems not only "builtin functions", but all available functions?

@cbornet
Copy link
Contributor Author

cbornet commented Jul 27, 2022

It's only builtin functions. It's the same as for sinks and sources.
The name available-functions/available-sinks/available-sources are indeed confusing.
We can change to builtin-functions which is more accurate but is not coherent with sinks/sources.

@cbornet cbornet changed the title Add admin CLI command to get available built-in functions [feature][functions] Add admin CLI command to get available built-in functions Jul 27, 2022
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Jul 27, 2022
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

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

Good work!

@ApiResponses(value = {
@ApiResponse(code = 200, message = "Get builtin functions successfully.")
})
@Path("/builtinfunctions")
Copy link
Contributor

@nicoloboschi nicoloboschi Aug 17, 2022

Choose a reason for hiding this comment

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

IMO if we want to follow the same as the "/connectors" above, this endpoint should be "/functions"

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that "buildinfunctions" is clearer.
"functions" may look like to refer to "all the functions"

not a big deal

responseContainer = "List"
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Get builtin functions successfully.")
Copy link
Contributor

Choose a reason for hiding this comment

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

what about error responses ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added them. PTAL

private final AsyncHttpClient asyncHttpClient;

public FunctionsImpl(WebTarget web, Authentication auth, AsyncHttpClient asyncHttpClient, long readTimeoutMs) {
super(auth, readTimeoutMs);
this.functions = web.path("/admin/v3/functions");
this.worker = web.path("/admin/v2/worker");
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for pulsar-admin functions. However it's a bit weird that the rest endpoint is under "/worker"

void runCmd() throws Exception {
getAdmin().functions().getBuiltInFunctions()
.forEach(function -> {
System.out.println(function.getName());
Copy link
Contributor

Choose a reason for hiding this comment

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

could we create a common method to display this kind of stuff ? (sinks, sources, functions..)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Between source and sink maybe. But between Function and Connectors, we handle distinct classes that are unrelated (FunctionDefinition and ConnectorDefinition) so I don't think we can factorize.

@cbornet cbornet force-pushed the list-functions branch 2 times, most recently from e4ce5e6 to b851267 Compare August 17, 2022 16:02
@cbornet
Copy link
Contributor Author

cbornet commented Aug 17, 2022

I changed the location of the endpoint from /worker to /functions for more consistency. PTAL.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@cbornet cbornet closed this Aug 26, 2022
@cbornet cbornet reopened this Aug 26, 2022
@cbornet cbornet closed this Aug 27, 2022
@cbornet cbornet reopened this Aug 27, 2022
@eolivelli eolivelli merged commit 34eb74d into apache:master Aug 28, 2022
Pomelongan pushed a commit to Pomelongan/pulsar that referenced this pull request Aug 28, 2022
@cbornet cbornet deleted the list-functions branch August 29, 2022 07:48
@momo-jun
Copy link
Contributor

@cbornet It will help users a lot if you can add the docs for this feature. Do you have any plans on that?

@Technoboy- Technoboy- added this to the 2.12.0 milestone Sep 27, 2022
@Technoboy- Technoboy- added type/feature The PR added a new feature or issue requested a new feature area/function labels Sep 27, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Sep 29, 2022
@cbornet
Copy link
Contributor Author

cbornet commented Nov 18, 2022

Isn't doc for this auto-generated?

@tisonkun
Copy link
Member

@momo-jun
Copy link
Contributor

Yes, the reference doc can be auto-generated now. Besides the reference info, do you have any other additional information to add in the Pulsar doc site to actively promote this feature? If not, the label can be changed to doc-complete.

@cbornet
Copy link
Contributor Author

cbornet commented Nov 23, 2022

I opened #18569 to add doc for built-in functions that gives more context.

@cbornet
Copy link
Contributor Author

cbornet commented Nov 23, 2022

available-functions and reload have not been picked into 2.11. Will the reference be re-generated with the 2.11 code when it's released ?

@tisonkun
Copy link
Member

tisonkun commented Nov 23, 2022

@cbornet I think so. Generally, if we release on time, this won't be a big issue, but 2.11.0 takes more than three months to release. Also, I'm considering versioned docs along with release branches, or cutting new versioned docs on feature freeze (along with cutting the branch), but all of them requires concrete proposals, and I assume to take care of it in months.

For current status, ping @Technoboy- the RM of 2.11.0 FYI. And perhaps we revert the related sections after the docs cut. This is the same as Pulsar SQL's caveat (https://pulsar.apache.org/docs/next/sql-overview#caveat) so you may also add a note for versions as a workaround (we should not have it with a proper process ).

@momo-jun momo-jun added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/function doc-complete Your PR changes impact docs and the related docs have been already added. type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants