Fork me on GitHub
#proletarian
<
2023-03-31
>
emccue17:03:44

this might sound dumb - but im considering using proletariat's job table in...perhaps a strange way

emccue17:03:11

specifically, on a trigger from another table inserting a job for proletarian to pick up

István Karaszi17:06:33

I need to do exactly the same

emccue17:03:56

CREATE TABLE IF NOT EXISTS job (
    job_id      UUID PRIMARY KEY,   -- job id, generated and returned by proletarian.job/enqueue!
    queue       TEXT      NOT NULL, -- queue name
    job_type    TEXT      NOT NULL, -- job type
    payload     TEXT      NOT NULL, -- Transit-encoded job data
    attempts    INTEGER   NOT NULL, -- Number of attempts. Starts at 0. Increments when the job is processed.
    enqueued_at TIMESTAMP NOT NULL, -- When the job was enqueued (never changes)
    process_at  TIMESTAMP NOT NULL  -- When the job should be run (updates every retry)
);
I can edit this sql to make it a little easier on my end (default time on enqueued and processe_at and default value on attempts + job_id)

emccue17:03:10

but the thing im kinda going.eeerg on is the payload

emccue17:03:33

its pretty easy to make json in postgres for the job data, but if that json is "~" then its not valid transit

emccue17:03:45

which is such a dumb edge case but im thinking about it

emccue17:03:06

because it would mean that hypothetically putting a ~ at the start of some random fields would be a hidden bug

emccue17:03:31

and I almost want to ask if there is a way i could mark that the payload is actually json encoded

emccue18:03:22

you know what, :proletarian/serializer might be the thing. Just need to always use json

👍 2