blob: ba8be7165d581bf9ff11b91787b985eb121795a5 [file] [log] [blame]
Serge Bazanski3fd70d82018-10-14 08:12:46 -07001Mirko, the HSWAW microservice helper library
2============================================
3
4Wanna write a Go microservice for HSWAW? Can't be arsed to copy paste code? This is the library for you!
5
6Usage (dev)
7-----------
8
9 package main
10
11 import (
Serge Bazanskic981e572018-10-25 12:12:35 +010012 "code.hackerspace.pl/hscloud/go/mirko"
Serge Bazanski3fd70d82018-10-14 08:12:46 -070013 )
14
15 func main() {
16 m := mirko.New()
17
18 // setup/checks before TCP ports are opened...
19 // ...
20
21 if err := m.Listen(); err != nil {
22 glog.Exitf("Listen(): %v", err)
23 }
24
25 // register your gRPC and http handlers...
26 // (relfection and basic debug http is automatically registered)
27 // pb.RegisterFooServer(m.GRPC(), s)
28 // m.HTTPMux().HandleFunc("/debug/foo", fooHandler)
29
30 if err := m.Serve(); err != nil {
31 glog.Exitf("Serve(): %v", err)
32 }
33
34 // start any other background processing...
Serge Bazanski4f7ee512018-10-14 18:20:59 +010035 // (you can use m.Context() to get a context that will get
36 // canceled when the service is about to shut down)
Serge Bazanski3fd70d82018-10-14 08:12:46 -070037
Serge Bazanski4f7ee512018-10-14 18:20:59 +010038 <-m.Done()
Serge Bazanski3fd70d82018-10-14 08:12:46 -070039 }
40
41Usage (running)
42---------------
43
44The following flags are automatically registered:
45
Serge Bazanski2a6175c2018-10-14 08:49:28 -070046 - `-listen_address` (default: `127.0.0.1:4200`): where to listen for gRPC requests
47 - `-debug_address` (default: `127.0.0.1:4201`): where to listen for debug HTTP requests
Serge Bazanski446c9e12018-10-14 17:06:09 +010048 - `-debug_allow_all` (default: false): whether to allow all IP address (vs. localhost) to connect to debug endpoint
Serge Bazanski3fd70d82018-10-14 08:12:46 -070049
Serge Bazanski3fd70d82018-10-14 08:12:46 -070050The following debug HTTP handlers are installed:
51
52 - `/debug/status`: show the [statusz](https://github.com/q3k/statusz) page
53 - `/debug/requests`: show the [net/trace](https://godoc.org/golang.org/x/net/trace) page (including gRPC traces)
54