You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/09/30 16:46:31 UTC
[GitHub] [camel] essobedo opened a new pull request, #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
essobedo opened a new pull request, #8452:
URL: https://github.com/apache/camel/pull/8452
Fix for https://issues.apache.org/jira/browse/CAMEL-10173
## Motivation
The API v3 of etcd should be supported by Camel and for this, we would like to propose a new component based on https://github.com/etcd-io/jetcd.
## Modifications:
* Add a new test infra for Integration tests with etcd v3
* Convert the test for the AggregationRepository into an integration test
* Propose a consumer and a producer based on jetcd and the legacy code.
* Propose a ServiceSupport based on jetcd and the legacy code.
* Propose a RoutePolicy based on jetcd and the legacy code. The leadership management relies on a lease with TTL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1265182976
@davsclaus @oscerd I've just proposed an asynchronous/non-blocking producer instead of a synchronous/blocking one because the client allows us to do it easily. What do you prefer in this case and in general?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1265250931
:heavy_check_mark: Finished component verification: 0 component(s) test failed out of **4 component(s) tested**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1265517982
:x: Finished component verification: **1 component(s) test failed** out of 6 component(s) tested
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1263938656
:heavy_check_mark: Finished component verification: 0 component(s) test failed out of **1 component(s) tested**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] github-actions[bot] commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1263796723
:warning: This PR changes Camel components and will be tested automatically.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
davsclaus commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1265405713
yeah its up to the component developer, but the async is usually better but can be harder to implemenent, and also ensure to trigger camel callback.done(false) in all the places needed to continue routing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] essobedo commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
essobedo commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1263809652
@lburgazzoli it would be great if you could review it as you know well jetcd, you are the reporter of the ticket and you seem to be very familiar with route policies. Thx in advance 🙏
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] oscerd commented on pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
oscerd commented on PR #8452:
URL: https://github.com/apache/camel/pull/8452#issuecomment-1265190624
There is no preferences in general. It's up to the contributor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on a diff in pull request #8452: CAMEL-10173: camel-etcd3 - Add an implementation based on jetcd
Posted by GitBox <gi...@apache.org>.
davsclaus commented on code in PR #8452:
URL: https://github.com/apache/camel/pull/8452#discussion_r985757732
##########
components/camel-etcd3/src/main/java/org/apache/camel/component/etcd3/Etcd3Producer.java:
##########
@@ -47,73 +78,151 @@ class Etcd3Producer extends DefaultProducer {
}
@Override
- public void process(Exchange exchange) throws Exception {
- String action = exchange.getIn().getHeader(Etcd3Constants.ETCD_ACTION, String.class);
- String targetPath = exchange.getIn().getHeader(Etcd3Constants.ETCD_PATH, String.class);
- if (targetPath == null) {
- targetPath = path;
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ try {
+ String action = exchange.getIn().getHeader(Etcd3Constants.ETCD_ACTION, String.class);
+ String targetPath = exchange.getIn().getHeader(Etcd3Constants.ETCD_PATH, String.class);
+ if (targetPath == null) {
+ targetPath = path;
+ }
+
+ StringHelper.notEmpty(targetPath, Etcd3Constants.ETCD_PATH);
+ StringHelper.notEmpty(action, Etcd3Constants.ETCD_ACTION);
+
+ switch (action) {
+ case Etcd3Constants.ETCD_KEYS_ACTION_SET:
+ processSetAsync(targetPath, exchange, callback);
+ break;
+ case Etcd3Constants.ETCD_KEYS_ACTION_GET:
+ processGetAsync(targetPath, exchange, callback);
+ break;
+ case Etcd3Constants.ETCD_KEYS_ACTION_DELETE:
+ processDelAsync(targetPath, exchange, callback);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown action " + action);
+ }
+ } catch (Exception e) {
+ exchange.setException(e);
+ callback.done(true);
+ return true;
}
+ return false;
+ }
- StringHelper.notEmpty(targetPath, Etcd3Constants.ETCD_PATH);
- StringHelper.notEmpty(action, Etcd3Constants.ETCD_ACTION);
-
- switch (action) {
- case Etcd3Constants.ETCD_KEYS_ACTION_SET:
- processSet(targetPath, exchange);
- break;
- case Etcd3Constants.ETCD_KEYS_ACTION_GET:
- processGet(targetPath, exchange);
- break;
- case Etcd3Constants.ETCD_KEYS_ACTION_DELETE:
- processDel(targetPath, exchange);
- break;
- default:
- throw new IllegalArgumentException("Unknown action " + action);
+ @Override
+ protected void doStop() throws Exception {
+ try {
+ client.close();
+ } finally {
+ super.doStop();
}
}
- private void processDel(String targetPath, Exchange exchange) throws Exception {
- exchange.getIn().setBody(
+ /**
+ * Add actions to perform once the given future is complete.
+ *
+ * @param future the future to complete with specific actions.
+ * @param exchange the exchange into which the result of the future (response or exception) is set.
+ * @param callback the callback to call once the future is done.
+ * @param <T> the result type returned by the future.
+ */
+ private <T> void onComplete(CompletableFuture<T> future, Exchange exchange, AsyncCallback callback) {
+ future.thenAccept(r -> exchange.getIn().setBody(r))
+ .whenComplete(
+ (r, e) -> {
+ try {
+ if (e != null) {
+ exchange.setException(new CamelException(e));
Review Comment:
You can set an CamelExchangeException when you have access to the exchange causing this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org