1
0
Fork 0
hscloud/go/mirko/README

55 lines
1.6 KiB
Plaintext
Raw Normal View History

2018-10-14 15:12:46 +00:00
Mirko, the HSWAW microservice helper library
============================================
Wanna write a Go microservice for HSWAW? Can't be arsed to copy paste code? This is the library for you!
Usage (dev)
-----------
package main
import (
2018-10-25 11:12:35 +00:00
"code.hackerspace.pl/hscloud/go/mirko"
2018-10-14 15:12:46 +00:00
)
func main() {
m := mirko.New()
// setup/checks before TCP ports are opened...
// ...
if err := m.Listen(); err != nil {
glog.Exitf("Listen(): %v", err)
}
// register your gRPC and http handlers...
// (relfection and basic debug http is automatically registered)
// pb.RegisterFooServer(m.GRPC(), s)
// m.HTTPMux().HandleFunc("/debug/foo", fooHandler)
if err := m.Serve(); err != nil {
glog.Exitf("Serve(): %v", err)
}
// start any other background processing...
2018-10-14 17:20:59 +00:00
// (you can use m.Context() to get a context that will get
// canceled when the service is about to shut down)
2018-10-14 15:12:46 +00:00
2018-10-14 17:20:59 +00:00
<-m.Done()
2018-10-14 15:12:46 +00:00
}
Usage (running)
---------------
The following flags are automatically registered:
2018-10-14 15:49:28 +00:00
- `-listen_address` (default: `127.0.0.1:4200`): where to listen for gRPC requests
- `-debug_address` (default: `127.0.0.1:4201`): where to listen for debug HTTP requests
2018-10-14 16:06:09 +00:00
- `-debug_allow_all` (default: false): whether to allow all IP address (vs. localhost) to connect to debug endpoint
2018-10-14 15:12:46 +00:00
The following debug HTTP handlers are installed:
2018-10-25 21:37:37 +00:00
- `/debug/status`: show the statusz page
2018-10-14 15:12:46 +00:00
- `/debug/requests`: show the [net/trace](https://godoc.org/golang.org/x/net/trace) page (including gRPC traces)