- 
                Notifications
    You must be signed in to change notification settings 
- Fork 54
Http sink retries #181
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
          
     Open
      
      
            jonathanlehto
  wants to merge
  5
  commits into
  getindata:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
jonathanlehto:http-sink-retries
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +863
        
        
          −487
        
        
          
        
      
    
  
  
     Open
                    Http sink retries #181
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c86109d
              
                Enable HTTP Sink request retries
              
              
                 387c37c
              
                Add tests
              
              
                 356e224
              
                Add RateLimitingStrategy
              
              
                 f984210
              
                Add Http Sink capability, DeliveryMode support, introduce http lookup…
              
              
                jonathanlehto 392e1f8
              
                Merge branch 'main' into http-sink-retries
              
              
                jonathanlehto File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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 hidden or 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
    
  
  
    
              
        
          
          
            17 changes: 17 additions & 0 deletions
          
          17 
        
  ...main/java/com/getindata/connectors/http/BatchHttpStatusCodeValidationFailedException.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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,17 @@ | ||
| package com.getindata.connectors.http; | ||
|  | ||
| import java.util.List; | ||
|  | ||
| import lombok.Getter; | ||
|  | ||
| import com.getindata.connectors.http.internal.sink.httpclient.HttpRequest; | ||
|  | ||
| @Getter | ||
| public class BatchHttpStatusCodeValidationFailedException extends Exception { | ||
| List<HttpRequest> failedRequests; | ||
|  | ||
| public BatchHttpStatusCodeValidationFailedException(String message, List<HttpRequest> failedRequests) { | ||
| super(message); | ||
| this.failedRequests = failedRequests; | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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 hidden or 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
    
  
  
    
              
        
          
          
            47 changes: 39 additions & 8 deletions
          
          47 
        
  src/main/java/com/getindata/connectors/http/internal/SinkHttpClientResponse.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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 | 
|---|---|---|
| @@ -1,31 +1,62 @@ | ||
| package com.getindata.connectors.http.internal; | ||
|  | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|  | ||
| import lombok.Data; | ||
| import lombok.NonNull; | ||
| import lombok.ToString; | ||
|  | ||
| import com.getindata.connectors.http.internal.config.ResponseItemStatus; | ||
| import com.getindata.connectors.http.internal.sink.HttpSinkRequestEntry; | ||
| import com.getindata.connectors.http.internal.sink.httpclient.HttpRequest; | ||
|  | ||
| /** | ||
| * Data class holding {@link HttpSinkRequestEntry} instances that {@link SinkHttpClient} attempted | ||
| * to write, divided into two lists — successful and failed ones. | ||
| * to write. | ||
| */ | ||
| @Data | ||
| @ToString | ||
| public class SinkHttpClientResponse { | ||
|  | ||
| /** | ||
| * A list of successfully written requests. | ||
| * A list of requests along with write status. | ||
| */ | ||
| @NonNull | ||
| private final List<HttpRequest> successfulRequests; | ||
| private final List<ResponseItem> requests; | ||
|  | ||
| /** | ||
| * A list of requests that {@link SinkHttpClient} failed to write. | ||
| */ | ||
| @NonNull | ||
| private final List<HttpRequest> failedRequests; | ||
| public List<HttpRequest> getSuccessfulRequests() { | ||
| return requests.stream() | ||
| .filter(r -> r.getStatus().equals(ResponseItemStatus.SUCCESS)) | ||
| .map(ResponseItem::getRequest) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|  | ||
| public List<HttpRequest> getFailedRequests() { | ||
| return requests.stream() | ||
| .filter(r -> r.getStatus().equals(ResponseItemStatus.FAILURE)) | ||
| .map(ResponseItem::getRequest) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|  | ||
| public List<HttpRequest> getTemporalRequests() { | ||
| return requests.stream() | ||
| .filter(r -> r.getStatus().equals(ResponseItemStatus.TEMPORAL)) | ||
| .map(ResponseItem::getRequest) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|  | ||
| public List<HttpRequest> getIgnoredRequests() { | ||
| return requests.stream() | ||
| .filter(r -> r.getStatus().equals(ResponseItemStatus.IGNORE)) | ||
| .map(ResponseItem::getRequest) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|  | ||
| @Data | ||
| @ToString | ||
| public static class ResponseItem { | ||
| private final HttpRequest request; | ||
| private final ResponseItemStatus status; | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
              
        
          
          
            18 changes: 18 additions & 0 deletions
          
          18 
        
  src/main/java/com/getindata/connectors/http/internal/config/ResponseItemStatus.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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,18 @@ | ||
| package com.getindata.connectors.http.internal.config; | ||
|  | ||
| public enum ResponseItemStatus { | ||
| SUCCESS("success"), | ||
| TEMPORAL("temporal"), | ||
| IGNORE("ignore"), | ||
| FAILURE("failure"); | ||
|  | ||
| private final String status; | ||
|  | ||
| ResponseItemStatus(String status) { | ||
| this.status = status; | ||
| } | ||
|  | ||
| public String getStatus() { | ||
| return status; | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
              
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.
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.
sink.delivery-guarantee is interesting and looks like it is a bringing this connector in line with others. When do we think we will get more that one request issued? I assume we would need more processing for exactly once.
Uh oh!
There was an error while loading. Please reload this page.
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 am lifting a big part of the code from an earlier PR, which was the source of using a delivery guarantee. However, for my personal use case, I do in fact need to guarantee at least once behavior 🙂. The current implementation has an indefinite number of retries. If we don't have the delivery guarantee, we'll need to have something like number of attempts imo. I'm fine with whatever though! I just really need retries!
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.
Exactly once is pretty challenging given that we are using HTTP requests. Imo, it would require coordination with the receiving service to response with some kind of ack in order to enforce it. I don't believe exactly once can be achieved on just the client side with HTTP requests if that makes sense. However, duplicated success message emissions should be really infrequent