-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.x] Introduce "Context" #49730
Merged
Merged
[11.x] Introduce "Context" #49730
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3a9df3f
Add "context"
timacdonald ab89cde
Inject event dispatcher
timacdonald d6058d0
Use a scoped instance
timacdonald 5cbddd1
Allow app to be refreshed
timacdonald d423af9
lint
timacdonald 7d1bda4
Update facade
timacdonald 90e498e
Resolve using current app instance
timacdonald 0a5e0e4
serialization
timacdonald 3f2c93a
serialization
timacdonald 1a7914b
lint
timacdonald 0caf265
tests
timacdonald 869602c
wip
timacdonald 9559ef8
report
timacdonald 6250e6d
facade
timacdonald 2f942f9
Typo
timacdonald 570b5e7
formatting
timacdonald 8a5d3ef
Octane fix
timacdonald 19498dd
lint
timacdonald a4721e5
Reduce API
timacdonald d7a4fc8
lint
timacdonald c1cdffa
Update tests/Integration/Log/ContextIntegrationTest.php
timacdonald 152382e
Update tests/Integration/Log/ContextIntegrationTest.php
timacdonald ccb4106
wip
crynobone e4f0641
wip
crynobone 88215cd
wip
crynobone d9be3ac
formatting
taylorotwell 8d5afa3
add alias
taylorotwell d229f1d
formatting
taylorotwell e40d4fe
formatting
taylorotwell 593fc4c
check for function
taylorotwell 88295f8
add null hydration test
taylorotwell f97a4d1
rename events
taylorotwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Illuminate\Log\Context; | ||
|
||
use Illuminate\Queue\Events\JobProcessing; | ||
use Illuminate\Queue\Queue; | ||
use Illuminate\Support\Facades\Context; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class ContextServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->scoped(Repository::class); | ||
} | ||
|
||
/** | ||
* Boot the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
Queue::createPayloadUsing(function ($connection, $queue, $payload) { | ||
$context = Context::dehydrate(); | ||
|
||
return $context === null ? $payload : [ | ||
...$payload, | ||
'illuminate:log:context' => $context, | ||
]; | ||
}); | ||
|
||
$this->app['events']->listen(function (JobProcessing $event) { | ||
Context::hydrate($event->job->payload()['illuminate:log:context'] ?? null); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Illuminate\Log\Context\Events; | ||
|
||
class ContextDehydrating | ||
{ | ||
/** | ||
* The context instance. | ||
* | ||
* @var \Illuminate\Log\Context\Repository | ||
*/ | ||
public $context; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @param \Illuminate\Log\Context\Repository $context | ||
*/ | ||
public function __construct($context) | ||
{ | ||
$this->context = $context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Illuminate\Log\Context\Events; | ||
|
||
class ContextHydrated | ||
{ | ||
/** | ||
* The context instance. | ||
* | ||
* @var \Illuminate\Log\Context\Repository | ||
*/ | ||
public $context; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @param \Illuminate\Log\Context\Repository $context | ||
*/ | ||
public function __construct($context) | ||
{ | ||
$this->context = $context; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @timacdonald,
JobRetryRequested
has a different interface for the payload.for example, spatie/laravel-multitenacy has covered this here
Am I missing something or this scenario was not mapped out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What issue are you seeing in particular?