initializer

This commit is contained in:
insanity@loafle.com 2017-05-19 11:24:19 +09:00
parent 127cd706b4
commit 560a16b6fe
3 changed files with 32 additions and 4 deletions

View File

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="Go SDK">
<CLASSES>
<root url="file://$PROJECT_DIR$/../../../../../sdk/go/1.8/src" />
</CLASSES>
<SOURCES>
<root url="file://$PROJECT_DIR$/../../../../../sdk/go/1.8/src" />
</SOURCES>
</library>
</component>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,18 +1,18 @@
package initializer_go package initializer_go
import ( import (
"sync"
cm "loafle.com/overflow/agent_api/config_manager"
"google.golang.org/grpc" "google.golang.org/grpc"
cm "loafle.com/overflow/agent_api/config_manager"
"sync"
) )
var ( var (
once sync.Once once sync.Once
instance *Initializer instance *Initializer
) )
type Initializer struct { type Initializer struct {
gconf *cm.GlobalConfig gconf *cm.GlobalConfig
} }
func Start(ch chan string, conf *cm.GlobalConfig) error { func Start(ch chan string, conf *cm.GlobalConfig) error {
@ -26,6 +26,15 @@ func Start(ch chan string, conf *cm.GlobalConfig) error {
return nil return nil
} }
func Stop(res chan bool) {
GetInstance().stop()
res <- true
}
func GetInstance() *Initializer { func GetInstance() *Initializer {
once.Do(func() { once.Do(func() {
instance = &Initializer{} instance = &Initializer{}
@ -47,3 +56,6 @@ func (i *Initializer) getSecretKey() (string, error) {
} }
func (i *Initializer) stop() {
}