Skip to content

adtechpotok/go-health

Repository files navigation

Build Status codecov Go Report Card License

Go health

result

{
"Version":"1.0",
"Lifetime":1307, 
"Errors":0,
"Warnings":0,
"Heartbeat":0, // fixing problem with closed binlog connection
"BinLogPosition":62532416,
"BinLogFile":"mysql-bin.000003",
"Additional":null, //any usefull data you need
"CacheState":
    {
    "Animals.Cats":27,
    "Superheroes.Marvel":12
    }
}

#Configuration

var daemonHealth = health.New(version)
var log = logrus.New() 

func init(){
	log.Hooks.Add(&health.HealthHook{daemonHealth})
}

func industrialHealth(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
	daemonHealth.CacheState = t
	err := daemonHealth.Health()
	if err != nil {
		log.Error(err)
		return
	}

    w.Header().Set("Content-Type", "application/json; charset=utf-8")
    js, _ := jsoniter.Marshal(result)
    w.Write(js)
}

add this to catch binlog slowdowns *don't forget to add mysql trigger to fix binlog freezing

func (h *binlogHandler) OnRow(e *canal.RowsEvent) error {
	defer func() {
		if r := recover(); r != nil {
			log.Error(r, " ", string(debug.Stack()))
		}
	}()
	go daemonHealth.CanalListener(e)
	return nil
}

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published