Re: Python, C++: Connecting, creating a session

2009-02-12 Thread Gordon Sim

Rafael Schloming wrote:

Jonathan Robie wrote:
C++ seems simpler and cleaner to me here. You create a Connection 
object, open it, then use it to create a Session object:


C++:
=

Connection connection;

try {
  connection.open(host, port);
  Session session =  connection.newSession();


Python is more complex, because it requires:

   * a socket object
   * connection.start()
   * a unique identifier that I specify


Python:
==

socket = connect(host, port)
connection = Connection (sock=socket, username=user, password=password)
connection.start()
session = connection.session(str(uuid4()))



Should we make the Python API ape C++ here?


Here are my thoughts in no particular order:

 - How does the C++ connect work without a username and password?


That can be specified on Connection::open() either through the passed in 
ConnectionSetttings (preferred at present as this allows setting of 
various options including tcp/ssl/rdma) or as arguments with defaults in 
the other two cases.


 - I can buy adding a static convenience method similar to the C++ one, 
although I'd expect a username and password somewhere as well. I think 
we should preserve the ability to pass in a socket from an arbitrary 
source though. This can be quite handy.


 - I think the C++ API should probably permit an explicitly chosen 
session name as well, but the certainly both could default to creating 
the uuid when no session name is specified.


A user supplied name can indeed be passed in to the 
Connection::newSession() method in c++ and defaults to a uuid if none is 
specified.


-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org



Re: Python, C++: Connecting, creating a session

2009-02-12 Thread Gordon Sim

Rafael Schloming wrote:

Gordon Sim wrote:

 - How does the C++ connect work without a username and password?


That can be specified on Connection::open() either through the passed 
in ConnectionSetttings (preferred at present as this allows setting of 
various options including tcp/ssl/rdma) or as arguments with defaults 
in the other two cases.


My initial inclination would be to do that through keyword args in 
python rather than having an extra ConnectionSettings object. Is there a 
specific reason the ConnectionSettings way is preferred for C++ or is it 
just style?


There are a fair amount of different options and a separate struct to 
hold them seemed cleaner in c++. I wouldn't view that as something that 
had to be identical in python though.


 - I can buy adding a static convenience method similar to the C++ 
one, although I'd expect a username and password somewhere as well. I 
think we should preserve the ability to pass in a socket from an 
arbitrary source though. This can be quite handy.


 - I think the C++ API should probably permit an explicitly chosen 
session name as well, but the certainly both could default to 
creating the uuid when no session name is specified.


A user supplied name can indeed be passed in to the 
Connection::newSession() method in c++ and defaults to a uuid if none 
is specified.


What happens if you call newSession() and supply the same name twice? 
The python API returns the old session, which is why the method is 
called session rather than newSession or createSession or some such.


You would get an error due to the session being in use. In the c++ api 
the newSession() always returns a new session.


-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org



Python, C++: Connecting, creating a session

2009-02-11 Thread Jonathan Robie
C++ seems simpler and cleaner to me here. You create a Connection 
object, open it, then use it to create a Session object:


C++:
=

Connection connection;

try {
  connection.open(host, port);
  Session session =  connection.newSession();


Python is more complex, because it requires:

   * a socket object
   * connection.start()
   * a unique identifier that I specify


Python:
==

socket = connect(host, port)
connection = Connection (sock=socket, username=user, password=password)
connection.start()
session = connection.session(str(uuid4()))



Should we make the Python API ape C++ here?

Jonathan

-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org



Re: Python, C++: Connecting, creating a session

2009-02-11 Thread Rafael Schloming

Jonathan Robie wrote:
C++ seems simpler and cleaner to me here. You create a Connection 
object, open it, then use it to create a Session object:


C++:
=

Connection connection;

try {
  connection.open(host, port);
  Session session =  connection.newSession();


Python is more complex, because it requires:

   * a socket object
   * connection.start()
   * a unique identifier that I specify


Python:
==

socket = connect(host, port)
connection = Connection (sock=socket, username=user, password=password)
connection.start()
session = connection.session(str(uuid4()))



Should we make the Python API ape C++ here?


Here are my thoughts in no particular order:

 - How does the C++ connect work without a username and password?

 - I can buy adding a static convenience method similar to the C++ one, 
although I'd expect a username and password somewhere as well. I think 
we should preserve the ability to pass in a socket from an arbitrary 
source though. This can be quite handy.


 - I think the C++ API should probably permit an explicitly chosen 
session name as well, but the certainly both could default to creating 
the uuid when no session name is specified.


--Rafael

-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org



Re: Python, C++: Connecting, creating a session

2009-02-11 Thread Aidan Skinner
On Wed, Feb 11, 2009 at 5:32 PM, Rafael Schloming rafa...@redhat.com wrote:

  - I can buy adding a static convenience method similar to the C++ one,
 although I'd expect a username and password somewhere as well. I think we
 should preserve the ability to pass in a socket from an arbitrary source
 though. This can be quite handy.

Arbitrary sockets are really quite handy. Martin added one to the Java
client to do this last year.

- Aidan

-- 
Apache Qpid - World Domination through Advanced Message Queueing
http://qpid.apache.org

-
Apache Qpid - AMQP Messaging Implementation
Project:  http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org