go: add bazel buildfiles, implement leasifier
diff --git a/go/mirko/mirko.go b/go/mirko/mirko.go
index 2e62c3d..01766db 100644
--- a/go/mirko/mirko.go
+++ b/go/mirko/mirko.go
@@ -38,17 +38,15 @@
httpServer *http.Server
httpMux *http.ServeMux
- ctx context.Context
- cancel context.CancelFunc
- waiters []chan bool
+ ctx context.Context
+ cancel context.CancelFunc
}
func New() *Mirko {
ctx, cancel := context.WithCancel(context.Background())
return &Mirko{
- ctx: ctx,
- cancel: cancel,
- waiters: []chan bool{},
+ ctx: ctx,
+ cancel: cancel,
}
}
@@ -161,10 +159,8 @@
// Done() returns a channel that will emit a value when the service is
// shut down. This should be used in the main() function instead of a select{}
// call, to allow the background context to be canceled fully.
-func (m *Mirko) Done() chan bool {
- c := make(chan bool, 1)
- m.waiters = append(m.waiters, c)
- return c
+func (m *Mirko) Done() <-chan struct{} {
+ return m.Context().Done()
}
// Serve starts serving HTTP and gRPC requests
@@ -187,10 +183,6 @@
select {
case <-signalCh:
m.cancel()
- time.Sleep(time.Second)
- for _, w := range m.waiters {
- w <- true
- }
}
}()