From 62111462fe64247deffabeddedc86952b3dbca56 Mon Sep 17 00:00:00 2001
From: Darren Shepherd <darren@rancher.com>
Date: Mon, 17 Sep 2018 15:58:44 -0700
Subject: [PATCH] Add peer manager

---
 config/context.go          |  3 ++-
 peermanager/peermanager.go | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 peermanager/peermanager.go

diff --git a/config/context.go b/config/context.go
index 013e5ef1..229a742b 100644
--- a/config/context.go
+++ b/config/context.go
@@ -23,6 +23,7 @@ import (
 	projectSchema "github.com/rancher/types/apis/project.cattle.io/v3/schema"
 	rbacv1 "github.com/rancher/types/apis/rbac.authorization.k8s.io/v1"
 	"github.com/rancher/types/config/dialer"
+	"github.com/rancher/types/peermanager"
 	"github.com/rancher/types/user"
 	"github.com/sirupsen/logrus"
 	"k8s.io/api/core/v1"
@@ -51,7 +52,7 @@ type ScaledContext struct {
 	AccessControl     types.AccessControl
 	Dialer            dialer.Factory
 	UserManager       user.Manager
-	Leader            bool
+	PeerManager       peermanager.PeerManager
 
 	Management managementv3.Interface
 	Project    projectv3.Interface
diff --git a/peermanager/peermanager.go b/peermanager/peermanager.go
new file mode 100644
index 00000000..b71a1a6a
--- /dev/null
+++ b/peermanager/peermanager.go
@@ -0,0 +1,15 @@
+package peermanager
+
+type Peers struct {
+	SelfID string
+	IDs    []string
+	Ready  bool
+	Leader bool
+}
+
+type PeerManager interface {
+	IsLeader() bool
+	Leader()
+	AddListener(l chan<- Peers)
+	RemoveListener(l chan<- Peers)
+}