github.com/midokura/kubeedge@v1.2.0-mido.0/tests/stubs/edge/handlerstub/module.go (about) 1 /* 2 Copyright 2019 The KubeEdge Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package handlerstub 18 19 import ( 20 "k8s.io/klog" 21 22 "github.com/kubeedge/beehive/pkg/core" 23 "github.com/kubeedge/kubeedge/tests/stubs/common/constants" 24 ) 25 26 // Init module 27 func init() { 28 core.Register(&HandlerStub{}) 29 } 30 31 // HandlerStub definition 32 type HandlerStub struct { 33 podManager *PodManager 34 } 35 36 // Return module name 37 func (*HandlerStub) Name() string { 38 return constants.HandlerStub 39 } 40 41 // Return module group 42 func (*HandlerStub) Group() string { 43 return constants.MetaGroup 44 } 45 46 // Start handler hub 47 func (hs *HandlerStub) Start() { 48 // New pod manager 49 pm, err := NewPodManager() 50 if err != nil { 51 klog.Errorf("Failed to create pod manager with error: %v", err) 52 return 53 } 54 hs.podManager = pm 55 56 // Wait for message 57 klog.Infof("Wait for message") 58 hs.WaitforMessage() 59 60 // Start upstream controller 61 upstream, err := NewUpstreamController(pm) 62 if err != nil { 63 klog.Errorf("New upstream controller failed with error: %v", err) 64 return 65 } 66 upstream.Start() 67 }