heartbeat

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 7 Imported by: 2

README

heartbeat

A simple NATS Heartbeat lib

Documentation

Index

Constants

View Source
const (
	PublisherTopic        = "peer-heartbeat"
	ConsumerRegisterTopic = "peer-consumer-register"
	CurrentConsumersTopic = "peer-consumers"
	TickerTime            = 30 * time.Second
	MetricsTimeout        = 2 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(id string, nc *nats.Conn, hos ...Option) *Handler

func (*Handler) Close added in v0.0.7

func (h *Handler) Close()

func (*Handler) GetConsumers

func (h *Handler) GetConsumers() []string

func (*Handler) ListenForConsumers

func (h *Handler) ListenForConsumers()

func (*Handler) ListenForHeartbeatPublisher

func (h *Handler) ListenForHeartbeatPublisher()

func (*Handler) StartHeartbeatPublisher

func (h *Handler) StartHeartbeatPublisher()

type MetricsHandler added in v0.0.2

type MetricsHandler interface {
	RecordConsumerRegistered(ctx context.Context, id string, current int)
	ResetConsumerRegistered(ctx context.Context)
}

type NilMetrics added in v0.0.2

type NilMetrics struct {
}

func NewNilMetrics added in v0.0.2

func NewNilMetrics() *NilMetrics

func (*NilMetrics) RecordConsumerRegistered added in v0.0.2

func (m *NilMetrics) RecordConsumerRegistered(ctx context.Context, id string, current int)

func (*NilMetrics) ResetConsumerRegistered added in v0.0.4

func (m *NilMetrics) ResetConsumerRegistered(ctx context.Context)

type Option

type Option func(h *Handler)

func SetConsumerRegisterTopic

func SetConsumerRegisterTopic(topic string) Option

func SetCurrentConsumersTopic added in v0.0.7

func SetCurrentConsumersTopic(topic string) Option

func SetHeartbeatTickerTime

func SetHeartbeatTickerTime(ti time.Duration) Option

func SetHeartbeatTopic

func SetHeartbeatTopic(topic string) Option

func SetLogger

func SetLogger(l logrus.FieldLogger) Option

func SetMetrics added in v0.0.2

func SetMetrics(m MetricsHandler) Option

func SetMetricsTimeout added in v0.0.6

func SetMetricsTimeout(t time.Duration) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL