在使用buf注册golang gRPC中的serviceServer时出现错误。

huangapple go评论81阅读模式
英文:

error registering serviceServer in golang gRPC using buf

问题

我正在尝试编写一个使用buf的gRPC golang服务器。我不认为buf是问题所在。项目位于:https://github.com/vinceyoumans/wc6

在server01/main.go的第70行

crawlerpb.RegisterCrawlerServiceServer(grpcServer, &crawlServer{})
出现了一个错误

无法将'&crawlServer{}'(类型为*crawlServer)用作CrawlerServiceServer类型,因为类型未实现'CrawlerServiceServer',需要方法:MonitorCrawl(CrawlerService_MonitorCrawlServer) error,但是只有方法:MonitorCrawl(in *crawlerpb.MonitorCrawlRequest, stream crawlerpb.CrawlerService_MonitorCrawlServer) error

我相信所有这些方法都已经实现了。

由于涉及到很多组件,所以无法添加所有的代码,但是在解决问题时我会进行具体的记录。

有什么建议吗?

英文:

I am trying to code a gRPC golang server, using buf. I don't believe buf is the problem. The project is at: https://github.com/vinceyoumans/wc6

line 70 in server01/main.go

crawlerpb.RegisterCrawlerServiceServer(grpcServer, &crawlServer{})
is giving an error

Cannot use '&crawlServer{}' (type *crawlServer) as the type CrawlerServiceServer Type does not implement 'CrawlerServiceServer' need the method: MonitorCrawl(CrawlerService_MonitorCrawlServer) error have the method: MonitorCrawl(in *crawlerpb.MonitorCrawlRequest, stream crawlerpb.CrawlerService_MonitorCrawlServer) error

All of these methods I believe are implemented.

There are a lot of moving parts, so cannot add all of the code, but will document with specifics when I resolve problem.

any suggestions?

答案1

得分: 1

我认为我解决了这个问题。解决方案是从rpc MonitorCrawl( stream MonitorCrawlRequest)中移除Stream...这是一个修复方法,它可以编译、运行和监听。但我还需要看看它是否与客户端一起工作。

英文:

I think I resolved the question. The solution was to remove the Stream from the rpc MonitorCrawl( stream MonitorCrawlRequest)... this is a fix, as in it compiles and runs... and listens. But I still have to see if it works with a client

huangapple
  • 本文由 发表于 2023年1月19日 14:36:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/75168538.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定