#Saving worker pool on quit/ resuming on next application open

9 messages · Page 1 of 1 (latest)

sterile raft
#

Whats the solution for this, how can I have a channel of jobs and write it to a file. Is that bad practice?
I don't think you can read a full channel so would i need to basically add a switch inside my workerRunJob function

    // don't do the work, just add to slice (will be called on all jobs overtime..)
    jobsToWriteToFile = append(jobsToWriteToFile,job)
} else{
    // Complete job
    // 30 seconds.....
}```
oak lantern
#

what is a "job" in your program?

sterile raft
#

just different snippets of tasks generally a few http requests or database query, sounds weird but yeah

#

maybe i need to create another slice representing the "jobs" and pop them off this readable list as they are done by workers

#

so channel for logic but another slice kept in sync of the actual remaining jobs

#

i probably just need to read into fundamentals some more, probably over complicating it / using it incorrectly

#

probably answered that wrong, job is a struct in my program.
I can determine what the work to do is from that struct

#

but all the jobs are stored in a channel, which is the dilemma of actually retrieving the remaining jobs when program quits

oak lantern
#

if theyre all in a struct, could you just marshal the slice of jobs and unmarshal them when you need them?