Example application
This is an example golang application. Commands list:
Packages which use in this example project
Install the Golang and GO environment
https://golang.org/doc/installInstall Postgresql (if you want to run locally)
Clone repository
git clone [email protected]:Aristat/golang-example-app.git (go get)Install Golang packages without modules
make installInstall database
make createdbSql migrations
sql-migrate upInstall Golang dependencies
make dependenciesGenerate artifacts(binary files and configs)
make buildPackages for proto generator
https://grpc.io/docs/languages/go/quickstart/#prerequisitesSet APP_WD if you start to use html templates or path to ssh keys or run make test
export APP_WD=go_path to project_path/resources or project_path/artifactsGenerate docker image
DOCKER_IMAGE=golang-example-app TAG=development make docker-imageUp jaeger in docker-compose or disable Jaeger(and rebuild binary file) in resources/configs/*.yaml
docker-compose up jaegerStart daemon (main service)
make startor
./artifacts/bin daemon -c ./artifacts/configs/development.yaml -dStart product service
./artifacts/bin product-service -c ./artifacts/configs/development.yaml -dStart health-check service
./artifacts/bin health-check -c ./artifacts/configs/development.yaml -ddocker-compose rm # Remove previous containers
REMOVE_CONTAINERS=on DOCKER_IMAGE=golang-example-app TAG=development make docker-image # Generate new docker image
docker-compose up./scripts/docker-compose-start.shhttp://localhost:16686http://localhost:9096/products_grpchttp://localhost:9096/products_natshttp://localhost:9096/products_slowlyGraphql client for testing. End-point http://localhost:9096/query.
Generate JWT for Graphql authorization
./artifacts/bin jwt token --key='./artifacts/keys/local/private_key.pem' --fields='{"sub": "owner", "iss": "test-service"}'Set JWT token in headers
{
"Authorization": "bearer token"
}Example query
query oneUser {
users {
one(email: "[email protected]") {
email
id
}
}
}Example query with data loader
query allProducts {
products {
list {
products {
id
productItems {
id
name
}
}
}
}
}Example mutation
mutation createUser {
users {
createUser(email: "[email protected]", password: "123456789") {
id
email
}
}
}➜ make testNo open issues yet, or sync has not completed.