cooperspencer / gickup

https://cooperspencer.github.io/gickup-documentation/
Apache License 2.0
962 stars 34 forks source link

Support hitting an endpoint on success #108

Closed jordancrawfordnz closed 2 years ago

jordancrawfordnz commented 2 years ago

(this is a feature request - it's something I'd like to implement if I get a chance but perhaps someone may be able to beat me too it!)

Background

Services such as healthchecks.io or Dead Mans Snitch are used to be alerted if something doesn't happen in your infrastructure. How it works is that each time something happens, such as running a backup, an endpoint on one of these services is hit. If this doesn't happen within the expected timeframe then something is broken and the administrator gets sent an email.

I personally find these very helpful, especially for things which are generally pretty set and forget like a backup - this means I can sleep easy knowing the backup will be working unless I'm told otherwise.

Suggested Solution

Introduce an optional 'success_url' config option - when the backup successfully runs, make a GET request to this endpoint.

cooperspencer commented 2 years ago

Something like this was already planned by @mtoohey31. Here you can have a look at what his approach was: https://github.com/cooperspencer/gickup/pull/100/files

jordancrawfordnz commented 2 years ago

Something like this was already planned by @mtoohey31. Here you can have a look at what his approach was: https://github.com/cooperspencer/gickup/pull/100/files

Oh nice - I only searched issues but didn't think to check for existing PRs!

I still think it'd be great to be able to use the built in cron schedular and support heartbeats, but I agree there is a danger of feature creep.

I'm happy to continue the implementation in #100 if @mtoohey31 is happy with that (and work on supporting multiple heartbeat URLs as suggested) otherwise I'll use their code as inspiration (I'm not too familiar with Go if I'm honest!).

mtoohey31 commented 2 years ago

Sure, feel free to use the code in #100 as your starting point. IIRC it was pretty much done except it only supported a single URL, so if you swap URL string for URLs []string in the heartbeat config, update the example config, and update the heartbeat.Send function to loop over the elements of conf.URLs and make a request for each item, that should be everything.

jordancrawfordnz commented 2 years ago

Thanks @mtoohey31! I've raised https://github.com/cooperspencer/gickup/pull/109 - I'm not very experienced in Go so your guidance and existing code made it all very easy!

mtoohey31 commented 2 years ago

Nice, thanks for taking the time to do that! Glad to hear you found the code helpful.