Skip to content

radekwlsk/go-kit-svc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

$ go run main.go

Now HTTP requests can be made:

$ curl -XPOST -d'{"s":"hello, world!"}' localhost:8080/tc
{"v":"Hello, World!"}
$ curl -XPOST -d'{"s":"hello, world!"}' localhost:8080/rw
{"v":"hello,world!"}
$ curl -XPOST -d'{"s":"hello, world!"}' localhost:8080/c
{"v":13}

Or gRPC client can be run:

$ go run cmd/client.go -http-addr="localhost:8080" tc "hello, world!" rw "hello,   world!" c "hello, world!"
Hello, World!
hello,world!
13

$ go run cmd/client.go -grpc-addr="8081" tc "hello, world!" rw "hello,   world!" c "hello, world!"
Hello, World!
hello,world!
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)