Skip to content
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.

Added support to send different headers, apiRoot and different query param values to candidate, primary and secondary servers #43

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sukalpomitra
Copy link

You can send different HTTP Header Key value pairs to candidate, primary and secondary servers. Add -candidateHeaders=Authorization:Basic OtxGHYUI, userRole:admin1 -primaryHeaders=Authorization:Basic NjhmskT, userRole:admin2 -secondaryHeaders=Authorization:Basic Tysfdg, userRole:admin3 to your command line arguments

You can add apiRoots to the api calls to candidate, primary and secondary servers. Add -candidateApiRoot="api/v2" -primaryApiRoot="api/v1" -secondaryApiroot="api/v1" to your command line arguments. Usage:- curl 'localhost:8880/getAllMessages' will send a request candidateServer:candidatePort/api/v2/getAllMessages to candidate server while it will send primaryServer:primaryPort/api/v1/getAllMessages to primary server

You can now substitute different queryParam values before multicasting to the three different servers. Usage:- curl 'localhost:8880/api/getUserMessages?message=userId'. Create a file apiParams.xml with the following structure
<apiParams> <userId> <candidate> 12 </candidate> <primary> 13 </primary> <secondary> 14 </secondary> </userId> </apiParams>
This will send a request candidateServer:candidatePort/api/getUserMessages?message=12 to candidate server while sending primaryServer:primaryPort/api/getUserMessages?message=13 and secondaryServer:secondaryPort/api/getUserMessages?message=14 request to primary and secondary servers respectively.

@sukalpomitra
Copy link
Author

hi @puneetkhanduri these two tests failed on my local machine too. But I donot know why. The changes I have done should not effect those test cases.

@sukalpomitra
Copy link
Author

Ok figured out why the test cases were failing. While I was treating the request as HttpRequest the test case was sending string. Added a check to execute my code only when the request is an HttpRequest. Test cases are passing now. Willc ommit soon.

… only when the request is an instance of httprequest
@sukalpomitra
Copy link
Author

hi @puneetkhanduri I think now the coverage test is failing. Don't understand why from the logs though.

@codecov-io
Copy link

Current coverage is 36.59%

Merging #43 into master will increase coverage by <.01%

  1. 6 files (not in diff) in ...la/com/twitter/diffy were modified. more
    • Misses +1
    • Hits -1
@@             master        #43   diff @@
==========================================
  Files            29         29          
  Lines           789        850    +61   
  Methods         772        833    +61   
  Messages          0          0          
  Branches         17         17          
==========================================
+ Hits            288        311    +23   
- Misses          501        539    +38   
  Partials          0          0          

Powered by Codecov. Last updated by 8586972...18507a3

@@ -3,15 +3,95 @@ package com.twitter.diffy.proxy
import com.twitter.finagle.Service
import com.twitter.util.{Future, Try}

class SequentialMulticastService[-A, +B](
services: Seq[Service[A, B]])
import org.jboss.netty.handler.codec.http.HttpRequest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generic provides a common protocol-agnostic abstraction to multicast something to an arbitrary number of destinations. The concern of having target specific headers belongs to the HttpDifferenceProxy implementation and should live there.

Further, instead of creating 3 different versions of the request before sending any of them to the targets perhaps you could compose each target with a Filter that independently re-writes whatever requests it receives before forwarding it to the underlying target.

@sukalpomitra
Copy link
Author

I will try to find some time and do the changes suggested

@savakarv
Copy link

@sukalpomitra This PR is still open. Did you figure out a different way to send headers? I am trying out diffy and I met with this requirement of sending headers. cc @puneetkhanduri

@sukalpomitra
Copy link
Author

@savakarv I moved on to other projects and did not have time to fix it. Why dont you fork mine and continue.

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ sukalpo.mitra
❌ sukalpomitra


sukalpo.mitra seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants