Skip to content
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

Add JSON support: #6

Merged
merged 3 commits into from
Jun 18, 2014
Merged

Add JSON support: #6

merged 3 commits into from
Jun 18, 2014

Conversation

cquinn
Copy link
Contributor

@cquinn cquinn commented Jun 17, 2014

  • rpc extensions to support both XML and JSON requests and responses
  • net support for a Eureka connection using JSON or XML
  • net support for marshalling and unmarshalling of the apps, app and instance structs
  • custom unmarshallers and intermediate wrapper structs to deal with nasty Eureka JSON
  • updated existing net tests to test both XML and JSON
  • added new sample-driven tests for JSON unmarshalling. (tricky to get that working--tests were a lifesaver)

 - rpc extensions to support both XML and JSON requests and responses
 - net support for a Eureka connection using JSON or XML
 - net support for marshalling and unmarshalling of the apps, app and instance structs
 - custom unmarshallers and intermediate wrapper structs to deal with nasty Eureka JSON
@cquinn
Copy link
Contributor Author

cquinn commented Jun 17, 2014

We have a need at our company (Riot Games) to use the JSON flavor of Eureka's REST API. This pull request adds that support to fargo in an optional way. I've made a few other changes that I'll comment on inline.

Let me know if you are interested in this change in general, and I'll make sure that I've cleaned up anything you don't like. There are definitely some debug / comment bits in there that need some cleanup before committing.

@@ -0,0 +1,104 @@
package fargo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where I put the custom JSON unmarshalling

@ryansb
Copy link
Contributor

ryansb commented Jun 17, 2014

I'd definitely be interested in this. Most of the reason there isn't JSON support already is the gotchas in the Eureka JSON API.

I've made some comments, but this is definitely worth working on. Thanks a ton for your contributions.

Split out instance retrieval needed in ReregisterInstance() into new functions GetInstance() and readInstanceInto()
Small change to readAppInto() to match simpler form in readInstanceInto()
@cquinn
Copy link
Contributor Author

cquinn commented Jun 17, 2014

OK, I think I've addressed all your comments.

if err = json.Unmarshal(b, &ii); err == nil {
marshalLog.Debug("Instance.UnmarshalJSON ii:%+v\n", ii)
*i = Instance(ii)
i.Port, _ = strconv.Atoi(ii.PortJ.Number)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably fine, but ignoring the err case here gives me pause. Maybe log if there's a problem?

@ryansb
Copy link
Contributor

ryansb commented Jun 18, 2014

Looks great. Just a couple nitpicks then I'll merge it and tag a new release.

@cquinn
Copy link
Contributor Author

cquinn commented Jun 18, 2014

I think all your comments are addressed now.

ryansb added a commit that referenced this pull request Jun 18, 2014
Add JSON support: (credit: @cquinn)
@ryansb ryansb merged commit 0dffa3a into hudl:master Jun 18, 2014
@ryansb
Copy link
Contributor

ryansb commented Jun 18, 2014

Great, thanks!

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

Successfully merging this pull request may close these issues.

3 participants