microo8 / plgo

easily create postgresql extensions in golang; moved to gitlab.com/microo8/plgo
292 stars 23 forks source link

Background Worker written in Go #2

Open fabriziomello opened 6 years ago

fabriziomello commented 6 years ago

Hi,

We did some experiments, look at: https://github.com/prest/bgworker

microo8 commented 6 years ago

Yes I've seen that and add a star to that project :) But didn't have time/energy/some other excuse ... I leave this open as a reminder to do it. Or if anyone can do it I will pull it right away

omani commented 6 years ago

any news to this? being able to use goroutines would be absolutely awesome.

microo8 commented 6 years ago

I've been testing this. It works fine, also have ideas how to integrate it to plgo tool. But I've got a problem, that goroutines are not starting. Is someone familiar with it? I must somehow enable threading in the background worker?

fabriziomello commented 6 years ago

@microo8 would be nice if you share some code sample

microo8 commented 6 years ago

The code that I experimented with is in the test/bgw directory

Wanted to isolate the get_got _sigterm and wait_latch to something similar as the time.Tick method. It needs to run a separate goroutine to wait for the latch. (Also need to add close on that channel)

Also tried to run a goroutine, that doesn't use the log (maybe the log isn't accessible from another thread), but does something else (like touch a new file). But it doesn't run.