在使用Go运行时的App Engine上,如何在实例之间传递套接字?

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

How can I pass a socket between instances on App Engine using the Go runtime?

问题

Python运行时通过pickling the connection来实现。在经典App Engine上,使用Go运行时的google.golang.org/appengine/socket是否有类似的方法来共享套接字?

英文:

The Python runtime allows it by pickling the connection. Is there a similar way to share sockets using the Go runtime on classic App Engine with google.golang.org/appengine/socket?

答案1

得分: 0

描述符在Go API中没有暴露出来:https://github.com/golang/appengine/blob/master/socket/socket_classic.go#L152

type Conn struct {
    ctx    context.Context
    desc   string
    offset int64

    prot          pb.CreateSocketRequest_SocketProtocol
    local, remote *pb.AddressPort

    readDeadline, writeDeadline time.Time // optional
}

desc是在另一端重建套接字所需的内容。

你可以在GitHub上fork这个库,将conn结构体修改为公开所需的desc属性,然后将导入更改为github.com/YOURUSERNAME/appengine/socket而不是appengine/socket

这是一项很大的工作,所以如果你能想出其他解决方法,可能会更好。尽管如此,这应该是可行的。

英文:

The descriptor isn't exposed in the Go API: https://github.com/golang/appengine/blob/master/socket/socket_classic.go#L152

type Conn struct {
    ctx    context.Context
    desc   string
    offset int64

    prot          pb.CreateSocketRequest_SocketProtocol
    local, remote *pb.AddressPort

    readDeadline, writeDeadline time.Time // optional
}

desc is what you would need on the other side to reconstruct the socket.

It should be possible fork this library on GitHub, change the conn struct to expose the needed desc property, and then change the import to github.com/YOURUSERNAME/appengine/socket instead of appengine/socket.

It's a lot of work so if you can come up with a different way to solve this you're probably better off. Nevertheless it should be possible.

huangapple
  • 本文由 发表于 2015年12月16日 23:40:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/34316147.html
匿名

发表评论

匿名网友

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

确定