Skip to content

Checklist For Speed

scil edited this page Sep 16, 2018 · 33 revisions
  • put Third_Party/ServiceProvider::class => [], in 'providers_on_worker' in config/laravelfly.php
  • find out singleton services in that service provider, and decide to make the services to be CLONE SERVICE or WORKER SERVICE (former is simpler but requires more care when using the service).
  • find out route middlewares in that service provider, and you can put them into 'singleton_route_middlewares' if these middlewares are like WORKER SERVICE.

CLONE SERVICE

  • put Third_Party/ServiceProvider::class => [ 'service_name' => 'clone', ],

  • If its Facade alias maybe used before any requests, put it in 'clean_Facade_on_work' in config/laravelfly.php

  • If other CLONE SERVICEs or WORKER SERVVCEs have ref to this service, update the ref in update_on_request in config/laravelfly.php.

    • By default, amoung Laravel offical services, only app('url') is cloned. If you CLONE SERVICE has an ref to app('url'), you have to update it.
  • There is no ref to this service in your controllers, see controller and stale reference.

  • more

WORKER SERVICE

A. no coroutine

  • ensure the service can be WORKER SERVICE, read WORKER SERVICE and WORKER OBJECT. If refactor by extending 3rd party service provider, replace third-party service provider with new service provider.

    • singleton
    • its vars should restore if a change made in a request and harm the next request.
    • If it has ref attibutes, like app['events'] has an attribubte container, the attribute container must be also A WORKER SERVICE.
  • put Third_Party/ServiceProvider::class => [ 'service_name' => true, ],

  • more

B. using coroutine

  • its props will not change in any requests. For associate array type, changed are allowed if there is no harm.

  • if it has ref attibutes, like app['events'] has an attribubte container, the container must be also A COROUTINE-FRIENDLY SERVICE

  • put Third_Party/ServiceProvider::class => [ 'service_name' => true, ],

  • more

CLONE SERVICE or WORKER SERVICE/OBJECT

  • static props should keep consistent. If coroutine used, they must keep same; if not, the changes in a request should not harm the next request. Refactor not made for following static props of laravel offical services, so pay some attension to them:

    • Illuminate\Pagination\Paginator:: currentPathResolver,currentPageResolver,viewFactoryResolver,defaultView,defaultSimpleView
    • Illuminate\Database\Eloquent\Model::globalScopes ( Global Scopes ) is an associated array, its values on the same key should always be same.
    • If you use Laravel Macros, an object's Macros with same name should always be same if the object is made on worker, like addGlobalScope.
  • If it has ref to other CLONE SERVICEs like app('url'), update the ref in update_on_request in config/laravelfly.php. By default, LaravelFly would output CLONE SERVICEs to console.

  • If the service has an ref to app('request'), like (mcamara/laravel-localization it should be updated like this

    'update_on_request' => [

        [
            'this' => 'laravellocalization',
            'closure' => function () {
                app()->rebinding('request', function () {
                    $this->request = app('request');
                });
            }
        ],

    ],