35 lines
635 B
Go
35 lines
635 B
Go
package cluster
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.giftfish.de/ston1th/haproxy-lb/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
|
|
Fatal(error)
|
|
}
|
|
|
|
type Callbacks struct {
|
|
Leader func(context.Context, CallbackContext)
|
|
Follower func(context.Context, CallbackContext)
|
|
Cleanup func(context.Context, CallbackContext)
|
|
}
|