The --bgworker option seems useful, but it spits out quite outdated code.
$ cargo pgx new mybgw --bgworker
$ cd mybgw
$ cargo pgx run pg15
error[E0599]: no function or associated item named `execute` found for struct `pgx::Spi` in the current scope
--> src/lib.rs:61:18
|
61 | Spi::execute(|client| {
| ^^^^^^^ function or associated item not found in `pgx::Spi`
The --bgworker option seems useful, but it spits out quite outdated code.
Probably https://github.com/tcdi/pgx/blob/master/cargo-pgx/src/templates/bgworker_lib_rs needs to be synced with https://github.com/tcdi/pgx/blob/master/pgx-examples/bgworker/src/lib.rs