Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
laravel-mongodb
Commits
4e6cc229
Commit
4e6cc229
authored
Sep 02, 2016
by
Fady Khalife
Committed by
Jens Segers
Sep 02, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #789 (#792)
* Fixes #789 * StyleCI fixes * StyleCI fixes * StyleCI fixes
parent
87d8eedd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
README.md
README.md
+15
-0
MongodbQueueServiceProvider.php
src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php
+24
-0
MongoFailedJobProvider.php
...enssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
+66
-0
No files found.
README.md
View file @
4e6cc229
...
...
@@ -262,6 +262,21 @@ If you want to use MongoDB as your database backend, change the the driver in `c
],
```
If you want to use MongoDB to handle failed jobs, change the database in
`config/queue.php`
:
```
php
'failed'
=>
[
'database'
=>
'mongodb'
,
'table'
=>
'failed_jobs'
,
],
```
And add the service provider in
`config/app.php`
:
```
php
Jenssegers\Mongodb\MongodbQueueServiceProvider
::
class
,
```
### Sentry
If you want to use this library with
[
Sentry
](
https://cartalyst.com/manual/sentry
)
, then check out https://github.com/jenssegers/Laravel-MongoDB-Sentry
...
...
src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php
0 → 100644
View file @
4e6cc229
<?php
namespace
Jenssegers\Mongodb
;
use
Illuminate\Queue\QueueServiceProvider
;
use
Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider
;
class
MongodbQueueServiceProvider
extends
QueueServiceProvider
{
/**
* Register the failed job services.
*
* @return void
*/
protected
function
registerFailedJobServices
()
{
// Add compatible queue failer if mongodb is configured.
if
(
config
(
'queue.failed.database'
)
==
'mongodb'
)
{
$this
->
app
->
singleton
(
'queue.failer'
,
function
(
$app
)
{
return
new
MongoFailedJobProvider
(
$app
[
'db'
],
config
(
'queue.failed.database'
),
config
(
'queue.failed.table'
));
});
}
else
{
parent
::
registerFailedJobServices
();
}
}
}
src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php
0 → 100644
View file @
4e6cc229
<?php
namespace
Jenssegers\Mongodb\Queue\Failed
;
use
Carbon\Carbon
;
use
Illuminate\Queue\Failed\DatabaseFailedJobProvider
;
class
MongoFailedJobProvider
extends
DatabaseFailedJobProvider
{
/**
* Log a failed job into storage.
*
* @param string $connection
* @param string $queue
* @param string $payload
*
* @return void
*/
public
function
log
(
$connection
,
$queue
,
$payload
)
{
$failed_at
=
Carbon
::
now
()
->
getTimestamp
();
$this
->
getTable
()
->
insert
(
compact
(
'connection'
,
'queue'
,
'payload'
,
'failed_at'
));
}
/**
* Get a list of all of the failed jobs.
*
* @return array
*/
public
function
all
()
{
$all
=
$this
->
getTable
()
->
orderBy
(
'_id'
,
'desc'
)
->
get
();
$all
=
array_map
(
function
(
$job
)
{
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
return
$job
;
},
$all
);
return
$all
;
}
/**
* Get a single failed job.
*
* @param mixed $id
* @return array
*/
public
function
find
(
$id
)
{
$job
=
$this
->
getTable
()
->
find
(
$id
);
$job
[
'id'
]
=
(
string
)
$job
[
'_id'
];
return
$job
;
}
/**
* Delete a single failed job from storage.
*
* @param mixed $id
* @return bool
*/
public
function
forget
(
$id
)
{
return
$this
->
getTable
()
->
where
(
'_id'
,
$id
)
->
delete
()
>
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment