go - Should you use protobuf as the datatype you use for processing or only for transmission? -
i have matrix struct written in go. matrix struct has bunch of methods. want able efficiently compute matrix operations want able send on wire in order distribute computation.
i have matrix , methods separate protobuf definition. when need send on wire have create new pb.matrix{} existing matrix{} struct , make grpc call. seems waste. so, waste? , should defining matrix struct protobuf definition , use embedding define operations on it? or better keep them separate each other?
in terms of architecture, i'd keep them separate. agree single responsibility principle. in 1 of projects use form:
type foo struct { ... } func newfoofromproto(f *myproto.foo) *foo { ... } func (f *foo) toproto() *myproto.foo { ... }
Comments
Post a Comment