func listenerPinger(listener *pq.Listener) {
   for {
	   time.Sleep(60 * time.Second)
	   _ = listener.Ping()
   }
}
runs in its own goroutine
package main
import (
	"github.com/johto/notifyutils/notifydispatcher"
	"github.com/lib/pq"
	"fmt"
	"github.com/prometheus/client_golang/prometheus"
	"os"
	"sync"
	"time"
)
type pqListenerWrapper struct {
	l *pq.Listener
	ch chan *pq.Notification
	inputChannelSaturationRatio *prometheus.Desc
	dispatcherChannelSaturationRatio *prometheus.Desc
}
func newPqListenerWrapper(l *pq.Listener) (*pqListenerWrapper, error) {
	w := &pqListenerWrapper{
		l: l,
		ch: make(chan *pq.Notification, 4),
	}
	w.inputChannelSaturationRatio = prometheus.NewDesc(
		"allas_input_channel_saturation_ratio",
		"main notification input Go channel saturation",
		nil,
		nil,
	)
	w.dispatcherChannelSaturationRatio = prometheus.NewDesc(
		"allas_dispatcher_channel_saturation_ratio",
		"dispatcher notification Go channel saturation",
		nil,
		nil,
	)
	err := Config.Prometheus.RegisterMetricsCollector(w)
	if err != nil {
		return nil, err
	}
	go w.workerGoroutine()
	return w, nil
}
func (w *pqListenerWrapper) Describe(ch chan<- *prometheus.Desc) {
	ch <- w.inputChannelSaturationRatio
	ch <- w.dispatcherChannelSaturationRatio
}
func (w *pqListenerWrapper) Collect(ch chan<- prometheus.Metric) {
	inputChSaturation := float64(len(w.l.Notify)) / float64(cap(w.l.Notify))
	ch <- prometheus.MustNewConstMetric(w.inputChannelSaturationRatio, prometheus.GaugeValue, inputChSaturation)
	dispatcherChSaturation := float64(len(w.ch)) / float64(cap(w.ch))
	ch <- prometheus.MustNewConstMetric(w.dispatcherChannelSaturationRatio, prometheus.GaugeValue, dispatcherChSaturation)
}
func (w *pqListenerWrapper) workerGoroutine() {
	input := w.l.NotificationChannel()
	for {
		m := <-input
		MetricNotificationsReceived.Inc()
		w.ch <- m
	}
}
func (w *pqListenerWrapper) Listen(channel string) error {
	return w.l.Listen(channel)
}
func (w *pqListenerWrapper) Unlisten(channel string) error {
	return w.l.Unlisten(channel)
}
func (w *pqListenerWrapper) NotificationChannel() <-chan *pq.Notification {
	return w.ch
}