Skip to content

Commit 9d43170

Browse files
author
Jamie Hannaford
committed
Attempt to fix 5.3 segfault
1 parent 09da4f7 commit 9d43170

File tree

502 files changed

+79965
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

502 files changed

+79965
-2
lines changed

doc/_build/doctrees/auth.doctree

7.09 KB
Binary file not shown.
5.8 KB
Binary file not shown.
19.8 KB
Binary file not shown.

doc/_build/doctrees/debugging.doctree

13.7 KB
Binary file not shown.
283 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
9.52 KB
Binary file not shown.

doc/_build/doctrees/index.doctree

14 KB
Binary file not shown.

doc/_build/doctrees/iterators.doctree

43.7 KB
Binary file not shown.

doc/_build/doctrees/logging.doctree

7.12 KB
Binary file not shown.

doc/_build/doctrees/regions.doctree

6.03 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
38.4 KB
Binary file not shown.
13.2 KB
Binary file not shown.
6.54 KB
Binary file not shown.
14.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
4.47 KB
Binary file not shown.
2.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

doc/_build/doctrees/url-types.doctree

3.47 KB
Binary file not shown.
4.55 KB
Binary file not shown.

doc/_build/html/.buildinfo

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: da7e999e4172075fe9536fec2c0e5662
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

doc/_build/html/_sources/auth.txt

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Authentication
2+
==============
3+
4+
The client does not automatically authenticate against the API when it is
5+
instantiated - it waits for an API call. When this happens, it checks
6+
whether the current “token” has expired, and (re-)authenticates if
7+
necessary.
8+
9+
You can force authentication, by calling:
10+
11+
.. code-block:: php
12+
13+
$client->authenticate();
14+
15+
If the credentials are incorrect, a ``401`` error will be returned. If
16+
credentials are correct, a ``200`` status is returned with your Service
17+
Catalog.
18+
19+
20+
Service Catalog
21+
---------------
22+
23+
The Service Catalog is returned on successful authentication, and is
24+
composed of all the different API services available to the current
25+
tenant. All of this functionality is encapsulated in the ``Catalog``
26+
object, which allows you greater control and interactivity.
27+
28+
.. code-block:: php
29+
30+
/** @var OpenCloud\Common\Service\Catalog */
31+
$catalog = $client->getCatalog();
32+
33+
// Return a list of OpenCloud\Common\Service\CatalogItem objects
34+
foreach ($catalog->getItems() as $catalogItem) {
35+
36+
$name = $catalogItem->getName();
37+
$type = $catalogItem->getType();
38+
39+
if ($name == 'cloudServersOpenStack' && $type == 'compute') {
40+
break;
41+
}
42+
43+
// Array of OpenCloud\Common\Service\Endpoint objects
44+
$endpoints = $catalogItem->getEndpoints();
45+
foreach ($endpoints as $endpoint) {
46+
if ($endpoint->getRegion() == 'DFW') {
47+
echo $endpoint->getPublicUrl();
48+
}
49+
}
50+
}
51+
52+
As you can see, you have access to each Service’s name, type and list of
53+
endpoints. Each endpoint provides access to the specific region, along
54+
with its public and private endpoint URLs.
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Caching credentials
2+
===================
3+
4+
You can speed up your API operations by caching your credentials in a
5+
(semi-)permanent location, such as your DB or local filesystem. This
6+
enable subsequent requests to access a shared resource, instead of
7+
repetitively having to re-authenticate on every thread of execution.
8+
9+
Tokens are valid for 24 hours, so you can effectively re-use the same
10+
cached value for that period. If you try to use a cached version that
11+
has expired, an authentication request will be made.
12+
13+
Filesystem example
14+
------------------
15+
16+
In this example, credentials will be saved to a file in the local
17+
filesystem. Be sure to exclude it from your VCS.
18+
19+
.. code-block:: php
20+
21+
use OpenCloud\Rackspace;
22+
23+
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
24+
'username' => 'foo',
25+
'apiKey' => 'bar'
26+
));
27+
28+
$cacheFile = __DIR__ . '/.opencloud_token';
29+
30+
// If the cache file exists, try importing it into the client
31+
if (file_exists($cacheFile)) {
32+
$data = unserialize(file_get_contents($cacheFile));
33+
$client->importCredentials($data);
34+
}
35+
36+
$token = $client->getTokenObject();
37+
38+
// If no token exists, or the current token is expired, re-authenticate and save the new token to disk
39+
if (!$token || ($token && $token->hasExpired())) {
40+
$client->authenticate();
41+
file_put_contents($cacheFile, serialize($client->exportCredentials()));
42+
}
43+
44+
In tests, the above code shaved about 1-2s off the execution time.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
Customizing Clients
2+
===================
3+
4+
Logger injection
5+
----------------
6+
7+
As the ``Rackspace`` client extends the ``OpenStack`` client, they both support
8+
passing ``$options`` as an array via the constructor's third parameter. The
9+
options are passed as a config to the `Guzzle` client, but also allow to inject
10+
your own logger.
11+
12+
Your logger should implement the ``Psr\Log\LoggerInterface`` `as defined in
13+
PSR-3 <https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md>`_.
14+
One example of a compatible logger is `Monolog <https://github.com/Seldaek/monolog>`_.
15+
When the client does create a service, it will inject the logger if one is
16+
available.
17+
18+
To inject a ``LoggerInterface`` compatible logger into a new client:
19+
20+
.. code-block:: php
21+
22+
use Monolog\Logger;
23+
use OpenCloud\OpenStack;
24+
25+
// create a log channel
26+
$logger = new Logger('name');
27+
28+
$client = new OpenStack('http://identity.my-openstack.com/v2.0', array(
29+
'username' => 'foo',
30+
'password' => 'bar'
31+
), array(
32+
'logger' => $logger,
33+
));
34+
35+
36+
Authentication
37+
--------------
38+
39+
The client does not automatically authenticate against the API when it is
40+
instantiated - it waits for an API call. When this happens, it checks
41+
whether the current “token” has expired, and (re-)authenticates if
42+
necessary.
43+
44+
You can force authentication, by calling:
45+
46+
.. code-block:: php
47+
48+
$client->authenticate();
49+
50+
If the credentials are incorrect, a ``401`` error will be returned. If
51+
credentials are correct, a ``200`` status is returned with your Service
52+
Catalog.
53+
54+
55+
Service Catalog
56+
---------------
57+
58+
The Service Catalog is returned on successful authentication, and is
59+
composed of all the different API services available to the current
60+
tenant. All of this functionality is encapsulated in the ``Catalog``
61+
object, which allows you greater control and interactivity.
62+
63+
.. code-block:: php
64+
65+
/** @var OpenCloud\Common\Service\Catalog */
66+
$catalog = $client->getCatalog();
67+
68+
// Return a list of OpenCloud\Common\Service\CatalogItem objects
69+
foreach ($catalog->getItems() as $catalogItem) {
70+
71+
$name = $catalogItem->getName();
72+
$type = $catalogItem->getType();
73+
74+
if ($name == 'cloudServersOpenStack' && $type == 'compute') {
75+
break;
76+
}
77+
78+
// Array of OpenCloud\Common\Service\Endpoint objects
79+
$endpoints = $catalogItem->getEndpoints();
80+
foreach ($endpoints as $endpoint) {
81+
if ($endpoint->getRegion() == 'DFW') {
82+
echo $endpoint->getPublicUrl();
83+
}
84+
}
85+
}
86+
87+
As you can see, you have access to each Service’s name, type and list of
88+
endpoints. Each endpoint provides access to the specific region, along
89+
with its public and private endpoint URLs.
90+
91+
92+
Default HTTP headers
93+
--------------------
94+
95+
To set default HTTP headers:
96+
97+
.. code-block:: php
98+
99+
$client->setDefaultOption('headers/X-Custom-Header', 'FooBar');
100+
101+
102+
User agents
103+
-----------
104+
105+
php-opencloud will send a default ``User-Agent`` header for every HTTP
106+
request, unless a custom value is provided by the end-user. The default
107+
header will be in this format:
108+
109+
User-Agent: OpenCloud/xxx cURL/yyy PHP/zzz
110+
111+
where ``xxx`` is the current version of the SDK, ``yyy`` is the current
112+
version of cURL, and ``zzz`` is the current PHP version. To override
113+
this default, you must run:
114+
115+
.. code-block:: php
116+
117+
$client->setUserAgent('MyCustomUserAgent');
118+
119+
which will result in:
120+
121+
User-Agent: MyCustomUserAgent
122+
123+
If you want to set a *prefix* for the user agent, but retain the default
124+
``User-Agent`` as a suffix, you must run:
125+
126+
.. code-block:: php
127+
128+
$client->setUserAgent('MyPrefix', true);
129+
130+
which will result in:
131+
132+
User-Agent: MyPrefix OpenCloud/xxx cURL/yyy PHP/zzz
133+
134+
where ``$client`` is an instance of ``OpenCloud\OpenStack`` or
135+
``OpenCloud\Rackspace``.
136+
137+
138+
Other functionality
139+
-------------------
140+
141+
For a full list of functionality provided by Guzzle, please consult the
142+
`official documentation`_.
143+
144+
.. _official documentation: http://docs.guzzlephp.org/en/latest/http-client/client.html
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
Debugging
2+
=========
3+
4+
There are two important debugging strategies to use when encountering
5+
problems with HTTP transactions.
6+
7+
Strategy 1: Meaningful exception handling
8+
-----------------------------------------
9+
10+
If the API returns a ``4xx`` or ``5xx`` status code, it indicates that
11+
there was an error with the sent request, meaning that the transaction
12+
cannot be adequately completed.
13+
14+
The Guzzle HTTP component, which forms the basis of our SDK's transport
15+
layer, utilizes `numerous exception
16+
classes <https://github.com/guzzle/guzzle/tree/master/src/Guzzle/Http/Exception>`__
17+
to handle this error logic.
18+
19+
The two most common exception classes are:
20+
21+
- ``Guzzle\Http\Exception\ClientErrorResponseException``, which is
22+
thrown when a ``4xx`` response occurs
23+
24+
- ``Guzzle\Http\Exception\ServerErrorResponseException``, which is
25+
thrown when a ``5xx`` response occurs
26+
27+
Both of these classes extend the base ``BadResponseException`` class.
28+
29+
This provides you with the granularity you need to debug and handle
30+
exceptions.
31+
32+
An example with Swift
33+
~~~~~~~~~~~~~~~~~~~~~
34+
35+
If you're trying to retrieve a Swift resource, such as a Data Object,
36+
and you're not completely certain that it exists, it makes sense to wrap
37+
your call in a try/catch block:
38+
39+
.. code-block:: php
40+
41+
use Guzzle\Http\Exception\ClientErrorResponseException;
42+
43+
try {
44+
return $service->getObject('foo.jpg');
45+
} catch (ClientErrorResponseException $e) {
46+
if ($e->getResponse()->getStatusCode() == 404) {
47+
// Okay, the resource does not exist
48+
return false;
49+
}
50+
} catch (\Exception $e) {
51+
// Some other exception was thrown...
52+
}
53+
54+
55+
Both ``ClientErrorResponseException`` and
56+
``ServerErrorResponseException`` have two methods that allow you to
57+
access the HTTP transaction:
58+
59+
.. code-block:: php
60+
61+
// Find out the faulty request
62+
$request = $e->getRequest();
63+
64+
// Display everything by casting as string
65+
echo (string) $request;
66+
67+
// Find out the HTTP response
68+
$response = $e->getResponse();
69+
70+
// Output that too
71+
echo (string) $response;
72+
73+
74+
Strategy 2: Wire logging
75+
------------------------
76+
77+
Guzzle provides a `Log
78+
plugin <http://docs.guzzlephp.org/en/latest/plugins/log-plugin.html>`__
79+
that allows you to log everything over the wire, which is useful if you
80+
don't know what's going on.
81+
82+
Here's how you enable it:
83+
84+
Install the plugin
85+
~~~~~~~~~~~~~~~~~~
86+
87+
.. code-block:: bash
88+
89+
composer require guzzle/guzzle
90+
91+
92+
Add to your client
93+
~~~~~~~~~~~~~~~~~~
94+
95+
.. code-block:: php
96+
97+
use Guzzle\Plugin\Log\LogPlugin;
98+
99+
$client->addSubscriber(LogPlugin::getDebugPlugin());
100+
101+
102+
The above will add a generic logging subscriber to your client, which
103+
will output every HTTP transaction to `STDOUT`.

0 commit comments

Comments
 (0)