-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
b6ff1ec
to
a9055c4
Compare
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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
There was a problem hiding this 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?
It's only builtin functions. It's the same as for sinks and sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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") |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about error responses ?
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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..)
There was a problem hiding this comment.
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.
e4ce5e6
to
b851267
Compare
I changed the location of the endpoint from |
b851267
to
55a47ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
55a47ea
to
6333b9c
Compare
@cbornet It will help users a lot if you can add the docs for this feature. Do you have any plans on that? |
(cherry picked from commit 34eb74d)
Isn't doc for this auto-generated? |
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 |
I opened #18569 to add doc for built-in functions that gives more context. |
|
@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 ). |
Motivation
Same as
sinks available-sinks
andsources available-sources
but for Functions.Modifications
admin/v3/functions/builtins
to broker and function worker.getBuiltInFunctions
andgetBuiltInFunctionsAsync
methods.functions available-functions
Verifying this change
(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 changesDocumentation
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)