Skip to content

vlopatkin/go-sentinel

Repository files navigation

go-sentinel

Build Status codecov Go Report Card

Package sentinel implements Redis Sentinel pub/sub watcher for golang

Installation

Install go-sentinel using the "go get" command:

go get github.com/ncade/go-sentinel

Documentation

See godoc for package and API descriptions

Usage

// create sentinel watcher with minimal config
snt := sentinel.New(sentinel.Config{
	Password:          "password",
	Addrs:             []string{"localhost:26379"},
	Groups:            []string{"redis01", "redis02", "redis03"},
	RefreshInterval:   45 * time.Second,
	HeartbeatInterval: 10 * time.Second,
	HeartbeatTimeout:  5 * time.Second,
})

// run redis instances discovery for configured groups
// and pub/sub listening for +switch-master, +slave, +sdown, -sdown events
go snt.Run()

defer snt.Stop()

// get master address for 'redis01' master name
master, err := snt.GetMasterAddr("redis01")

// get slaves addresses for 'redis01' master name
slaves, err := snt.GetSlavesAddrs("redis01")

About

Redis Sentinel watcher

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published