gpt4 book ai didi

go - 使用 GVisor (Cloud Run) 问题的 Pubsub 拉取订阅

转载 作者:IT王子 更新时间:2023-10-29 01:43:42 24 4
gpt4 key购买 nike

我想使用 Go 获取 Google PubSub 订阅。它在本地运行良好,但当我将它部署在 Cloud Run 上时,无法提取任何消息。

这是我的代码片段

func (pubSubService *pubSubService) Received() (msgArray []*pubsub.Message, err error) {
ctx := context.Background()
cctx, cancel := context.WithCancel(ctx)
msgArray = []*pubsub.Message{}

var receivedMessage = make(chan *pubsub.Message)

go func() {
for {
select {
case msg := <-receivedMessage:
msgArray = append(msgArray, msg)
case <-time.After(pubSubService.waitTimeOutInMillis * time.Millisecond):
cancel()
}
}
}()

err = pubSubService.client.Subscription(pubSubService.subscriptionName).Receive(cctx, func(ctx context.Context, msg *pubsub.Message) {
receivedMessage <- msg
msg.Ack()
})
if err != nil {
return
}

return
}

这里是日志错误

D  Container Sandbox Limitation: Unsupported syscall setsockopt(0x7,0x6,0x12,0xc00006f204,0x4,0x0) 
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x5,0x6,0x12,0xc0003c1204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xa,0x6,0x12,0xc0003bd204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xc,0x6,0x12,0xc00037d204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x6,0x6,0x12,0xc0002d3204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x8,0x6,0x12,0xc00052b204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x9,0x6,0x12,0xc000391204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xb,0x6,0x12,0xc00043b204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x6,0x6,0x12,0xc0003b3204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xc,0x6,0x12,0xc0003d3204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x7,0x6,0x12,0xc000391204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x5,0x6,0x12,0xc000309204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xb,0x6,0x12,0xc0004d3204,0x4,0x0)

Received call被Cloud Run的GVisor沙箱过滤

您知道为此问题设置的 workarround 或 ReceiveSetting 吗?提前致谢。

最佳答案

不,这是错误的。我发现了我的问题:我高估了 GCP 全局网络:取消轮询的超时设置为 200 毫秒。有了这个要求,我的应用程序就没有时间在取消之前恢复第一条消息。有 2000 毫秒的超时,它完美地工作!

Go routine可以用Cloud run,但是http请求回复后就不能存活了。

关于go - 使用 GVisor (Cloud Run) 问题的 Pubsub 拉取订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56197404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com