move package
This commit is contained in:
54
impl/server_config.go
Normal file
54
impl/server_config.go
Normal 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
27
impl/server_data.go
Normal 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
16
impl/server_status.go
Normal 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user