-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: Support CallBack for ConnectRecord * doc: Improve some documentation * feat: Support for multi-server data callbacks * perf: Optimize some logic
- Loading branch information
Showing
16 changed files
with
603 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...ctor-http/src/main/java/org/apache/eventmesh/connector/http/sink/data/HttpRetryEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.connector.http.sink.data; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* Single HTTP retry event | ||
*/ | ||
@Data | ||
public class HttpRetryEvent { | ||
|
||
public static final String PREFIX = "http-retry-event-"; | ||
|
||
private String parentId; | ||
|
||
private int maxRetries; | ||
|
||
private int currentRetries; | ||
|
||
private Throwable lastException; | ||
|
||
/** | ||
* Increase the current retries by 1 | ||
*/ | ||
public void increaseCurrentRetries() { | ||
this.currentRetries++; | ||
} | ||
|
||
/** | ||
* Check if the current retries is greater than or equal to the max retries | ||
* @return true if the current retries is greater than or equal to the max retries | ||
*/ | ||
public boolean isMaxRetriesReached() { | ||
return this.currentRetries >= this.maxRetries; | ||
} | ||
|
||
/** | ||
* Get the limited exception message with the default limit of 256 | ||
* @return the limited exception message | ||
*/ | ||
public String getLimitedExceptionMessage() { | ||
return getLimitedExceptionMessage(256); | ||
} | ||
|
||
/** | ||
* Get the limited exception message with the specified limit | ||
* @param maxLimit the maximum limit of the exception message | ||
* @return the limited exception message | ||
*/ | ||
public String getLimitedExceptionMessage(int maxLimit) { | ||
if (lastException == null) { | ||
return ""; | ||
} | ||
String message = lastException.getMessage(); | ||
if (message == null) { | ||
return ""; | ||
} | ||
if (message.length() > maxLimit) { | ||
return message.substring(0, maxLimit); | ||
} | ||
return message; | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
.../src/main/java/org/apache/eventmesh/connector/http/sink/data/MultiHttpRequestContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.connector.http.sink.data; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
|
||
/** | ||
* Multi HTTP request context | ||
*/ | ||
public class MultiHttpRequestContext { | ||
|
||
public static final String NAME = "multi-http-request-context"; | ||
|
||
/** | ||
* The remaining requests to be processed. | ||
*/ | ||
private final AtomicInteger remainingRequests; | ||
|
||
/** | ||
* The last failed event. | ||
* If there are no retries or retries are not enabled, it will be null. | ||
* If retries occur but still fail, it will be logged, and only the last one will be retained. | ||
*/ | ||
private HttpRetryEvent lastFailedEvent; | ||
|
||
public MultiHttpRequestContext(int remainingEvents) { | ||
this.remainingRequests = new AtomicInteger(remainingEvents); | ||
} | ||
|
||
/** | ||
* Decrement the remaining requests by 1. | ||
*/ | ||
public void decrementRemainingRequests() { | ||
remainingRequests.decrementAndGet(); | ||
} | ||
|
||
public int getRemainingRequests() { | ||
return remainingRequests.get(); | ||
} | ||
|
||
public HttpRetryEvent getLastFailedEvent() { | ||
return lastFailedEvent; | ||
} | ||
|
||
public void setLastFailedEvent(HttpRetryEvent lastFailedEvent) { | ||
this.lastFailedEvent = lastFailedEvent; | ||
} | ||
} |
Oops, something went wrong.