-
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
[PIP 86][Function] add funtion api to support preload and release external resources #13205
[PIP 86][Function] add funtion api to support preload and release external resources #13205
Conversation
@nlu90 @eolivelli could you please have a check |
@wangjialing218 Did you call a vote for the PIP-86 in the dev@pulsar mailing list? Also you may want to update the PIP-86 content to reflect the newest idea. It's good if we can get feedback from the community. And then start the review work. |
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.
Overall is good.
Please add unit tests and integration tests.
There is a duplicate PR for this PIP, please close the old one
...ctions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
Outdated
Show resolved
Hide resolved
pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/RichFunction.java
Outdated
Show resolved
Hide resolved
91fe81f
to
9eb10c9
Compare
9eb10c9
to
81b6818
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.
The PIP Vote has been passed.
And some updates in the PIP-86 needed to reflect the actual changes we added here.
pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Function.java
Outdated
Show resolved
Hide resolved
pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Function.java
Outdated
Show resolved
Hide resolved
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstance.java
Show resolved
Hide resolved
...ctions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java
Outdated
Show resolved
Hide resolved
625b665
to
cb623aa
Compare
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@nlu90 @eolivelli please have a check again |
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.
The change looks good.
But in your test your are not testing that the new methods are executed.
I suggest to add some static variables in the function in order to be able to check that the function runs
@eolivelli I tried to add static variables in function but failed to get correct value in test code, may be caused by different class loader, could you give some suggestion? |
@eolivelli Could you help take a look again when you are available? |
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
…ernal resources (apache#13205) ### Motivation This patch is based on apache#11112, I have talked with @wuchenxi123 and I will continue the work for this feature. ### Modifications Introduce `RichFunction` interface extends `Function`, which provide `setup` and `tearDown` API. `setup` is called only once when function instance started. `tearDown` is called when function instance closed. User could use these interface to initialize and release their external resources such as RedisClient. ### Does this pull request potentially affect one of the following parts: *If `yes` was chosen, please highlight the changes* - The public API: ( **yes**)
Motivation
This patch is based on #11112, I have talked with @wuchenxi123 and I will continue the work for this feature.
Modifications
Introduce
RichFunction
interface extendsFunction
, which providesetup
andtearDown
API.setup
is called only once when function instance started.tearDown
is called when function instance closed.User could use these interface to initialize and release their external resources such as RedisClient.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?
doc-required
I think we need to add chapter to tell user how to use the API in
functions-develop.md