Added notes about setting up development environment, basis Makefile, and protobuf schema.
This commit is contained in:
39
Makefile
Normal file
39
Makefile
Normal file
@@ -0,0 +1,39 @@
|
||||
OS := $(shell sh -c 'uname -s 2>/dev/null || echo linux' | tr "[:upper:]" "[:lower:]")
|
||||
PROTOC := $(shell which protoc)
|
||||
platform = ubuntu-latest
|
||||
|
||||
# Protobuf compiler (aka Protoc)
|
||||
ifeq ($(OS), linux)
|
||||
protoc=protoc-3.14.0-linux-x86_64.zip
|
||||
endif
|
||||
ifeq ($(OS), darwin)
|
||||
protoc = protoc-3.14.0-osx-x86_64.zip
|
||||
platform = macos-latest
|
||||
endif
|
||||
|
||||
schema:
|
||||
ifeq (,$(wildcard ./tmp/protoc/bin/protoc))
|
||||
make protoc
|
||||
endif
|
||||
./tmp/protoc/bin/protoc --proto_path=./schema ./schema/bls12381sig.proto \
|
||||
--go_opt=paths=source_relative \
|
||||
--go_out=plugins=grpc:./go/bls/grpc/; \
|
||||
|
||||
protoc:
|
||||
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$(protoc)
|
||||
mkdir -p ./tmp/protoc
|
||||
unzip -o $(protoc) -d ./tmp/protoc bin/protoc
|
||||
unzip -o $(protoc) -d ./tmp/protoc 'include/*'
|
||||
rm -f $(protoc)
|
||||
go install google.golang.org/grpc@v1.42.0
|
||||
go install github.com/golang/protobuf/protoc-gen-go@latest
|
||||
|
||||
memprofile:
|
||||
go test -run=. -bench=. -benchtime=5s -count 1 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./... | tee bench.txt
|
||||
go tool pprof -http :8081 mem.out
|
||||
|
||||
benchmem: build test
|
||||
go test -run=. -bench=. -benchtime=5s -count 1 -benchmem ./...
|
||||
|
||||
clean:
|
||||
rm -rf ./tmp
|
||||
61
README.md
61
README.md
@@ -20,9 +20,68 @@ clear detail. Many tutorials leave out important things, and to ensure this does
|
||||
not happen, each stage's parts will be also found in the [steps](. /steps)
|
||||
folder at the root of the repository.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This tutorial was developed on a system running Pop OS based on Ubuntu 21.
|
||||
As such there may be some small differences compared to Ubuntu 20, but
|
||||
protobuf will still be version 3.
|
||||
|
||||
In general, you will be deploying your binaries to systems also running
|
||||
ubuntu 20 or 21 or similar, on x86-64 platform, so the same instructions can
|
||||
be used in setting up a fresh server when deploying. We will not cover
|
||||
Docker or any other container system here.
|
||||
|
||||
Necessary things that you probably already have:
|
||||
|
||||
sudo apt install -y build-essential git wget curl autoconf automake libtool
|
||||
|
||||
### Install Go
|
||||
|
||||
Go 1.17+ is recommended - unlike most other languages, the forward
|
||||
compatibility guarantee is ironclad, so go to
|
||||
[https://go.dev/dl/](https://go.dev/dl/) and pick the latest one (1.17.8 at
|
||||
time of writing), "copy link location" on the relevant version (linux x86-64)
|
||||
|
||||
cd
|
||||
mkdir bin
|
||||
wget https://go.dev/dl/go1.17.8.linux-amd64.tar.gz
|
||||
tar xvf go1.17.8.linux-amd64.tar.gz
|
||||
|
||||
This also creates a proper place where `go install` will put produced
|
||||
binaries, which is recommended for avoiding cluttering up repositories you
|
||||
are working on with binaries and potentially accidentally adding them to the
|
||||
repository, which can be very problematic if you are working on a BIG
|
||||
application (Go apps are generally under 60mb in size but this is still a
|
||||
lot in a source code repository).
|
||||
|
||||
Using your favourite editor, open up `~/.bashrc` - or just
|
||||
|
||||
nano ~/.bashrc
|
||||
|
||||
and put the following lines at the end
|
||||
|
||||
export GOBIN=$HOME/bin
|
||||
export GOPATH=$HOME
|
||||
export GOROOT=$GOPATH/go
|
||||
export PATH=$HOME/go/bin:$HOME/.local/bin:$GOBIN:$PATH
|
||||
|
||||
save and close, and `ctrl-d` to kill the terminal session, and start a new one.
|
||||
|
||||
### Install Protobuf Compiler
|
||||
|
||||
sudo apt install -y protobuf-compiler
|
||||
protoc --version # Ensure compiler version is 3+
|
||||
|
||||
### Notes
|
||||
|
||||
Note that we also will be demonstrating the use of `make` as a build tool.
|
||||
This is not strictly necessary when developing Go applications, but it is
|
||||
very commonly used for this purpose and can simplify a lot of things. This
|
||||
entire section could be automated into a makefile script, for example.
|
||||
|
||||
## Step By Step:
|
||||
|
||||
here will be the step by step process of building the library with a logical
|
||||
Here will be the step by step process of building the library with a logical
|
||||
sequence that builds from the basis to the specific parts for each in the order
|
||||
that is needed both for understanding and for the constraints of syntax, grammar
|
||||
and build system design...
|
||||
|
||||
34
service/schema/based32.proto
Normal file
34
service/schema/based32.proto
Normal file
@@ -0,0 +1,34 @@
|
||||
syntax = "proto3";
|
||||
package signer;
|
||||
option go_package = "github.com/quanterall/service";
|
||||
|
||||
service Transcriber {
|
||||
rpc Encode(EncodeRequest) returns (EncodeResponse);
|
||||
rpc Decode(DecodeRequest) returns (DecodeResponse);
|
||||
}
|
||||
enum Error {
|
||||
ZERO_LENGTH =0;
|
||||
CHECK_FAILED = 1;
|
||||
}
|
||||
|
||||
message EncodeRequest {
|
||||
bytes Data = 1;
|
||||
}
|
||||
|
||||
message EncodeResponse {
|
||||
oneof Encoded {
|
||||
string EncodedString = 1;
|
||||
Error Error = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message DecodeRequest{
|
||||
string EncodedString = 1;
|
||||
}
|
||||
|
||||
message DecodeResponse {
|
||||
oneof Decoded {
|
||||
bytes Data = 1;
|
||||
Error Error = 2;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,9 @@ type Service struct {
|
||||
}
|
||||
|
||||
type Handler struct {
|
||||
Chan interface{}
|
||||
Chan interface{}
|
||||
Params interface{}
|
||||
Result interface{}
|
||||
}
|
||||
|
||||
type Handlers map[string]Handler
|
||||
|
||||
Reference in New Issue
Block a user