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

54
impl/server_config.go Normal file
View File

@@ -0,0 +1,54 @@
package impl
import (
"golang.org/x/net/context"
pb "loafle.com/overflow/crawler_go/grpc"
"loafle.com/overflow/crawler_go"
)
type ConfigServerImpl struct {
Crawlers map[string]crawler.Crawler
}
func (s *ConfigServerImpl) Add(c context.Context, in *pb.Input) (*pb.Output, error) {
output := &pb.Output{}
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Add(in.Id)
if err != nil {
// process error
}
output.Data = rd
} else {
output.Data = []byte("Not Assign Crawler")
}
return output, nil
}
func (s *ConfigServerImpl) Remove(c context.Context, in *pb.Input) (*pb.Output, error) {
output := &pb.Output{}
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Remove(in.Id)
if err != nil {
// process error
}
output.Data = rd
} else {
output.Data = []byte("Not Assign Crawler")
}
return output, nil
}
func (s *ConfigServerImpl) Init(c context.Context, inputArray *pb.InputArray) (*pb.Output, error) {
output := &pb.Output{}
for _,in := range inputArray.In {
if c, ok := s.Crawlers[in.Name.String()]; ok {
rd, err := c.Init(in.Path)
if err != nil {
// process error
}
output.Data = rd
} else {
output.Data = []byte("Not Assign Crawler")
}
}
return output, nil
}

27
impl/server_data.go Normal file
View File

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

16
impl/server_status.go Normal file
View File

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