Ejemplo n.º 1
0
class AiopikaDriverConfig(DriverConfig):

    logo = fields.Str("""
 _____       _
|  __ \     (_)               
| |  | |_ __ ___   _____ _ __ 
| |  | | '__| \ \ / / _ \ '__|
| |__| | |  | |\ V /  __/ |   
|_____/|_|  |_| \_/ \___|_|aiopika""")

    health_endpoint = fields.Bool(False)

    rabbitmq: RabbitmqPropertyConfig = fields.Nested(RabbitmqPropertyConfig)
    queue: QueuePropertyConfig = fields.Nested(QueuePropertyConfig)

    # Processing
    prefetch_count = fields.Int(10)
    ignore_processed = fields.Bool(True)
    requeue_delay = fields.Int(10)
    default_retry_delay = fields.Int(60)
    requeue_unknown = fields.Bool(False)
    requeue_if_failed = fields.Bool(
        True)  # TODO: Set `requeue` for all AiopikaException subclasses

    sentry_dsn = fields.Str('', env_key='SENTRY_DSN')
    sentry_env = fields.Str('', env_key='SENTRY_ENV')
    sentry_ignore_errors = fields.List(fields.Str,
                                       default=[],
                                       env_key='SENTRY_IGNORE_ERRORS')
    sentry_kwargs = fields.Dict({}, env_key='SENTRY_KWARGS')

    version = fields.Str('', env_key='VERSION')
Ejemplo n.º 2
0
class AiopikaDriverConfig(DriverConfig):

    logo = fields.Str("""
 _____       _
|  __ \     (_)               
| |  | |_ __ ___   _____ _ __ 
| |  | | '__| \ \ / / _ \ '__|
| |__| | |  | |\ V /  __/ |   
|_____/|_|  |_| \_/ \___|_|aiopika""")

    workers = fields.Int(1)

    health_endpoint = fields.Bool(False)

    rabbitmq: RabbitmqPropertyConfig = fields.Nested(RabbitmqPropertyConfig)
    queue: QueuePropertyConfig = fields.Nested(QueuePropertyConfig)

    # Processing
    prefetch_count = fields.Int(10)
    ignore_processed = fields.Bool(True)
    requeue_delay = fields.Int(10)
    default_retry_delay = fields.Int(60)
    requeue_unknown = fields.Bool(False)
    requeue_if_failed = fields.Bool(
        True)  # TODO: Set `requeue` for all AiopikaException subclasses

    sentry_dsn = fields.Str('')
    sentry_env = fields.Str('dev')
Ejemplo n.º 3
0
class RabbitmqPropertyConfig(BaseConfig):
    host = fields.Str('localhost')
    port = fields.Int(5672)

    user = fields.Str('rabbitmq')
    password = fields.Str('test')

    vhost = fields.Str('/')
Ejemplo n.º 4
0
class SanicDriverConfig(DriverConfig):

    logo = fields.Str("""
 _____       _
|  __ \     (_)               
| |  | |_ __ ___   _____ _ __ 
| |  | | '__| \ \ / / _ \ '__|
| |__| | |  | |\ V /  __/ |   
|_____/|_|  |_| \_/ \___|_|sanic
    """)

    workers = fields.Int(1)

    host = fields.Str('0.0.0.0')
    port = fields.Int(8000)

    blueprint = fields.Str('')
    health_endpoint = fields.Bool(True)

    request_max_size = fields.Int(100000000)  # 100 megabytes
    request_timeout = fields.Int(60)  # 60 seconds
    response_timeout = fields.Int(60)  # 60 seconds
    keep_alive = fields.Bool(True)
    keep_alive_timeout = fields.Int(5)  # 5 seconds
    websocket_max_size = fields.Int(2**20)  # 1 megabytes
    websocket_max_queue = fields.Int(32)
    websocket_read_limit = fields.Int(2**16)
    websocket_write_limit = fields.Int(2**16)
    graceful_shutdown_timeout = fields.Int(15.0)  # 15 sec
    access_log = fields.Bool(True)

    sentry_dsn = fields.Str('', env_key='SENTRY_DSN')
    sentry_env = fields.Str('', env_key='SENTRY_ENV')
    sentry_kwargs = dict()

    def get_sanic_config(self) -> Config:
        c = Config()
        c.LOGO = self.logo
        c.REQUEST_MAX_SIZE = self.request_max_size
        c.REQUEST_TIMEOUT = self.request_timeout
        c.RESPONSE_TIMEOUT = self.response_timeout
        c.KEEP_ALIVE = self.keep_alive
        c.KEEP_ALIVE_TIMEOUT = self.keep_alive_timeout
        c.WEBSOCKET_MAX_SIZE = self.websocket_max_size
        c.WEBSOCKET_MAX_QUEUE = self.websocket_max_queue
        c.WEBSOCKET_READ_LIMIT = self.websocket_read_limit
        c.WEBSOCKET_WRITE_LIMIT = self.websocket_write_limit
        c.GRACEFUL_SHUTDOWN_TIMEOUT = self.graceful_shutdown_timeout
        c.ACCESS_LOG = self.access_log

        return c
Ejemplo n.º 5
0
class QueuePropertyConfig(BaseConfig):
    name = fields.Str('queue')
    auto_delete = fields.Bool(False)
    durable = fields.Bool(True)