first commit

This commit is contained in:
snoop 2017-04-13 11:53:00 +09:00
commit cb2b9a67b4
3 changed files with 127 additions and 0 deletions

23
.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# Created by .ignore support plugin (hsz.mobi)
### Go template
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
.gitignore 제거할 예정
.idea/ 제거할 예정
crawler_manager.go 제거할 예정
.idea/
*.iml/

83
crawler_manager.go Normal file
View File

@ -0,0 +1,83 @@
package crawler_manager
import (
"google.golang.org/grpc"
"log"
g "loafle.com/overflow/crawler_go/grpc"
"context"
)
const (
address = "192.168.1.105:50052"
)
func CallAdd() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
cc := g.NewConfigClient(conn)
in := &g.Input{}
in.Path = ""
in.Id = ""
in.Name = g.Crawlers_HEALTH_DNS
out, err := cc.Add(context.Background(), in)
if err != nil {
log.Println(err)
}
log.Println(out)
}
func CallInit() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
cc := g.NewConfigClient(conn)
in := &g.Input{}
in.Path = ""
in.Id = ""
in.Name = g.Crawlers_HEALTH_DNS
inArr := &g.InputArray{}
inArr.In = append(inArr.In, in)
outInit, errInit := cc.Init(context.Background(), inArr)
if errInit != nil {
log.Println(errInit)
}
log.Println(outInit)
}
func CallRemove() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
cc := g.NewConfigClient(conn)
inR := &g.Input{}
inR.Id = "123123"
inR.Name = g.Crawlers_HEALTH_DNS
outRem, errRem := cc.Remove(context.Background(), inR)
if errRem != nil {
log.Println(errRem)
}
log.Println(outRem)
}

21
crawler_manager_test.go Normal file
View File

@ -0,0 +1,21 @@
package crawler_manager
import (
"testing"
//grpc1 "google.golang.org/grpc"
)
func TestAdd(t *testing.T) {
CallAdd();
}
func TestCallInit(t *testing.T) {
CallInit()
}
func TestCallRemove(t *testing.T) {
CallRemove()
}