Skip to content

First draft of changes to the HTTP client#56

Closed
gstein wants to merge 15 commits intobasho:masterfrom
gstein:newhttp
Closed

First draft of changes to the HTTP client#56
gstein wants to merge 15 commits intobasho:masterfrom
gstein:newhttp

Conversation

@gstein
Copy link
Copy Markdown
Contributor

@gstein gstein commented Sep 8, 2011

This branch builds from my "relax-deps" and "simplify" branches, so there are many changes relative to master. The "relax-deps" is not required, but a few of the changes in "simplify" are needed for this branch to work.

This branch is a beginning for a revamp of the original HTTP client (and elimination of the extended clients). It needs more documentation and comments, but I'd like an initial review for it.

The ConnectionManager in this branch can also be used to revamp pbc.py, but those changes are not in this branch.

multiple hosts, passing them out for use. Both HTTP and bare sockets are
supported.

* riak/transports/connection.py:
  (ConnectionManager): new base class for managing connections
  (HTTPConnectionManager): manage HTTP connections
  (Socket): new connection type, for bare sockets
  (SocketConnectionManager): manage bare socket connections
  (NoHostsDefined): simple exception when we cannot open a conn

* riak/transports/http.py:
  (RiakHttpTransport.__init__): use a connection manager
  (RiakHttpTransport.__copy__): disable for now
  (RiakHttpTransport.parse_body): can't print host/port right now
  (RiakHttpTransport.http_request): rebuild to use the connection manager.
…open

a connection to the Riak server(s) once its host/port is defined. When a
host (and port) is removed from the hostport set, then remove connections.
…t is

redundant, given the new RiakHttpTransport capabilities)
@gstein
Copy link
Copy Markdown
Contributor Author

gstein commented Sep 10, 2011

This branch passes the tests for me (many are skipped due to: no protobuf, no urllib3, SKIP_SEARCH=1, SKIP_LUWAK=1).

* riak/transports/connection.py:
  (ConnectionManager.add_hostport): fix typo: s/conn/conns/
  (Connectionmanager.remove_host): tweak control flow to move conn.close()
    outside of the try/except.
Create an appropriate CM and pass that to the transport. We also adjust
the constructor signature and allow for arbitrary options to be passed to
the transport (eg. Http takes a prefix and mapred_prefix). Some backwards
compat code has been introduced in all transports (other than the basic
RiakHttpTransport) to extract a host/port pair from the CM.

This commit also re-enables testing of RiakHttpReuseTransport, even though
it is busted and should go away "soon".
* riak/transports/transport.py:
  (RiakTransport): document the 'api' classvar, but not enter a default.
    all subclasses must provide the default explicitly.

* riak/transports/http.py:
  (RiakHttpTransport): notate the class is now API v2.

* riak/transports/pbc.py:
  (RiakPbcTransport): notate the class is now API v2.

* riak/client.py:
  (RiakClient.__init__): handle api < 2 transports

* riak/search.py:
  (RiakSearch.__init__): if api < 2, then raise a deprecation warning. the
    old code would simply fail, so we are "allowed" to bail out.
Conflicts:
	riak/util.py
         -- simple conflict due to diff context change. fixed imports.
This also closes connections whenever an error occurs, for safety. This
ensures the HTTPConnection object returns to a usable state.
@gstein
Copy link
Copy Markdown
Contributor Author

gstein commented Oct 26, 2011

This work is subsumed into the "merge_greg" branch, which is part of pull request #85.

Closing.

@gstein gstein closed this Oct 26, 2011
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