File manager - Edit - /var/www/payraty/helpdesk/public/storage/branding_media/images/README.md.tar
Back
var/www/payraty/helpdesk/vendor/pda/pheanstalk/README.md 0000755 00000020050 00000000000 0017063 0 ustar 00 Pheanstalk ========== [](https://packagist.org/packages/pda/pheanstalk) [](https://packagist.org/pda/pheanstalk) [](https://scrutinizer-ci.com/g/pheanstalk/pheanstalk/?branch=master) [](https://scrutinizer-ci.com/g/pheanstalk/pheanstalk/?branch=master) [](https://travis-ci.org/pheanstalk/pheanstalk) Pheanstalk 5 is a pure PHP8.1+ client for use with [beanstalkd workqueue][1] versions 1.12 and later. In 2021 / 2022 / 2023 it was almost completely rewritten from scratch with the following goals in mind: - Fully typed - Passing the strict rule set for static analysis using PHPStan and Psalm - Splitting the different roles into separate parts Usage Example ------------- #### Producer ```php use Pheanstalk\Pheanstalk; use Pheanstalk\Values\TubeName; $pheanstalk = Pheanstalk::create('127.0.0.1'); $tube = new TubeName('testtube'); // Queue a Job $pheanstalk->useTube($tube); $pheanstalk->put("job payload goes here\n"); $pheanstalk->useTube($tube); $pheanstalk->put( data: json_encode(['test' => 'data'], JSON_THROW_ON_ERROR), priority: Pheanstalk::DEFAULT_PRIORITY, delay: 30, timeToRelease: 60 ); ``` #### Consumer / Worker ```php use Pheanstalk\Pheanstalk; use Pheanstalk\Values\TubeName; $pheanstalk = Pheanstalk::create('127.0.0.1'); $tube = new TubeName('testtube'); // we want jobs from 'testtube' only. $pheanstalk->watch($tube); // this hangs until a Job is produced. $job = $pheanstalk->reserve(); try { $jobPayload = $job->getData(); // do work. echo "Starting job with payload: {$jobPayload}\n"; sleep(2); // If it's going to take a long time, periodically // tell beanstalk we're alive to stop it rescheduling the job. $pheanstalk->touch($job); sleep(2); // eventually we're done, delete job. $pheanstalk->delete($job); } catch(\Exception $e) { // handle exception. // and let some other worker retry. $pheanstalk->release($job); } ``` #### Systemd configuration for Consumer / Worker Note that this does not aim to cover all possible scenarios or configurations. ```cli [Unit] Description=My App Worker [Service] User=deployer Group=www-data Restart=always ExecStart=/usr/bin/php /var/www/html/worker.php [Install] WantedBy=multi-user.target ``` Running the tests ----------------- Make sure you have docker-compose installed. ```sh > composer test ``` # History ## Pheanstalk 4 In 2018 [Sam Mousa][3] took on the responsibility of maintaining Pheanstalk. Pheanstalk 4.0 drops support for older PHP versions. It contains the following changes (among other things): - Strict PHP type hinting - Value objects for Job IDs - Functions without side effects - Dropped support for persistent connections - Add support for multiple socket implementations (streams extension, socket extension, fsockopen) ### Dropping support persistent connections Persistent connections are a feature where a TCP connection is kept alive between different requests to reduce overhead from TCP connection set up. When reusing TCP connections we must always guarantee that the application protocol, in this case beanstalks' protocol is in a proper state. This is hard, and in some cases impossible; at the very least this means we must do some tests which cause roundtrips. Consider for example a connection that has just sent the command `PUT 0 4000`. The beanstalk server is now going to read 4000 bytes, but if the PHP script crashes during this write the next request get assigned this TCP socket. Now to reset the connection to a known state it used to subscribe to the default tube: `use default`. Since the beanstalk server is expecting 4000 bytes, it will just write this command to the job and wait for more bytes.. To prevent these kinds of issues the simplest solution is to not use persistent connections. ### Dropped connection handling Depending on the socket implementation used we might not be able to enable TCP keepalive. If we do not have TCP keepalive there is no way for us to detect dropped connections, the underlying OS may wait up to 15 minutes to decide that a TCP connection where no packets are being sent is disconnected. When using a socket implementation that supports read timeouts, like `SocketSocket` which uses the socket extension we use read and write timeouts to detect broken connections; the issue with the beanstalk protocol is that it allows for no packets to be sent for extended periods of time. Solutions are to either catch these connection exceptions and reconnect or use `reserveWithTimeout()` with a timeout that is less than the read / write timeouts. Example code for a job runner could look like this (this is real production code): ```php use Pheanstalk\Pheanstalk; use Pheanstalk\Values\TubeName; interface Task { } interface TaskFactory { public function fromData(string $data): Task; } interface CommandBus { public function handle(Task $task): void; } function run(\Pheanstalk\PheanstalkSubscriber $pheanstalk, CommandBus $commandBus, TaskFactory $taskFactory): void { /** * @phpstan-ignore-next-line */ while (true) { $job = $pheanstalk->reserveWithTimeout(50); if (isset($job)) { try { $task = $taskFactory->fromData($job->getData()); $commandBus->handle($task); echo "Deleting job: {$job->getId()}\n"; $pheanstalk->delete($job); } catch (\Throwable $t) { echo "Burying job: {$job->getId()}\n"; $pheanstalk->bury($job); } } } } ``` Here connection errors will cause the process to exit (and be restarted by a task manager). ### Functions with side effects In version 4 functions with side effects have been removed, functions like `putInTube` internally did several things: 1. Switch to the tube 2. Put the job in the new tube In this example, the tube changes meaning that the connection is now in a different state. This is not intuitive and forces any user of the connection to always switch / check the current tube. Another issue with this approach is that it is harder to deal with errors. If an exception occurs it is unclear whether we did or did not switch tube. ### Migration to v4 A migration should in most cases be relatively simple: - Change the constructor, either use the static constructor, use a DI container to construct the dependencies, or manually instantiate them. - Change instances of `reserve()` with a timeout to `reserveWithTimeout(int $timeout)` since `reserve()` no longer accepts a `timeout` parameter. - Run your tests, or use a static analyzer to test for calls to functions that no longer exist. - Make sure that you handle connection exceptions (this is not new to V4, only in V4 you will get more of them due to the default usage of a socket implementation that has read / write timeouts). ## Pheanstalk 3 Pheanstalk is a pure PHP 7.1+ client for the [beanstalkd workqueue][1]. It has been actively developed, and used in production by many, since late 2008. Created by [Paul Annesley][2], Pheanstalk is rigorously unit tested and written using encapsulated, maintainable object oriented design. Community feedback, bug reports and patches has led to a stable 1.0 release in 2010, a 2.0 release in 2013, and a 3.0 release in 2014. Pheanstalk 3.0 introduces PHP namespaces, PSR-1 and PSR-2 coding standards, and PSR-4 autoloader standard. beanstalkd up to the latest version 1.10 is supported. All commands and responses specified in the [protocol documentation][4] for beanstalkd 1.3 are implemented. [1]: https://beanstalkd.github.io/ [2]: https://paul.annesley.cc/ [3]: https://github.com/sammousa [4]: https://github.com/kr/beanstalkd/tree/v1.3/doc/protocol.txt?raw=true var/www/payraty/helpdesk/vendor/psr/http-client/README.md 0000755 00000001045 00000000000 0017227 0 ustar 00 HTTP Client =========== This repository holds all the common code related to [PSR-18 (HTTP Client)][psr-url]. Note that this is not a HTTP Client implementation of its own. It is merely abstractions that describe the components of a HTTP Client. The installable [package][package-url] and [implementations][implementation-url] are listed on Packagist. [psr-url]: https://www.php-fig.org/psr/psr-18 [package-url]: https://packagist.org/packages/psr/http-client [implementation-url]: https://packagist.org/providers/psr/http-client-implementation var/www/payraty/helpdesk/vendor/elasticsearch/elasticsearch/README.md 0000755 00000021037 00000000000 0021617 0 ustar 00 <p align="center"> <img src="https://github.com/elastic/elasticsearch-py/raw/main/docs/logo-elastic-glyph-color.svg" width="20%" alt="Elastic logo" /> </p> # Elasticsearch PHP client [](https://github.com/elastic/elasticsearch-php/actions) [](https://packagist.org/packages/elasticsearch/elasticsearch) [](https://packagist.org/packages/elasticsearch/elasticsearch) This is the official PHP client for [Elasticsearch](https://www.elastic.co/elasticsearch/). **[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)** or **[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** **for a free trial of Elastic Cloud**. ## Contents - [Installation](#installation) - [Connecting](#connecting) - [Usage](#usage) - [Versioning](#versioning) - [Backward Incompatible Changes](#backward-incompatible-changes-boom) - [Mock the Elasticsearch client](#mock-the-elasticsearch-client) - [FAQ](#faq-) - [Contribute](#contribute-) - [License](#license-) *** ## Installation Refer to the [Installation section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_installation) of the getting started documentation. ## Connecting Refer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_connecting) of the getting started documentation. ## Usage The `elasticsearch-php` client offers 400+ endpoints for interacting with Elasticsearch. A list of all these endpoints is available in the [official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html) of Elasticsearch APIs. Here we reported the basic operation that you can perform with the client: index, search and delete. - [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_creating_an_index) - [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_indexing_documents) - [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_getting_documents) - [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_searching_documents) - [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_updating_documents) - [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_documents) - [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_an_index) ### Versioning This client is versioned and released alongside Elasticsearch server. To guarantee compatibility, use the most recent version of this library within the major version of the corresponding Enterprise Search implementation. For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but not `8.0`. ## Compatibility The Elasticsearch client is compatible with currently maintained PHP versions. Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch without breaking. It does not mean that the client automatically supports new features of newer Elasticsearch versions; it is only possible after a release of a new client version. For example, a 8.12 client version won't automatically support the new features of the 8.13 version of Elasticsearch, the 8.13 client version is required for that. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made. | Elasticsearch Version | Elasticsearch-PHP Branch | Supported | | --------------------- | ------------------------ | --------- | | main | main | | | 8.x | 8.x | 8.x | | 7.x | 7.x | 7.17 | ## Backward Incompatible Changes :boom: The 8.0.0 version of `elasticsearch-php` contains a new implementation compared with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client communications. We tried to reduce the BC breaks as much as possible with `7.x` but there are some (big) differences: - we changed the namespace, now everything is under `Elastic\Elasticsearch` - we used the [elastic-transport-php](https://github.com/elastic/elastic-transport-php) library for HTTP communications; - we changed the `Exception` model, using the namespace `Elastic\Elasticsearch\Exception`. All the exceptions extends the `ElasticsearchException` interface, as in 7.x - we changed the response type of each endpoints using an [Elasticsearch](src/Response/Elasticsearch.php) response class. This class wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the access of the body response as array or object. This means you can access the API response as in 7.x, no BC break here! :angel: - we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts) You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more information. ## Mock the Elasticsearch client If you need to mock the Elasticsearch client you just need to mock a [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client. For instance, you can use the [php-http/mock-client](https://github.com/php-http/mock-client) as follows: ```php use Elastic\Elasticsearch\ClientBuilder; use Elastic\Elasticsearch\Response\Elasticsearch; use Http\Mock\Client; use Nyholm\Psr7\Response; $mock = new Client(); // This is the mock client $client = ClientBuilder::create() ->setHttpClient($mock) ->build(); // This is a PSR-7 response $response = new Response( 200, [Elasticsearch::HEADER_CHECK => Elasticsearch::PRODUCT_NAME], 'This is the body!' ); $mock->addResponse($response); $result = $client->info(); // Just calling an Elasticsearch endpoint echo $result->asString(); // This is the body! ``` We are using the `ClientBuilder::setHttpClient()` to set the mock client. You can specify the response that you want to have using the `addResponse($response)` function. As you can see the `$response` is a PSR-7 response object. In this example we used the `Nyholm\Psr7\Response` object from the [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using [PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as follows: ```php $response = $this->createMock('Psr\Http\Message\ResponseInterface'); ``` **Notice**: we added a special header in the HTTP response. This is the product check header, and it is required for guarantee that `elasticsearch-php` is communicating with an Elasticsearch server 8.0+. For more information you can read the [Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html) section of PHP-HTTP documentation. ## FAQ 🔮 ### Where do I report issues with the client? If something is not working as expected, please open an [issue](https://github.com/elastic/elasticsearch-php/issues/new). ### Where else can I go to get help? You can checkout the [Elastic community discuss forums](https://discuss.elastic.co/). ## Contribute 🚀 We welcome contributors to the project. Before you begin, some useful info... - If you want to contribute to this project you need to subscribe to a [Contributor Agreement](https://www.elastic.co/contributor-agreement). - Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/elasticsearch-php/issues). - If you want to send a PR for version `8.0` please use the `8.0` branch, for `8.1` use the `8.1` branch and so on. - Never send PR to `master` unless you want to contribute to the development version of the client (`master` represents the next major version). - Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/). If you are not familiar with PHPUnit you can have a look at the [reference](https://phpunit.readthedocs.io/en/9.5/). Thanks in advance for your contribution! :heart: ## License 📗 [MIT](LICENSE) © [Elastic](https://www.elastic.co/)
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings