haproxy-lb/pkg/cluster/cluster.go
2021-03-01 07:40:10 +01:00

34 lines
617 B
Go

package cluster
import (
"context"
"git.giftfish.de/ston1th/vipman/pkg/config"
"github.com/go-logr/logr"
)
type Cluster interface {
Start(*config.Config) error
SetCallbacks(Callbacks) error
Stepdown()
Stop()
}
type KV interface {
Get(k string) ([]byte, error)
GetPrefix(k string) (map[string][]byte, error)
Set(k string, v []byte) error
Delete(k string) error
}
type CallbackContext interface {
logr.Logger
KV
ID() string
}
type Callbacks struct {
Leader func(context.Context, CallbackContext)
Follower func(context.Context, CallbackContext)
Cleanup func(context.Context, CallbackContext)
}