Fork me on GitHub
#beginners
<
2020-03-15
>
Luis C. Arbildo01:03:34

Hello, currently I'm building an application that manage various schedules for day. My first approach was have a list of task, iterate through this, and then create a schedule for each task, but today I was thinking if this is the best approach and I thought, I could have a list of task, but just create the next schedule when the previous one ends, and thus, I could have just one schedule waiting. What is your opinion about that? Is really best, or there is really not profit? (If you have a link about how you can manage schedule task, I will gratefully)

phronmophobic01:03:39

there is a scheduling library for clojure, http://clojurequartz.info/, but I’m not sure if it’s the same use case you have in mind. can you define what you mean by “task” and “schedule?”

phronmophobic01:03:37

is a task just a function you want to run?

Luis C. Arbildo01:03:29

Yes, in a specific time

Luis C. Arbildo01:03:10

This function send a event to a client socket

phronmophobic01:03:08

it kind of depends on how robust you need it to be. scheduling is actually pretty tricky to get right, especially if tasks can fail.

phronmophobic01:03:16

it sounds like you have at least one recurring task. how many periodic tasks do you expect? can scheduled tasks be cancelled?

phronmophobic01:03:41

do tasks have to run at a specific time (eg. 5pm on a sunday) or after a certain amount of time has passed (eg. 3 hours from now)?

Luis C. Arbildo01:03:02

The minimum could be 1h, and not be canceled

Luis C. Arbildo01:03:46

The taks could change each 24hrs

phronmophobic01:03:52

for both quartzite and the http-kit timer, the scheduled tasks are only stored in memory. is it a big deal if tasks are lost if the server gets restarted or goes down for some reason?

Luis C. Arbildo01:03:38

I think have the list in the db, if the server goes down, should be a function to filter just the task with a time positive ( taskTime - now) positive

👍 4
phronmophobic01:03:45

I think both approaches could work. the main drawback of scheduling the next task after a previous one finishes is that you definitely want to make sure that if the task fails for any reason, it doesn’t prevent the next task from being scheduled

phronmophobic01:03:15

additionally, scheduling the next task after the previous one task finishes assumes tasks don’t overlap.

Luis C. Arbildo01:03:04

In terms of CPU or memory usage, there a big difference?

phronmophobic01:03:15

how many tasks are you expecting? I’m imagining that most servers could handle a quite a lot of tasks before it would start to matter

phronmophobic01:03:26

spread out over 24 hours? I’d be pretty surprised if you were running into performance issues for that amount

👍 4
Luis C. Arbildo02:03:30

@U7RJTCH6J thank you for your time!

🙂 4
soxley19:03:32

Hi there, I'm having trouble accessing a Java nested class in Clojure:

flow (.. (new GoogleAuthorizationCodeFlow$Builder http-transport json-factory client-secrets scopes)
                 (setDataStoreFactory (FileDataStoreFactory. (File. tokens-directory-path)))
                 (setAccessType "offline")
                 (build))
Here is the relevant import:
(:import [com.google.api.client.googleapis.auth.oauth2 GoogleAuthorizationCodeFlow GoogleClientSecrets])
This is the error I'm getting:
1. Caused by java.lang.IllegalArgumentException
   Unable to resolve classname: GoogleAuthorizationCodeFlow$Builder
I haven't done much Java interop before, so I expect I'm doing something silly. This is the documentation for the GoogleAuthorizationCodeFlow class: https://googleapis.dev/java/google-api-client/latest/. Does anyone have any ideas or recommendations?

seancorfield20:03:16

@soxley Pretty sure you'll need to import GoogleAuthorizationCodeFlow$Builder as well.

seancorfield20:03:41

(off the top of my head)

seancorfield20:03:00

(and I assume you have the library on your classpath, as part of your dependencies?)