Comments (2)
I've gone this route (queuing jobs via a trigger) and have had a great success with it. I use singletonkey
and startin
(where startin
is the throttle window). I'm using it to update my search index when records change that would affect the index. It's turned out to be extremely easy to setup!
In case it's helpful to others, here's what I'm using:
create or replace function dovetail_private.queuenoteforsearchindexing(note_id uuid) returns void as $$
insert into dovetail_pgboss.job (id, name, startin, singletonkey, data)
values
(
uuid_generate_v1(),
'SEARCH_INDEXING_INDEX_NOTE',
'10 seconds'::interval,
-- Using the note ID as the singletonkey serves to debounce based on note.
$1::text,
json_build_object('noteId', $1::text)
)
on conflict do nothing
$$ language sql strict security definer;
create function dovetail_private.note$queuesearchindexing() returns trigger as $$
begin
perform dovetail_private.queuenoteforsearchindexing(new.id);
-- result is ignored since this is an AFTER trigger
return null;
end;
$$ language plpgsql strict;
create trigger afterupdate050$queuesearchindexing after update
on dovetail.note
for each row
when (
new.title is distinct from old.title
or new.deleted is distinct from old.deleted
or new.type is distinct from old.type
or new.content_version is distinct from old.content_version
or new.ranges::text is distinct from old.ranges::text
)
execute procedure dovetail_private.note$queuesearchindexing();
from pg-boss.
👍 I have defaults defined for most fields, so unless you need to change them, they can be excluded from COPY or INSERT.
from pg-boss.
Related Issues (20)
- bug: swallowed error when connection is closed HOT 1
- The library does not support PostgreSQL 11, just 13+ HOT 1
- Bug: debounce mechanism schedule multiple jobs HOT 1
- High Database CPU when processing backlog HOT 9
- feature-request: It should be possible to predict a job key or id. HOT 4
- Use pg-boss with postgres.js HOT 5
- Stopping pg-boss gracefully does not wait until stop timeouts HOT 9
- 'stopping' state missing in TypeScript Types HOT 1
- Easier observability for expired jobs HOT 1
- Is pg-boss actively maintained? HOT 2
- Scheduled jobs cannot run more than once per minute HOT 7
- Limiting Concurrent Active Jobs Across Multiple Queues HOT 2
- Scheduling many individual jobs for the same queue HOT 3
- Document onComplete option HOT 1
- Job heartbeat support HOT 2
- Silently rejecting jobs when the db is not connected HOT 1
- New UUIDv7 increased performance and indexes
- Add a way to limit maximum retry delay for exponential backoff
- Should expire_in_seconds set the state to expired?
- Documentation for PgBoss constructor db option.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg-boss.