-
Notifications
You must be signed in to change notification settings - Fork 41
WORKER SERVICE and WORKER OBJECT
This type of service is also called COROUTINE-FRIENDLY SERVICE, as LaravelFly uses coroutine in Mode Map.
A COROUTINE-FRIENDLY SERVICE that must satisfy folling conditions:
-
singleton. A singleton service is made by by Illuminate\Containe\Application::singleton() or Illuminate\Containe\Application::instance()
-
its vars will not change in any requests
-
if it has ref attibutes, like app['events'] has an attribubte
container
, the container must be also A COROUTINE-FRIENDLY SERVICE
If a singleton service does not satisfy the second condition, you can try refactor.
There are two Traits LaravelFly\Map\Util\Dict
and LaravelFly\Map\Util\StaticDic
used by LaravelFly to make a service to be a COROUTINE-FRIENDLY SERVICE. The first trait handles non-static vars, while the second static vars.
There two simple examples which make Laravel's official service coroutine-friendly.
service | official | refactor |
---|---|---|
app['event'] | Illuminate\Events\Dispatcher | LaravelFly\Map\IlluminateBase\Dispatcher |
app['translator'] | Illuminate\Translation\Translator | LaravelFly\Map\Illuminate\Translation\Translator |
Any other objects can be COROUTINE-FRIENDLY if they work like a WORKER SERVICE.
- Start
- Coding Guideline
- Deploy and OS Configuration
- New API
- Design
- Dev about Mode Map
- Dev about Mode Backup