rpc_network_crawler_go/data_server.go

26 lines
445 B
Go
Raw Normal View History

2017-04-13 07:12:21 +00:00
package main
import (
"golang.org/x/net/context"
pb "loafle.com/overflow/crawler_go/grpc"
)
type DataServer struct {
}
func (s *DataServer) Get(c context.Context, in *pb.Input) (*pb.Output, error) {
output := &pb.Output{}
if c, ok := g_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
}