-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added new config helper function * flake8 * added docstrings * flake8 * removed need for config prefix * Add in container (#520) * added contains method to container * formatted and added tests * bumped version * Add ability to login using multiple columns (#521) * add list to auth class * adds ability to set a password column * formatted * fixed space in exception * Adds route redirection (#545) * adds a new redirect route class * flake8 * fixes issue where a json null could throw an exception (#544) * added ability to set status code in controller (#540) * added ability to set status code in controller * flake8 * added better exception when passing incorrect parameter type (#539) * added better exception when passing incorrect parameter type * fixed view test * fix delete method when body length is 0 (#529) * fix docstring for secure headers middleware (#548) * bumped version * Adds ability to use list for route params (#552) * Adds ability to use list for route params * added new assertion * Add new data type to be done serializing after response into json. * Fixing statement else if to elif * Inicial code to test response. * Assigment the serialized data to view variable to return just at end method. * Add test to verify the return of Response. * Wrapped serialized content by json() method from Response. * Filling more code to verify why Response is come empty. * minor tweaks for tests * flake8 * added ability to specify routes in the initializer (#559) * flake8 * Add migration message (#551) * added ability to show message when migrations are unmigrated * flake8 fixes * fixed command * flake8 * Adding statement to verify whether queue's driver is default. * Adding tests do verify default queue driver. Closes #564 * reworked queue connection drivers (#563) * fixed login method (#562) * bumped version * reworked queue connection drivers * modified queues * Masonite can now retry failed jobs 3 times and call a failed callback * added queue route * added failed job handling and job database table * fixed queue command docstrings * job failed methods now need to accept payload and error * commit * can now specify the channel you want to listen on * flake8 * flake8 * removed queue failed command * fixed command option descroption * fixed failed and fair * modified test * added base queue driver * only queueable classes will get requeud on fail * flake8 * upgrades async driver * updated async * cleaned up class inheritance * flake8 * fixed contract * updated queue contract * added better test for default * bumped version number
- Loading branch information
1 parent
e99da6c
commit 7f30c28
Showing
32 changed files
with
448 additions
and
101 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
include masonite/snippets/exceptions/css/* | ||
include masonite/snippets/exceptions/* | ||
include masonite/snippets/* | ||
include masonite/snippets/migrations/* | ||
include masonite/snippets/scaffold/* | ||
include masonite/snippets/auth/controllers/* | ||
include masonite/snippets/auth/templates/auth/* |
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,23 @@ | ||
""" A TestJob Queue Job """ | ||
|
||
from masonite.queues import Queueable | ||
|
||
|
||
class TestJob(Queueable): | ||
"""A TestJob Job | ||
""" | ||
|
||
def __init__(self): | ||
"""A TestJob Constructor | ||
""" | ||
|
||
pass | ||
|
||
def handle(self): | ||
"""Logic to handle the job | ||
""" | ||
|
||
return 2/0 | ||
|
||
def failed(self, payload, error): | ||
print('running a failed job hook') |
22 changes: 22 additions & 0 deletions
22
databases/migrations/2019_02_07_015506_create_failed_jobs_table.py
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,22 @@ | ||
from orator.migrations import Migration | ||
|
||
|
||
class CreateFailedJobsTable(Migration): | ||
|
||
def up(self): | ||
""" | ||
Run the migrations. | ||
""" | ||
with self.schema.create('failed_jobs') as table: | ||
table.increments('id') | ||
table.string('driver') | ||
table.string('channel') | ||
table.binary('payload') | ||
table.timestamp('failed_at') | ||
table.timestamps() | ||
|
||
def down(self): | ||
""" | ||
Revert the migrations. | ||
""" | ||
self.schema.drop('failed_jobs') |
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,18 @@ | ||
""" A QueueTableCommand Command """ | ||
|
||
|
||
from cleo import Command | ||
|
||
from masonite.helpers.filesystem import copy_migration | ||
|
||
|
||
class QueueTableCommand(Command): | ||
""" | ||
Create migration files for the queue feature | ||
queue:table | ||
""" | ||
|
||
def handle(self): | ||
copy_migration('masonite/snippets/migrations/create_failed_jobs_table.py') | ||
self.info('Migration created successfully') |
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
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,50 @@ | ||
"""Base queue driver.""" | ||
|
||
import pickle | ||
|
||
import pendulum | ||
|
||
from config import queue | ||
from masonite.drivers import BaseDriver | ||
from masonite.helpers import HasColoredCommands | ||
|
||
if 'amqp' in queue.DRIVERS: | ||
listening_channel = queue.DRIVERS['amqp']['channel'] | ||
else: | ||
listening_channel = 'default' | ||
|
||
|
||
class BaseQueueDriver(BaseDriver, HasColoredCommands): | ||
|
||
def add_to_failed_queue_table(self, payload): | ||
from config.database import DB as schema | ||
if schema.get_schema_builder().has_table('failed_jobs'): | ||
schema.table('failed_jobs').insert({ | ||
'driver': 'amqp', | ||
'channel': listening_channel, | ||
'payload': pickle.dumps(payload), | ||
'failed_at': pendulum.now() | ||
}) | ||
|
||
def run_failed_jobs(self): | ||
from config.database import DB as schema | ||
try: | ||
self.success('Attempting to send failed jobs back to the queue ...') | ||
for job in schema.table('failed_jobs').get(): | ||
payload = pickle.loads(job.payload) | ||
schema.table('failed_jobs').where('payload', job.payload).delete() | ||
self.push(payload['obj'], args=payload['args'], callback=payload['callback']) | ||
except Exception: | ||
self.danger('Could not get the failed_jobs table') | ||
|
||
def push(self, *objects, args=(), callback='handle', ran=1, channel=None): | ||
raise NotImplementedError | ||
|
||
def connect(self): | ||
return self | ||
|
||
def consume(self, channel, fair=False): | ||
raise NotImplementedError('The {} driver does not implement consume'.format(self.__class__.__name__)) | ||
|
||
def work(self): | ||
raise NotImplementedError('The {} driver does not implement work'.format(self.__class__.__name__)) |
Oops, something went wrong.