[openstack-dev] [openstack-sdk-php] Transport Clients, Service Clients, and state
Jamie Hannaford
jamie.hannaford at rackspace.com
Fri Jun 6 12:47:10 UTC 2014
Whether the same one is used for each service or a new one is used for each service doesn't matter.
Yes, it does matter IMO - and here are the reasons why:
1. By sharing a global transport object you’re introducing the risk of side effects. A transport object contains state that can be modified by its service object. Somewhere along the line, a Swift service could introduce a state modification that’s completely incompatible with a Nova service. What’s worse is that it will be a nightmare to debug - you’d have to trawl the entire service to see points where it interacts with the transport client. This is why people don’t use singletons - it’s incredibly risky and hard to debug. Object instantiations, on the other hand, are cheap and they offer protection through isolation.
2. Certain services rely on custom transport configurations. Each transport client has a base URL that is used for issuing HTTP requests - every time you execute a request, you’re effectively adding relevant paths for that API operation. A Swift service will have different URL endpoints from a Nova one - so there’s no point sharing. Another example is custom headers. Marconi requests custom headers to be sent, as does Glance. You save these as default headers on the transport client, that are sent for all requests that the service executes. These custom headers are not applicable to any other service except Marconi/Glance.
In the use-cases you mentioned, you’d easily handle that. You’d pass in proxy settings through the OpenStack entry point (like you do with your username and password), which would then percolate down into the transport clients as they’re created. These settings would be injected into each transport client. So if you require a different set-up for public clouds - that’s fine - you define different settings and fire up another $openstack object.
-OR- you could define different transport settings for different services - by passing them into the $openstack->get(‘compute’, [‘custom_settings’ => true]); call. This is great because it gives users the ability to apply custom transport options to certain services. So if I want to interact with a private Compute instance, I’d pass in a custom transport configuration for that service; if I wanted to use a proxy with my Swift service, I can pass details into that service when creating it. You can only do this (provide custom transport settings for 1 service) if each transport client is isolated, i.e. if there’s a 1-to-1 relationship between service and transport client. If you have a global one, you couldn’t introduce custom settings per service because it’d affect ALL others, which is a bad user experience.
Jamie
On June 5, 2014 at 6:33:34 PM, Matthew Farina (matt at mattfarina.com<mailto:matt at mattfarina.com>) wrote:
> My opinion is that we create a new transport client instance for every service client, not re-use existing instances. What’s your take on this?
I'm not in agreement and here is why (with a use case).
A transport client is concerned with transporting only. Whether the same one is used for each service or a new one is used for each service doesn't matter.
An example of using two transport clients would be a case where an application communicates with two different OpenStack clouds. One is a public cloud and the application communicates through a proxy. A transport client would know how to talk through the proxy to the public cloud. A second OpenStack cloud is a private cloud that is on the same company network. A second transport client would know how to talk to that without communicating through the proxy.
The service clients communicating with each cloud would use the appropriate transport client.
The mapping of transport client to service client doesn't need to be 1:1 if they operate in different spaces. Only having instances of a transport client as needed decreases the use of resources or the time needed to manage those.
If a transport client is only concerned with transporting than what is the need to have more than one per case to transport?
- Matt
On Thu, Jun 5, 2014 at 12:09 PM, Jamie Hannaford <jamie.hannaford at rackspace.com<mailto:jamie.hannaford at rackspace.com>> wrote:
I completely agree with you regarding separation of concerns.
I also agree with your definitions: a transport client is for managing HTTP transactions, a service client contains all the domain logic for an API service (Swift, Nova, etc.). A service knows nothing about HTTP, a transport client knows nothing about Swift. A transport client is injected into the service client, satisfying the type hint. So any transport client implementing our interface is fine.
Up to this point I’m in 100% agreement. The area which I think I misunderstood was the creation process of service clients. My take was that you were advocating a shared transport client instance - i.e. a transport client instantiated once, and re-used for every service client. If we did that, there would be global state.
My opinion is that we create a new transport client instance for every service client, not re-use existing instances. What’s your take on this?
Jamie
On June 5, 2014 at 5:17:57 PM, Matthew Farina (matt at mattfarina.com<mailto:matt at mattfarina.com>) wrote:
We've started to talk about the interactions between transport
clients, service clients, and state. I've noticed we're not on the
same page so I wanted to start a dialog. Here's my starting point...
A Transport Client is about transporting data. It sends and receives data.
A Service Client handles the interactions with a service (e.g., swift,
nova, keystone).
A Service Client uses a Transport Client when it needs to transport
data to and from a service.
When it comes to state, a Transport Client knows about transporting
things. That means it knows things like if there is a proxy and how to
work with it. A Service Client knows about a service which includes
and state for that service.
In the realm of separation of concerns, a Service Client doesn't know
about transport state and a Transport Client doesn't know about
service state. They are separate.
A Service Client doesn't care what Transport Client is used as long as
the API (interface) is compliant. A Transport Client doesn't care what
code calls it as long as it uses the public API defined by an
interface.
This is my take. If someone has a different take please share it with
the reasoning.
- Matt
Jamie Hannaford
Software Developer III - CH [experience Fanatical Support]
Tel: +41434303908<tel:%2B41434303908>
Mob: +41791009767<tel:%2B41791009767>
[Rackspace]
Rackspace International GmbH a company registered in the Canton of Zurich, Switzerland (company identification number CH-020.4.047.077-1) whose registered office is at Pfingstweidstrasse 60, 8005 Zurich, Switzerland. Rackspace International GmbH privacy policy can be viewed at www.rackspace.co.uk/legal/swiss-privacy-policy<http://www.rackspace.co.uk/legal/swiss-privacy-policy>
-
Rackspace Hosting Australia PTY LTD a company registered in the state of Victoria, Australia (company registered number ACN 153 275 524) whose registered office is at Suite 3, Level 7, 210 George Street, Sydney, NSW 2000, Australia. Rackspace Hosting Australia PTY LTD privacy policy can be viewed at www.rackspace.com.au/company/legal-privacy-statement.php<http://www.rackspace.com.au/company/legal-privacy-statement.php>
-
Rackspace US, Inc, 5000 Walzem Road, San Antonio, Texas 78218, United States of America
Rackspace US, Inc privacy policy can be viewed at www.rackspace.com/information/legal/privacystatement<http://www.rackspace.com/information/legal/privacystatement>
-
Rackspace Limited is a company registered in England & Wales (company registered number 03897010) whose registered office is at 5 Millington Road, Hyde Park Hayes, Middlesex UB3 4AZ.
Rackspace Limited privacy policy can be viewed at www.rackspace.co.uk/legal/privacy-policy<http://www.rackspace.co.uk/legal/privacy-policy>
-
Rackspace Benelux B.V. is a company registered in the Netherlands (company KvK nummer 34276327) whose registered office is at Teleportboulevard 110, 1043 EJ Amsterdam.
Rackspace Benelux B.V privacy policy can be viewed at www.rackspace.nl/juridisch/privacy-policy<http://www.rackspace.nl/juridisch/privacy-policy>
-
Rackspace Asia Limited is a company registered in Hong Kong (Company no: 1211294) whose registered office is at 9/F, Cambridge House, Taikoo Place, 979 King's Road, Quarry Bay, Hong Kong.
Rackspace Asia Limited privacy policy can be viewed at www.rackspace.com.hk/company/legal-privacy-statement.php<http://www.rackspace.com.hk/company/legal-privacy-statement.php>
-
This e-mail message (including any attachments or embedded documents) is intended for the exclusive and confidential use of the individual or entity to which this message is addressed, and unless otherwise expressly indicated, is confidential and privileged information of Rackspace. Any dissemination, distribution or copying of the enclosed material is prohibited. If you receive this transmission in error, please notify us immediately by e-mail at abuse at rackspace.com<mailto:abuse at rackspace.com> and delete the original message. Your cooperation is appreciated.
Jamie Hannaford
Software Developer III - CH [experience Fanatical Support]
Tel: +41434303908
Mob: +41791009767
[Rackspace]
Rackspace International GmbH a company registered in the Canton of Zurich, Switzerland (company identification number CH-020.4.047.077-1) whose registered office is at Pfingstweidstrasse 60, 8005 Zurich, Switzerland. Rackspace International GmbH privacy policy can be viewed at www.rackspace.co.uk/legal/swiss-privacy-policy
-
Rackspace Hosting Australia PTY LTD a company registered in the state of Victoria, Australia (company registered number ACN 153 275 524) whose registered office is at Suite 3, Level 7, 210 George Street, Sydney, NSW 2000, Australia. Rackspace Hosting Australia PTY LTD privacy policy can be viewed at www.rackspace.com.au/company/legal-privacy-statement.php
-
Rackspace US, Inc, 5000 Walzem Road, San Antonio, Texas 78218, United States of America
Rackspace US, Inc privacy policy can be viewed at www.rackspace.com/information/legal/privacystatement
-
Rackspace Limited is a company registered in England & Wales (company registered number 03897010) whose registered office is at 5 Millington Road, Hyde Park Hayes, Middlesex UB3 4AZ.
Rackspace Limited privacy policy can be viewed at www.rackspace.co.uk/legal/privacy-policy
-
Rackspace Benelux B.V. is a company registered in the Netherlands (company KvK nummer 34276327) whose registered office is at Teleportboulevard 110, 1043 EJ Amsterdam.
Rackspace Benelux B.V privacy policy can be viewed at www.rackspace.nl/juridisch/privacy-policy
-
Rackspace Asia Limited is a company registered in Hong Kong (Company no: 1211294) whose registered office is at 9/F, Cambridge House, Taikoo Place, 979 King's Road, Quarry Bay, Hong Kong.
Rackspace Asia Limited privacy policy can be viewed at www.rackspace.com.hk/company/legal-privacy-statement.php
-
This e-mail message (including any attachments or embedded documents) is intended for the exclusive and confidential use of the individual or entity to which this message is addressed, and unless otherwise expressly indicated, is confidential and privileged information of Rackspace. Any dissemination, distribution or copying of the enclosed material is prohibited. If you receive this transmission in error, please notify us immediately by e-mail at abuse at rackspace.com and delete the original message. Your cooperation is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140606/6d4c01c7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imagea6fd99.JPG
Type: image/jpeg
Size: 3124 bytes
Desc: imagea6fd99.JPG
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140606/6d4c01c7/attachment.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image7b6ad3.JPG
Type: image/jpeg
Size: 990 bytes
Desc: image7b6ad3.JPG
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140606/6d4c01c7/attachment-0001.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image738067.JPG
Type: image/jpeg
Size: 6844 bytes
Desc: image738067.JPG
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140606/6d4c01c7/attachment-0002.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image2388db.JPG
Type: image/jpeg
Size: 1074 bytes
Desc: image2388db.JPG
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140606/6d4c01c7/attachment-0003.jpe>
More information about the OpenStack-dev
mailing list