malthe/pq

Adding name of the job producer

riyadparvez opened this issue · 2 comments

Is it possible to add the name of the job producer? It would be very helpful.

from psycopg2 import connect
from pq import PQ

conn = connect('dbname=example user=postgres')
pq = PQ(conn, client_name='test_client')

Worker will see the name of producer. And preferrably adding column submitted_by into the database schema.

>>> job
<pq.Job id=77709 submitted_by="test_client" size=1 enqueued_at="2014-02-21T16:22:06Z" schedule_at=None>
stas commented

Hmm, might make more sense to leverage the application_name in the connection string, this way the API doesn't change... 🤔
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

That's better option actually. It'd be helpful if you can add a property submitted_by or something similar to the Job class: https://github.com/malthe/pq/blob/master/pq/__init__.py#L395