Skip to content

Commit

Permalink
Revert "Introduce Manager.Ctx()"
Browse files Browse the repository at this point in the history
This reverts commit 27bd71f.
  • Loading branch information
CbcWestwolf committed Jul 29, 2022
1 parent 70111de commit f47dd96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
11 changes: 2 additions & 9 deletions owner/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ type Manager interface {
CampaignOwner() error
// ResignOwner lets the owner start a new election.
ResignOwner(ctx context.Context) error
// Ctx returns the context of the manager.
Ctx() context.Context
// Cancel cancels this etcd ownerManager.
Cancel()
// RequireOwner requires the ownerManager is owner.
Expand Down Expand Up @@ -115,11 +113,6 @@ func (m *ownerManager) IsOwner() bool {
return atomic.LoadPointer(&m.elec) != unsafe.Pointer(nil)
}

// Ctx implements Manager.Ctx interface.
func (m *ownerManager) Ctx() context.Context {
return m.ctx
}

// Cancel implements Manager.Cancel interface.
func (m *ownerManager) Cancel() {
m.cancel()
Expand Down Expand Up @@ -156,12 +149,12 @@ func setManagerSessionTTL() error {
func (m *ownerManager) CampaignOwner() error {
logPrefix := fmt.Sprintf("[%s] %s", m.prompt, m.key)
logutil.BgLogger().Info("start campaign owner", zap.String("ownerInfo", logPrefix))
etcdSession, err := util2.NewSession(m.ctx, logPrefix, m.etcdCli, util2.NewSessionDefaultRetryCnt, ManagerSessionTTL)
session, err := util2.NewSession(m.ctx, logPrefix, m.etcdCli, util2.NewSessionDefaultRetryCnt, ManagerSessionTTL)
if err != nil {
return errors.Trace(err)
}
m.wg.Add(1)
go m.campaignLoop(etcdSession)
go m.campaignLoop(session)
return nil
}

Expand Down
6 changes: 0 additions & 6 deletions owner/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var _ Manager = &mockManager{}
type mockManager struct {
owner int32
id string // id is the ID of manager.
ctx context.Context
cancel context.CancelFunc
beOwnerHook func()
}
Expand All @@ -43,11 +42,6 @@ func NewMockManager(ctx context.Context, id string) Manager {
}
}

// Ctx implements Manager.Ctx interface
func (m *mockManager) Ctx() context.Context {
return m.ctx
}

// ID implements Manager.ID interface.
func (m *mockManager) ID() string {
return m.id
Expand Down

0 comments on commit f47dd96

Please sign in to comment.