├── .editorconfig ├── .php_cs ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── LICENSE.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── composer.json └── src └── SkeletonClass.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | 5 | This source file is subject to the MIT license that is bundled 6 | with this source code in the file LICENSE. 7 | EOF; 8 | 9 | return PhpCsFixer\Config::create() 10 | ->setRiskyAllowed(true) 11 | ->setRules([ 12 | '@Symfony' => true, 13 | '@Symfony:risky' => true, 14 | 'array_syntax' => ['syntax' => 'short'], 15 | 'combine_consecutive_unsets' => true, 16 | // one should use PHPUnit methods to set up expected exception instead of annotations 17 | 'general_phpdoc_annotation_remove' => ['expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'], 18 | 'header_comment' => ['header' => $header], 19 | 'heredoc_to_nowdoc' => true, 20 | 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'], 21 | 'no_unreachable_default_argument_value' => true, 22 | 'no_useless_else' => true, 23 | 'no_useless_return' => true, 24 | 'ordered_class_elements' => true, 25 | 'ordered_imports' => true, 26 | 'php_unit_strict' => true, 27 | 'phpdoc_add_missing_param_annotation' => true, 28 | 'phpdoc_order' => true, 29 | 'psr4' => true, 30 | 'strict_comparison' => false, 31 | 'strict_param' => true, 32 | 'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true], 33 | 'concat_space' => ['spacing' => 'one'], 34 | 'no_empty_statement' => true, 35 | 'simplified_null_return' => true, 36 | 'no_extra_consecutive_blank_lines' => true, 37 | 'pre_increment' => false 38 | ]) 39 | ->setFinder( 40 | PhpCsFixer\Finder::create() 41 | ->exclude('vendor') 42 | ->in(__DIR__) 43 | ) 44 | ->setUsingCache(false) 45 | ; 46 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `queue` will be documented in this file. 4 | 5 | Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. 6 | 7 | ## NEXT - YYYY-MM-DD 8 | 9 | ### Added 10 | - Nothing 11 | 12 | ### Deprecated 13 | - Nothing 14 | 15 | ### Fixed 16 | - Nothing 17 | 18 | ### Removed 19 | - Nothing 20 | 21 | ### Security 22 | - Nothing 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to make participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at `pei.greet@gmail.com`. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/yaochufa/queue). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``. 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ composer test 29 | ``` 30 | 31 | 32 | **Happy coding**! 33 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Detailed description 4 | 5 | Provide a detailed description of the change or addition you are proposing. 6 | 7 | Make it clear if the issue is a bug, an enhancement or just a question. 8 | 9 | ## Context 10 | 11 | Why is this change important to you? How would you use it? 12 | 13 | How can it benefit other users? 14 | 15 | ## Possible implementation 16 | 17 | Not obligatory, but suggest an idea for implementing addition or change. 18 | 19 | ## Your environment 20 | 21 | Include as many relevant details about the environment you experienced the bug in and how to reproduce it. 22 | 23 | * Version used (e.g. PHP 5.6, HHVM 3): 24 | * Operating system and version (e.g. Ubuntu 16.04, Windows 7): 25 | * Link to your project: 26 | * ... 27 | * ... 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2018 kcloze 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | Describe your changes in detail. 6 | 7 | ## Motivation and context 8 | 9 | Why is this change required? What problem does it solve? 10 | 11 | If it fixes an open issue, please link to the issue here (if you write `fixes #num` 12 | or `closes #num`, the issue will be automatically closed when the pull is accepted.) 13 | 14 | ## How has this been tested? 15 | 16 | Please describe in detail how you tested your changes. 17 | 18 | Include details of your testing environment, and the tests you ran to 19 | see how your change affects other areas of the code, etc. 20 | 21 | ## Screenshots (if appropriate) 22 | 23 | ## Types of changes 24 | 25 | What types of changes does your code introduce? Put an `x` in all the boxes that apply: 26 | - [ ] Bug fix (non-breaking change which fixes an issue) 27 | - [ ] New feature (non-breaking change which adds functionality) 28 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 29 | 30 | ## Checklist: 31 | 32 | Go over all the following points, and put an `x` in all the boxes that apply. 33 | 34 | Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our [continuous integration](http://www.phptherightway.com/#continuous-integration) server to make sure your [tests and code style pass](https://help.github.com/articles/about-required-status-checks/). 35 | 36 | - [ ] I have read the **[CONTRIBUTING](CONTRIBUTING.md)** document. 37 | - [ ] My pull request addresses exactly one patch/feature. 38 | - [ ] I have created a branch for this patch/feature. 39 | - [ ] Each individual commit in the pull request is meaningful. 40 | - [ ] I have added tests to cover my changes. 41 | - [ ] If my change requires a change to the documentation, I have updated it accordingly. 42 | 43 | If you're unsure about any of these, don't hesitate to ask. We're here to help! 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # queue 2 | 3 | [![Latest Version on Packagist][ico-version]][link-packagist] 4 | [![Software License][ico-license]](LICENSE.md) 5 | [![Build Status][ico-travis]][link-travis] 6 | [![Coverage Status][ico-scrutinizer]][link-scrutinizer] 7 | [![Quality Score][ico-code-quality]][link-code-quality] 8 | [![Total Downloads][ico-downloads]][link-downloads] 9 | 10 | **Note:** Replace ```kcloze``` ```kcloze``` ```https://github.com/YaochufaTech/swoole-queue``` ```pei.greet@gmail.com``` ```yaochufa``` ```queue``` ```基于swoole的抢购排队通用中间件,适合抢购秒杀场景,跟具体业务解耦``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can run `$ php prefill.php` in the command line to make all replacements at once. Delete the file prefill.php as well. 11 | 12 | This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what 13 | PSRs you support to avoid any confusion with users and contributors. 14 | 15 | 16 | ## Architecture 17 | ![architecture](docs/queue-arch.png) 18 | 19 | 20 | ## Structure 21 | 22 | If any of the following are applicable to your project, then the directory structure should follow industry best practices by being named the following. 23 | 24 | ``` 25 | bin/ 26 | config/ 27 | src/ 28 | tests/ 29 | vendor/ 30 | ``` 31 | 32 | 33 | ## Install 34 | 35 | Via Composer 36 | 37 | ``` bash 38 | $ composer require yaochufa/queue 39 | ``` 40 | 41 | ## Usage 42 | 43 | ``` php 44 | $skeleton = new Yaochufa\Queue(); 45 | echo $skeleton->echoPhrase('Hello, League!'); 46 | ``` 47 | 48 | ## Change log 49 | 50 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 51 | 52 | ## Testing 53 | 54 | ``` bash 55 | $ composer test 56 | ``` 57 | 58 | ## Contributing 59 | 60 | Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details. 61 | 62 | ## Security 63 | 64 | If you discover any security related issues, please email pei.greet@gmail.com instead of using the issue tracker. 65 | 66 | ## Credits 67 | 68 | - [kcloze][link-author] 69 | - [All Contributors][link-contributors] 70 | 71 | ## License 72 | 73 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 74 | 75 | [ico-version]: https://img.shields.io/packagist/v/yaochufa/queue.svg?style=flat-square 76 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square 77 | [ico-travis]: https://img.shields.io/travis/yaochufa/queue/master.svg?style=flat-square 78 | [ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/yaochufa/queue.svg?style=flat-square 79 | [ico-code-quality]: https://img.shields.io/scrutinizer/g/yaochufa/queue.svg?style=flat-square 80 | [ico-downloads]: https://img.shields.io/packagist/dt/yaochufa/queue.svg?style=flat-square 81 | 82 | [link-packagist]: https://packagist.org/packages/yaochufa/queue 83 | [link-travis]: https://travis-ci.org/yaochufa/queue 84 | [link-scrutinizer]: https://scrutinizer-ci.com/g/yaochufa/queue/code-structure 85 | [link-code-quality]: https://scrutinizer-ci.com/g/yaochufa/queue 86 | [link-downloads]: https://packagist.org/packages/yaochufa/queue 87 | [link-author]: https://github.com/kcloze 88 | [link-contributors]: ../../contributors 89 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yaochufa/queue", 3 | "type": "library", 4 | "description": "基于swoole的抢购排队通用中间件,适合抢购秒杀场景,跟具体业务解耦", 5 | "keywords": [ 6 | "yaochufa", 7 | "queue" 8 | ], 9 | "homepage": "https://github.com/YaochufaTech/swoole-queue", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "kcloze", 14 | "email": "pei.greet@gmail.com", 15 | "homepage": "https://github.com/YaochufaTech/swoole-queue", 16 | "role": "Developer" 17 | } 18 | ], 19 | "require": { 20 | "php" : ">=7.0" 21 | }, 22 | "require-dev": { 23 | "phpunit/phpunit" : "~6.5" 24 | }, 25 | "autoload": { 26 | "psr-4": { 27 | "Yaochufa\\Queue\\": "src" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "psr-4": { 32 | "Yaochufa\\Queue\\": "tests" 33 | } 34 | }, 35 | "scripts": { 36 | "test": "phpunit", 37 | "fix-style": "php-cs-fixer fix --config=./.php_cs" 38 | }, 39 | "extra": { 40 | "branch-alias": { 41 | "dev-master": "1.0-dev" 42 | } 43 | }, 44 | "config": { 45 | "sort-packages": true 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/SkeletonClass.php: -------------------------------------------------------------------------------- 1 | 6 | * This source file is subject to the MIT license that is bundled 7 | * with this source code in the file LICENSE. 8 | */ 9 | 10 | namespace Yaochufa\Queue; 11 | 12 | class SkeletonClass 13 | { 14 | /** 15 | * Create a new Skeleton Instance. 16 | */ 17 | public function __construct() 18 | { 19 | // constructor body 20 | } 21 | 22 | /** 23 | * Friendly welcome. 24 | * 25 | * @param string $phrase Phrase to return 26 | * 27 | * @return string Returns the phrase passed in 28 | */ 29 | public function echoPhrase($phrase) 30 | { 31 | return $phrase; 32 | } 33 | } 34 | --------------------------------------------------------------------------------