of_rpc => grpc

This commit is contained in:
jackdaw@loafle.com 2017-04-13 16:43:33 +09:00
parent a72e11fa30
commit 484c661739

View File

@ -9,11 +9,45 @@ type ConfigServer struct {
}
func (s *ConfigServer) Add(c context.Context, in *pb.Input) (*pb.Output, error) {
return nil, nil
output := &pb.Output{}
if c, ok := g_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 *ConfigServer) Remove(c context.Context, in *pb.Input) (*pb.Output, error) {
return nil, nil
output := &pb.Output{}
if c, ok := g_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 *ConfigServer) Init(c context.Context, in *pb.InputArray) (*pb.Output, error) {
return nil, nil
func (s *ConfigServer) 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 {
rd, err := c.Init(in.Path)
if err != nil {
// process error
}
output.Data = rd
} else {
output.Data = []byte("Not Assign Crawler")
}
}
return output, nil
}