Skip to content

uhtzf/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is a template for doing go-micro development using GitLab. It's based on the helloworld Go Micro template.

Reference links

Getting started

First thing to do is update main.go with your new project path:

-       proto "gitlab.com/gitlab-org/project-templates/go-micro/proto"
+       proto "gitlab.com/$YOUR_NAMESPACE/$PROJECT_NAME/proto"

Note that these are not actual environment variables, but values you should replace.

What's contained in this project

  • main.go - is the main definition of the service, handler and client
  • proto - contains the protobuf definition of the API

Dependencies

Install the following

Start Server

go run main.go --server_address localhost:8080

Query Service

micro call --address localhost:8080 greeter Greeter.Hello '{"name": "John"}'

Make API Call Example with grpcurl by opening new terminal

grpcurl -plaintext -d '{}' localhost:50051 RPRaisingService/GetCountries
grpcurl -plaintext -d '{}' localhost:50051 RPRaisingService/GetProductNames
grpcurl -plaintext -d '{}' localhost:50051 RPRaisingService/GetSimilarProjects
grpcurl -plaintext -d '{}' localhost:50051 RPRaisingService/GetScatterPlot
grpcurl -plaintext     -d '{"country": "60", "productName": "Product A", "employee_num": 15}'     localhost:50051     RPRaisingService.GenerateRP

Generate code from protobuf file

Make sure you have installed protoc and protoc-gen-go as described in https://github.com/go-micro/generator. Go to the directory am-rprasingv1.0 and then you can generate the go code using the following:

 protoc --proto_path=./proto   --go_out=paths=source_relative:./proto   --go-grpc_out=paths=source_relative:./proto   ./proto/rpraising.proto

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages