question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rare one off jobs & dynamic scheduled jobs

See original GitHub issue

I was really excited to see this library pop up - it’s awesome to see something using native worker threads and not requiring redis/mongo/some other store. But was then a bit confused by the configuration method when it came to trying it out.

I have use cases for different types of jobs:

  1. recurring jobs that operate like a cron
  2. one off, super rare, but long-running tasks that might never be run in the lifetime of the process
  3. jobs that are generated dynamically and need to be run at a specific time
  • 1 seems to be the main use case for Bree, but in my case the use case is smallest
  • 2 is the my main use case - I can sort of see how I might manage it by not calling bree.start() and only calling bree.run(‘task’) if the long running task is needed, but that feels like I’m not using the tool properly
  • 3 is a nice to have - already have code doing this, but unless I’m missing something there’s no way to achieve it with Bree - except approximation with a cron running every minute to check

Given the rareness of the one-off jobs, it’s a shame to have to declare them upfront, rather than being able to add them if and when they show up - otherwise there’s overhead for no good reason.

With type 3 specifically, I find it odd that Bree has support for setting an exact date when a job should run, but that can only be set on instantiation?

I guess I’m looking for bree.add(({jobConfig}) or bree.run({jobConfig}) - or am I massively missing something?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:41 (25 by maintainers)

github_iconTop GitHub Comments

2reactions
niftylettucecommented, Aug 18, 2020

v3.0.0 of Bree is released with support for Node v10+ and browsers.

See the updated README at https://github.com/breejs/bree#readme.

https://github.com/breejs/bree/releases/tag/v3.0.0

0reactions
NicolasGorgacommented, Feb 9, 2022

@shadowgate15 i tried this in the dummy function i sent you and it worked, although i dont understand the difference from what i wrote, since im using the await keyword for thw asyn operation and all the other operations are synchronous.

Now applying this approach to my real job doesnt work, it fails just as before. My real job:

(async () => { console.log(“In worker”);

const pushTokens = await userService.getPushTokens();

//nothing executes after the previous await console.log(“push tokens”, pushTokens);

if (pushTokens.length > 0) {
  console.log("need to send push");

  const messages: ExpoPushMessage[] = pushTokens.map((pt) => ({
	to: pt,
	title: "December Rooms",
	body: "Vas a ir a la oficina hoy?",
	data: {
	  screenName: "ConfirmAssist",
	},
  }));

  console.log("sending push", messages);

  sendNotifications(messages);

  console.log("al push sent");
} else {
  console.log("no push to send");
}

process.exit(0); })();

As you said with the dummy, i tried wrapping everything apart from the process.exit(0) in an async function, awaiting and the doing process.exit() but it didn’t work, this is confusing

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add new schedule job dynamically with Spring
If you want to dynamically schedule tasks you can do it without spring by using ExecutorService in particular ScheduledThreadPoolExecutor
Read more >
Dynamic Scheduling of Parallel Jobs with QoS Demands in ...
This paper addresses the dynamic scheduling of paral- lel jobs with QoS demands (soft-deadlines) in multi- clusters and grids. Three metrics (over-deadline,.
Read more >
Scheduled Task/Job, Technique T1053 - MITRE ATT&CK®
Monitor newly constructed scheduled jobs that may abuse task scheduling functionality to facilitate initial or recurring execution of malicious ...
Read more >
Building a simple dynamic job scheduler with Sidekiq - Tines
Every minute, we run a Sidekiq job (enqueued by sidekiq-scheduler) that acts as a “fan out” job. It queries the database for any...
Read more >
Jobs | Kubernetes
A Job creates one or more Pods and will continue to retry execution of the ... at the same time offloading actual pod-to-node...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found