A simple commit log
example for distributed computing.
See: Distributed Services with Go
go run cmd/server/main.go
$ curl -X POST localhost:8080 -d \
'{"record": {"value": "TGV0J3MgR28gIzEK"}}'
$ curl -X POST localhost:8080 -d \
'{"record": {"value": "TGV0J3MgR28gIzIK"}}'
$ curl -X POST localhost:8080 -d \
'{"record": {"value": "TGV0J3MgR28gIzMK"}}'
$ curl -X GET localhost:8080 -d '{"offset": 0}'
$ curl -X GET localhost:8080 -d '{"offset": 1}'
$ curl -X GET localhost:8080 -d '{"offset": 2}'
-
Download the latest version of protoc for the target system.
sudo apt install protobuf-compiler sudo apt install golang-goprotobuf-dev
-
Add
proto
filesmkdir -p api/v1 touch api/v1/log.protot
-
Install protobuf into project
go get google.golang.org/protobuf/[email protected]
-
Generate
protoc api/v1/*.proto \ --go_out=. \ --go_opt=paths=source_relative \ --proto_path=.