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

first design stab at API refactor #39

Merged
merged 33 commits into from
Feb 2, 2016
Merged

first design stab at API refactor #39

merged 33 commits into from
Feb 2, 2016

Conversation

mrtazz
Copy link
Owner

@mrtazz mrtazz commented Jan 12, 2016

this splits up the way to interact with endpoints into a simple and an
advanced usage way. The simple way mostly corresponds to the old API. The new
way is via a connection object that can be configured with different
properties.

related to #27, #31, #33

this splits up the way to interact with endpoints into a simple and an
advanced usage way. The simple way mostly corresponds to the old API. The new
way is via a `connection` object that can be configured with different
properties.

related to #27, #31, #33
@mrtazz mrtazz self-assigned this Jan 12, 2016
@mrtazz mrtazz added this to the v0.4.0 milestone Jan 12, 2016
@mrtazz
Copy link
Owner Author

mrtazz commented Jan 12, 2016

@mheffner if you have any feedback on the API design, I'd super appreciate it :)

@mrtazz
Copy link
Owner Author

mrtazz commented Jan 12, 2016

Hmm maybe the underlying semantics are better conveyed with an API like

conn = new Connection("http://example.com")
conn->get("/resource")

#include "restclient-cpp/restclient.h"

// initialize RestClient
RestClient::init();

Choose a reason for hiding this comment

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

What would this do in the per-connection case? Could this be handled inside Restclient in a call_once block?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll have to investigate this further, but this is what libcurl says about the global functions:

It isn't actually required that the functions be called at the beginning and end of the program -- that's just usually the easiest way to do it. It is required that the functions be called when no other thread in the program is running.

And if I want to retain the simple declaration that it's safe to use the connection object from within threads, then I can't do the call_once in there as I can't guarantee there aren't any other threads running. I think for the simple API this is fair and makes it a lot nicer to use.

Choose a reason for hiding this comment

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

Yep, sounds good. I think it's fine to keep then.

@mrtazz
Copy link
Owner Author

mrtazz commented Jan 31, 2016

ok this should be the first draft implementation of the new API. I punted on the request builder functionality as I think repeating something like conn->get("/foo") is easy enough and the builder would make it more confusing. Gonna let this sit here for a bit and then merge it to master.

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.

2 participants