♻️ Refactor task worker.

This commit is contained in:
Andrey Antukh 2020-08-06 16:05:14 +02:00 committed by Hirunatan
parent bda9cad3c2
commit b1b3ad61a5
13 changed files with 317 additions and 131 deletions

View file

@ -6,8 +6,10 @@
</Console>
</Appenders>
<Loggers>
<Logger name="io.vertx.sqlclient.impl.SocketConnectionBase" level="ERROR"/>
<Root level="info">
<Logger name="com.zaxxer.hikari" level="info" additivity="false"></Logger>
<Logger name="io.lettuce.core" level="info" additivity="false"></Logger>
<Logger name="io.netty" level="info" additivity="false"></Logger>
<Root level="debug">
<AppenderRef ref="console"/>
</Root>
</Loggers>

View file

@ -0,0 +1,29 @@
DROP TABLE task;
CREATE TABLE task (
id uuid DEFAULT uuid_generate_v4(),
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
modified_at timestamptz NOT NULL DEFAULT clock_timestamp(),
completed_at timestamptz NULL DEFAULT NULL,
scheduled_at timestamptz NOT NULL,
priority smallint DEFAULT 100,
queue text NOT NULL,
name text NOT NULL,
props jsonb NOT NULL,
error text NULL DEFAULT NULL,
retry_num smallint NOT NULL DEFAULT 0,
max_retries smallint NOT NULL DEFAULT 3,
status text NOT NULL DEFAULT 'new',
PRIMARY KEY (id, status)
) PARTITION BY list(status);
CREATE TABLE task_completed partition OF task FOR VALUES IN ('completed', 'failed');
CREATE TABLE task_default partition OF task default;
CREATE INDEX task__scheduled_at__queue__idx
ON task (scheduled_at, queue)
WHERE status = 'new' or status = 'retry';

View file

@ -0,0 +1,3 @@
delete from generic_token;
alter table generic_token drop column content;
alter table generic_token add column content jsonb not null;