I created a locker that uses Gorm and want to share it. #529
manuelarte
started this conversation in
Show and tell
Replies: 3 comments 1 reply
-
|
If you would like we could look at making another repo like https://github.com/go-co-op/gocron-redis-lock for gorm and having an implementation there to satisfy the gocron lock interface. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
That would be amazing, how can we proceed?
…On Mon, Jul 31, 2023, 6:39 PM John Roesler ***@***.***> wrote:
If you would like we could look at making another repo like
https://github.com/go-co-op/gocron-redis-lock for gorm and having an
implementation there to satisfy the gocron lock interface.
—
Reply to this email directly, view it on GitHub
<#529 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABIZ4I7A3OVD2UVKZMLE2ILXS7NTPANCNFSM6AAAAAA2ZUDFFI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@manuelarte Here is the repo: https://github.com/go-co-op/gocron-gorm-lock I'd suggest modeling after the patterns in https://github.com/go-co-op/gocron-redis-lock:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
This is just a locker I created that fulfills our needs, it was not built with the purpose of making it very generic, but I guess it could, potentially inspire other people that could have the same issue. In our case we are using Postgres and Gorm.
In our case, we have 4 pods running, in 2 different deployments and we are running one job every 24 hours. For that, every time a pod pick a job, it's storing it in the database, so if another pod tries to run the job, it first check:
If those conditions are met, a new entry in the database with that information plus the RUNNING status is created, and the unlock method, makes the status FINISHED.
Here is the code:
I hope it can help, and please I am open for feedback.
Beta Was this translation helpful? Give feedback.
All reactions