项目作者: radekwlsk

项目描述 :
Mini microservice with Go, go-kit and gRPC.
高级语言: Go
项目地址: git://github.com/radekwlsk/go-kit-svc.git
创建时间: 2017-06-28T20:07:24Z
项目社区:https://github.com/radekwlsk/go-kit-svc

开源协议:

下载


String Service

Microservice training using Go, go-kit toolkit and gRPC RPC framework for message transport (together with protobuf data interchange format).

Based on go-kit examples:

and ru rocker’s tutorial on microservices using go-kit and gRPC.

StringService provides only 3 basic operations on strings as project is made to learn microservices and gRPC principles more than Go itself.

Usage

Run server using main.go file:

  1. $ go run main.go

Now HTTP requests can be made:

  1. $ curl -XPOST -d'{"s":"hello, world!"}' localhost:8080/tc
  2. {"v":"Hello, World!"}
  3. $ curl -XPOST -d'{"s":"hello, world!"}' localhost:8080/rw
  4. {"v":"hello,world!"}
  5. $ curl -XPOST -d'{"s":"hello, world!"}' localhost:8080/c
  6. {"v":13}

Or gRPC client can be run:

  1. $ go run cmd/client.go -http-addr="localhost:8080" tc "hello, world!" rw "hello, world!" c "hello, world!"
  2. Hello, World!
  3. hello,world!
  4. 13
  5. $ go run cmd/client.go -grpc-addr="8081" tc "hello, world!" rw "hello, world!" c "hello, world!"
  6. Hello, World!
  7. hello,world!
  8. 13

program arguments are in form flags cmd str cmd str cmd str ... where cmd can be:

  • tc for StringService.TitleCase(...)
  • rw for StringService.RemoveWhitespace(...)
  • c for StringService.Count(...)

and str can be any string that will be argument of command.

Flags are:

  • -http-addr HTTP address (default :8080)
  • -grpc-addr gRPC address (default :8081)