gorums icon indicating copy to clipboard operation
gorums copied to clipboard

Generate server skeleton code

Open meling opened this issue 4 years ago • 1 comments

Provide argument gorums_out=srv=<srvName>,paths=... to protoc-gen-gorums to generate skeleton server code. The generated code would be saved to a file srvname.go. Decide if we should support both source_relative and other options. If srvname.go already exists and is non-empty, it should not be overwritten unless explicitly forced.

type srvName struct {
}

func (s * srvName) Unicast(ctx context.Context, r *proto.Request) {
}

func (s * srvName) Multicast(ctx context.Context, r *proto.Request) {
}

func (s * srvName) QuorumCall(ctx context.Context, req *proto.Request, out func(*proto.Response, error)) {
	out(&proto.Response{
		Field: nil, // TODO initialize
	}, nil)
}

meling avatar Apr 14 '21 11:04 meling

The default should be to generate server and client code templates unless they already exist. We could read an existing file, and check whether or not the method signatures still match, e.g. after a change, and warn the user.

meling avatar Apr 21 '21 10:04 meling