move package

This commit is contained in:
jackdaw@loafle.com 2017-04-17 13:24:59 +09:00
parent 927c9fd256
commit 0c46f6e24b
5 changed files with 26 additions and 17 deletions

View File

@ -1,16 +1,18 @@
package main
package impl
import (
"golang.org/x/net/context"
pb "loafle.com/overflow/crawler_go/grpc"
"loafle.com/overflow/crawler_go"
)
type ConfigServer struct {
type ConfigServerImpl struct {
Crawlers map[string]crawler.Crawler
}
func (s *ConfigServer) Add(c context.Context, in *pb.Input) (*pb.Output, error) {
func (s *ConfigServerImpl) Add(c context.Context, in *pb.Input) (*pb.Output, error) {
output := &pb.Output{}
if c, ok := g_crawlers[in.Name.String()]; ok {
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Add(in.Id)
if err != nil {
// process error
@ -21,9 +23,9 @@ func (s *ConfigServer) Add(c context.Context, in *pb.Input) (*pb.Output, error)
}
return output, nil
}
func (s *ConfigServer) Remove(c context.Context, in *pb.Input) (*pb.Output, error) {
func (s *ConfigServerImpl) Remove(c context.Context, in *pb.Input) (*pb.Output, error) {
output := &pb.Output{}
if c, ok := g_crawlers[in.Name.String()]; ok {
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Remove(in.Id)
if err != nil {
// process error
@ -34,11 +36,11 @@ func (s *ConfigServer) Remove(c context.Context, in *pb.Input) (*pb.Output, erro
}
return output, nil
}
func (s *ConfigServer) Init(c context.Context, inputArray *pb.InputArray) (*pb.Output, error) {
func (s *ConfigServerImpl) Init(c context.Context, inputArray *pb.InputArray) (*pb.Output, error) {
output := &pb.Output{}
for _,in := range inputArray.In {
if c, ok := g_crawlers[in.Name.String()]; ok {
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Init(in.Path)
if err != nil {
// process error

View File

@ -1,18 +1,20 @@
package main
package impl
import (
"golang.org/x/net/context"
pb "loafle.com/overflow/crawler_go/grpc"
"loafle.com/overflow/crawler_go"
)
type DataServer struct {
type DataServerImpl struct {
Crawlers map[string]crawler.Crawler
}
func (s *DataServer) Get(c context.Context, in *pb.Input) (*pb.Output, error) {
func (s *DataServerImpl) Get(c context.Context, in *pb.Input) (*pb.Output, error) {
output := &pb.Output{}
if c, ok := g_crawlers[in.Name.String()]; ok {
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Get(in.Id)
if err != nil {
// process error

View File

@ -1,14 +1,14 @@
package main
package impl
import(
"golang.org/x/net/context"
pb "loafle.com/overflow/crawler_go/grpc"
)
type StatusServer struct {
type StatusServerImpl struct {
}
func (s *StatusServer) Status(c context.Context, in *pb.Empty) (*pb.Boolean, error) {
func (s *StatusServerImpl) Status(c context.Context, in *pb.Empty) (*pb.Boolean, error) {
output := &pb.Boolean{}
output.Check =true
return output, nil

View File

@ -6,6 +6,7 @@ import (
"loafle.com/overflow/crawler_go"
pb "loafle.com/overflow/crawler_go/grpc"
"loafle.com/overflow/crawler_go/health_crawler/redis_protocol_crawler_go"
"loafle.com/overflow/rpc_network_crawler_go/impl"
"log"
"net"
"loafle.com/overflow/crawler_go/health_crawler/activedirectory_protocol_crawler_go"
@ -94,5 +95,9 @@ func start(rc pb.ConfigServer, rd pb.DataServer, rs pb.StatusServer) {
func main() {
initCrawlers()
start(&ConfigServer{}, &DataServer{}, &StatusServer{})
start(&impl.ConfigServerImpl{
Crawlers : g_crawlers,
}, &impl.DataServerImpl{
Crawlers : g_crawlers,
}, &impl.StatusServerImpl{})
}

View File

@ -19,7 +19,7 @@ type call func() crawler.Crawler
func startRPCServerTest(cc call) {
rr := cc()
AddDelegate(pb.Crawlers_HEALTH_REDIS.String(), rr)
go start(&ConfigServer{}, &DataServer{},&StatusServer{})
go start(&ConfigServerImpl{}, &DataServerImpl{},&StatusServerImpl{})
}
func clientCall(t *testing.T, cl pb.Crawlers) {