Skip to content

Commit

Permalink
Add queue cli option (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbjorge authored Jan 20, 2025
1 parent e005601 commit 33ee624
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pgqueuer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,30 @@ async def run_async() -> None:
asyncio_run(run_async())


@app.command(help="Manually enqueue a job into the PGQueuer system.")
def queue(
ctx: Context,
entrypoint: str = typer.Argument(
...,
help="The entry point of the job to be executed.",
),
payload: None | str = typer.Argument(
None,
help="Optional payload for the job. Can be any serialized data (e.g., JSON or a string)",
),
) -> None:
config: AppConfig = ctx.obj

async def run_async() -> None:
await (await query_adapter(config.dsn)).enqueue(
entrypoint,
None if payload is None else payload.encode(),
priority=0,
execute_after=timedelta(seconds=0),
)

asyncio_run(run_async())


if __name__ == "__main__":
app(prog_name="pgqueuer")

0 comments on commit 33ee624

Please sign in to comment.