WIP: raft leadership

This commit is contained in:
Ingo Oppermann
2023-04-13 21:44:24 +02:00
parent b6a9fa7965
commit 7643959bf8
5 changed files with 442 additions and 76 deletions

View File

@@ -622,16 +622,18 @@ func (a *api) start() error {
a.restream = restream
if cluster, err := cluster.New(cluster.ClusterConfig{
ID: cfg.ID,
Name: cfg.Name,
Path: filepath.Join(cfg.DB.Dir, "cluster"),
IPLimiter: a.sessionsLimiter,
Logger: a.log.logger.core.WithComponent("Cluster"),
}); err != nil {
return fmt.Errorf("unable to create cluster: %w", err)
} else {
a.cluster = cluster
if cfg.Cluster.Enable {
if cluster, err := cluster.New(cluster.ClusterConfig{
ID: cfg.ID,
Name: cfg.Name,
Path: filepath.Join(cfg.DB.Dir, "cluster"),
IPLimiter: a.sessionsLimiter,
Logger: a.log.logger.core.WithComponent("Cluster"),
}); err != nil {
return fmt.Errorf("unable to create cluster: %w", err)
} else {
a.cluster = cluster
}
}
var httpjwt jwt.JWT
@@ -1318,7 +1320,8 @@ func (a *api) stop() {
}
if a.cluster != nil {
a.cluster.Stop()
a.cluster.Leave()
a.cluster.Shutdown()
}
// Stop JWT authentication