1.9 KiB
1.9 KiB
How to develop truss
Dependencies
- Everything required to install
truss
- go-bindata for compiling templates into binary
$ go get github.com/jteeuwen/go-bindata/...
Building
Whenever templates are modified, the templates must be recompiled to binary, this is done with:
$ go generate github.com/Unity-Technologies/truss/...
Then to build truss and its protoc plugin to your $GOPATH/bin directory:
$ go install github.com/Unity-Technologies/truss/...
Both can be done from the Makefile in the root directory:
$ cd $GOPATH/github.com/Unity-Technologies/truss
$ make
Testing
Before submitting a pull request always run tests that cover modified code. Also build truss and run truss's integration test. This can be done by
$ cd $GOPATH/src/github.com/Unity-Technologies/truss
$ make
$ make test
# If the tests failed and you want to remove generated code
$ make testclean
Structure
Truss works as follows:
- Read in a group of
.proto
files - Execute
protoc
with ourprotoc-gen-protocast
protoc plugin, which outputs the protoc AST representation of the .proto files - Parse protoc's AST output and the
.proto
file with thegrpc Service
definition for http annotations usinggo-truss/deftree
- Use
protoc
andprotoc-gen-go
to generate.pb.go
files containing protobuf structs and transport for golang - Use the constructed
deftree
withgengokit
to template out basic gokit service with grpc and http/json transport and empty handlers - Generate documentation from comments with
gendocs
If there was already generated code in the filesystem then truss will not overwrite user code in the /NAME-service/handlers directory
Additional internal packages of note used by these programs are:
deftree
, located indeftree/
, which makes sense of the protobuf file passed to it byprotoc
, and is used bygengokit
andgendoc