This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch refactor-with-go-components-experimental
in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git

commit 94ffebdc021fbd6952a397d9891802d65bb6deca
Author: chickenlj <[email protected]>
AuthorDate: Mon Jul 31 13:08:23 2023 +0800

    leader
---
 pkg/core/election/universal/leaderelection.go | 55 ---------------------------
 pkg/core/runtime/builder.go                   | 13 +------
 2 files changed, 2 insertions(+), 66 deletions(-)

diff --git a/pkg/core/election/universal/leaderelection.go 
b/pkg/core/election/universal/leaderelection.go
deleted file mode 100644
index 85f6511e..00000000
--- a/pkg/core/election/universal/leaderelection.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package universal
-
-import (
-       "github.com/apache/dubbo-admin/pkg/core/logger"
-       "github.com/apache/dubbo-admin/pkg/core/runtime/component"
-       syncatomic "sync/atomic"
-)
-
-type LeaderElection struct {
-       callbacks []component.LeaderCallbacks
-       leader    int32
-}
-
-// Start will start leader election, calling all runFns when we become the 
leader.
-func (l *LeaderElection) Start(stop <-chan struct{}) {
-       logger.Sugar().Info("starting Leader Elector")
-
-}
-
-func (p *LeaderElection) AddCallbacks(callbacks component.LeaderCallbacks) {
-       p.callbacks = append(p.callbacks, callbacks)
-}
-
-func (p *LeaderElection) IsLeader() bool {
-       return syncatomic.LoadInt32(&(p.leader)) == 1
-}
-
-func (p *LeaderElection) setLeader(leader bool) {
-       var value int32 = 0
-       if leader {
-               value = 1
-       }
-       syncatomic.StoreInt32(&p.leader, value)
-}
-
-func NewLeaderElection() *LeaderElection {
-       return &LeaderElection{}
-}
diff --git a/pkg/core/runtime/builder.go b/pkg/core/runtime/builder.go
index 58dabb6a..0ea7ee9c 100644
--- a/pkg/core/runtime/builder.go
+++ b/pkg/core/runtime/builder.go
@@ -85,19 +85,10 @@ func BuilderFor(appCtx context.Context, cfg 
*dubbo_cp.Config) (*Builder, error)
 }
 
 func (b *Builder) Build() (Runtime, error) {
-       if !b.cfg.KubeConfig.IsKubernetesConnected {
-               return &runtime{
-                       RuntimeInfo: b.runtimeInfo,
-                       RuntimeContext: &runtimeContext{
-                               cfg: b.cfg,
-                       },
-                       Manager: b.cm,
-               }, nil
-       }
-       if b.grpcServer == nil {
+       if b.grpcServer == nil && b.cfg.KubeConfig.IsKubernetesConnected {
                return nil, errors.Errorf("grpcServer has not been configured")
        }
-       if b.certStorage == nil {
+       if b.certStorage == nil && b.cfg.KubeConfig.IsKubernetesConnected {
                return nil, errors.Errorf("certStorage has not been configured")
        }
        return &runtime{

Reply via email to