Closed zenhack closed 7 years ago
There is a way right now, but it is subtle. If you use the _Methods
generated function, you can accumulate a bunch of methods in a slice and pass that to server.New
.
This was helpful thanks. Would be nice to have a smoother way to do this, but I'd have to think a bit to come up with something.
So, I just tripped over a problem I don't know how to solve cleanly with the current capnproto APIs: Sandstorm defines an interface AppPersistent in grain.capnp. It's disjoint from any other type heirarchy. Any object that is to be shared with other grains must implement this. But, the
_ServerToClient
functions only export the methods for that particular type. This means that if I want to fulfill a powerbox request, I need to have a declared common subtype between the interface I actually want to export and the AppPersistent interface. I ended up declaring a bunch of stubs in this patch, but I'm rather unhappy about it.It would be nice if there was a better way to do this -- it's very unidiomatic Go, and nothing about the protocol requires it.