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)
- Scheduling many individual jobs for the same queue HOT 3
- Document onComplete option HOT 1
- Job heartbeat support HOT 4
- Silently rejecting jobs when the db is not connected HOT 1
- New UUIDv7 increased performance and indexes HOT 2
- Add a way to limit maximum retry delay for exponential backoff
- Should expire_in_seconds set the state to expired? HOT 1
- Documentation for PgBoss constructor db option.
- sub queues or queue groups
- Specify multiple host connections for PostgreSQL / Database Fail-Over
- Use of MD5 for Advisory Locks Crashes pg-boss on FIPS-Compliant Platforms HOT 1
- useSingletonQueue missing from JobInsert type
- Error: Jest has detected the following 1 open handle potentially keeping Jest from exiting HOT 3
- Typo in validation for Postgres names HOT 3
- Update types for v10 HOT 2
- db.lock is not a function HOT 1
- Feature Request: Bull-Board support/Fork HOT 6
- Job partitions pollute public schema HOT 1
- Tests failing in CI workflow HOT 1
- Issues with queue in v10 HOT 2
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.