From cb2b9a67b41312225c6a739f2bbe22bfbe3e0bcf Mon Sep 17 00:00:00 2001 From: snoop Date: Thu, 13 Apr 2017 11:53:00 +0900 Subject: [PATCH] first commit --- .gitignore | 23 ++++++++++++ crawler_manager.go | 83 +++++++++++++++++++++++++++++++++++++++++ crawler_manager_test.go | 21 +++++++++++ 3 files changed, 127 insertions(+) create mode 100644 .gitignore create mode 100644 crawler_manager.go create mode 100644 crawler_manager_test.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3352cfa --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/crawler_manager.go b/crawler_manager.go new file mode 100644 index 0000000..054b957 --- /dev/null +++ b/crawler_manager.go @@ -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) + +} \ No newline at end of file diff --git a/crawler_manager_test.go b/crawler_manager_test.go new file mode 100644 index 0000000..5620f8a --- /dev/null +++ b/crawler_manager_test.go @@ -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() +} \ No newline at end of file