26 lines
445 B
Go
26 lines
445 B
Go
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
|
|
}
|