veyron2: merge Runtime interfaces into veyron2.Runtime
Move all of the Runtime interfaces from veyron2/subdirectories into
veyron2/model.go to bring all of the documentation into one place
and see if this simplifies the overall code structure. This also
made it easy to get rid of the mgmt subdirectories in veyron2 and
the associated runtime.
Change-Id: I95f9fe4b2c72c737c7255b08ce1cfe1cbbace8a7
Change-Id: I602d4436f2c9690963d60bfce303465ebb36f64a
diff --git a/examples/boxes/boxes.idl.go b/examples/boxes/boxes.idl.go
index 8de494c..a5c20aa 100644
--- a/examples/boxes/boxes.idl.go
+++ b/examples/boxes/boxes.idl.go
@@ -7,6 +7,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -67,7 +68,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
@@ -328,7 +329,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/examples/fortune/fortune.idl.go b/examples/fortune/fortune.idl.go
index 1def498..cd7a418 100644
--- a/examples/fortune/fortune.idl.go
+++ b/examples/fortune/fortune.idl.go
@@ -7,6 +7,7 @@
"veyron2/security"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -58,7 +59,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/examples/inspector/inspector.idl.go b/examples/inspector/inspector.idl.go
index 875d5e1..fc46e79 100644
--- a/examples/inspector/inspector.idl.go
+++ b/examples/inspector/inspector.idl.go
@@ -5,6 +5,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -169,7 +170,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/examples/runtime/runtime_test.go b/examples/runtime/runtime_test.go
index 0b172d6..ebb19ba 100644
--- a/examples/runtime/runtime_test.go
+++ b/examples/runtime/runtime_test.go
@@ -9,7 +9,8 @@
"veyron/lib/signals"
_ "veyron/lib/testutil"
"veyron/lib/testutil/blackbox"
- "veyron2/mgmt"
+
+ "veyron2"
)
// TestHelperProcess is boilerplate for the blackbox setup.
@@ -51,7 +52,7 @@
c.Cmd.Start()
c.Expect("Ready")
c.WriteLine("stop")
- c.Expect(fmt.Sprintf("Received signal %s", mgmt.LocalStop))
+ c.Expect(fmt.Sprintf("Received signal %s", veyron2.LocalStop))
c.Expect("Interruptible cleanup")
c.Expect("Deferred cleanup")
c.WriteLine("close")
@@ -82,7 +83,7 @@
c.Expect("Ready")
c.WriteLine("forcestop")
c.Expect("straight exit")
- c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", mgmt.ForceStopExitCode))
+ c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", veyron2.ForceStopExitCode))
}
// TestSimpleServerKill demonstrates that a SIGKILL still forces the server
@@ -140,7 +141,7 @@
c.Cmd.Start()
c.Expect("Ready")
c.WriteLine("stop")
- c.Expect(fmt.Sprintf("Stop %s", mgmt.LocalStop))
+ c.Expect(fmt.Sprintf("Stop %s", veyron2.LocalStop))
c.ExpectSet([]string{
"Sequential blocking cleanup",
"Sequential interruptible cleanup",
@@ -185,7 +186,7 @@
c.Expect("Ready")
c.WriteLine("forcestop")
c.Expect("straight exit")
- c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", mgmt.ForceStopExitCode))
+ c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", veyron2.ForceStopExitCode))
}
// TestComplexServerKill demonstrates that a SIGKILL still forces the server to
diff --git a/examples/tunnel/tunnel.idl.go b/examples/tunnel/tunnel.idl.go
index 14c039c..20348eb 100644
--- a/examples/tunnel/tunnel.idl.go
+++ b/examples/tunnel/tunnel.idl.go
@@ -7,6 +7,7 @@
"veyron2/security"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -253,7 +254,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/examples/wspr_sample/cache.idl.go b/examples/wspr_sample/cache.idl.go
index c95b559..a08cdab 100644
--- a/examples/wspr_sample/cache.idl.go
+++ b/examples/wspr_sample/cache.idl.go
@@ -5,6 +5,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -247,7 +248,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/examples/wspr_sample/error_thrower.idl.go b/examples/wspr_sample/error_thrower.idl.go
index 77aad7d..c1b7490 100644
--- a/examples/wspr_sample/error_thrower.idl.go
+++ b/examples/wspr_sample/error_thrower.idl.go
@@ -5,6 +5,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -104,7 +105,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/lib/signals/signals_test.go b/lib/signals/signals_test.go
index 03a480c..d0a6b85 100644
--- a/lib/signals/signals_test.go
+++ b/lib/signals/signals_test.go
@@ -6,7 +6,7 @@
"syscall"
"testing"
- "veyron2/mgmt"
+ "veyron2"
"veyron2/rt"
_ "veyron/lib/testutil"
@@ -106,7 +106,7 @@
c.Cmd.Start()
c.Expect("ready")
c.WriteLine("stop")
- c.Expect(fmt.Sprintf("received signal %s", mgmt.LocalStop))
+ c.Expect(fmt.Sprintf("received signal %s", veyron2.LocalStop))
c.WriteLine("close")
c.ExpectEOFAndWait()
}
@@ -119,7 +119,7 @@
c.Cmd.Start()
c.Expect("ready")
c.WriteLine("stop")
- c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", mgmt.UnhandledStopExitCode))
+ c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", veyron2.UnhandledStopExitCode))
}
// TestDoubleSignal verifies that sending a succession of two signals to a child
@@ -162,7 +162,7 @@
c.Cmd.Start()
c.Expect("ready")
c.WriteLine("stop")
- c.Expect(fmt.Sprintf("received signal %s", mgmt.LocalStop))
+ c.Expect(fmt.Sprintf("received signal %s", veyron2.LocalStop))
c.WriteLine("stop")
c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", DoubleStopExitCode))
}
diff --git a/runtimes/google/mgmt/mgmt.go b/runtimes/google/mgmt/mgmt.go
deleted file mode 100644
index b509883..0000000
--- a/runtimes/google/mgmt/mgmt.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package mgmt
-
-import (
- "os"
- "sync"
-
- "veyron2/mgmt"
-)
-
-type impl struct {
- sync.RWMutex
- waiters []chan<- string
-}
-
-// New returns a new instance of the mgmt runtime implementation.
-func New() mgmt.Runtime {
- return new(impl)
-}
-
-// Stop implements mgmt.Runtime.
-func (m *impl) Stop() {
- m.RLock()
- defer m.RUnlock()
- if len(m.waiters) == 0 {
- os.Exit(mgmt.UnhandledStopExitCode)
- }
- for _, w := range m.waiters {
- select {
- case w <- mgmt.LocalStop:
- default:
- }
- }
-}
-
-// ForceStop implements mgmt.Runtime.
-func (*impl) ForceStop() {
- os.Exit(mgmt.ForceStopExitCode)
-}
-
-// WaitForStop implements mgmt.Runtime.
-func (m *impl) WaitForStop(ch chan<- string) {
- m.Lock()
- defer m.Unlock()
- m.waiters = append(m.waiters, ch)
-}
diff --git a/runtimes/google/rt/example_test.go b/runtimes/google/rt/example_test.go
index 6d92662..dd04ef0 100644
--- a/runtimes/google/rt/example_test.go
+++ b/runtimes/google/rt/example_test.go
@@ -5,6 +5,7 @@
"net"
"veyron/runtimes/google/rt"
+
"veyron2"
"veyron2/security"
)
diff --git a/runtimes/google/rt/mgmt.go b/runtimes/google/rt/mgmt.go
index f3af0a3..9b4757f 100644
--- a/runtimes/google/rt/mgmt.go
+++ b/runtimes/google/rt/mgmt.go
@@ -1,9 +1,37 @@
package rt
import (
- "veyron/runtimes/google/mgmt"
+ "os"
+ "sync"
+
+ "veyron2"
)
-func (rt *vrt) initMgmt() {
- rt.mgmtRT = mgmt.New()
+type mgmtImpl struct {
+ sync.RWMutex
+ waiters []chan<- string
+}
+
+func (rt *vrt) Stop() {
+ rt.mgmt.RLock()
+ defer rt.mgmt.RUnlock()
+ if len(rt.mgmt.waiters) == 0 {
+ os.Exit(veyron2.UnhandledStopExitCode)
+ }
+ for _, w := range rt.mgmt.waiters {
+ select {
+ case w <- veyron2.LocalStop:
+ default:
+ }
+ }
+}
+
+func (*vrt) ForceStop() {
+ os.Exit(veyron2.ForceStopExitCode)
+}
+
+func (rt *vrt) WaitForStop(ch chan<- string) {
+ rt.mgmt.Lock()
+ defer rt.mgmt.Unlock()
+ rt.mgmt.waiters = append(rt.mgmt.waiters, ch)
}
diff --git a/runtimes/google/mgmt/mgmt_test.go b/runtimes/google/rt/mgmt_test.go
similarity index 79%
rename from runtimes/google/mgmt/mgmt_test.go
rename to runtimes/google/rt/mgmt_test.go
index eb43393a..91817f5 100644
--- a/runtimes/google/mgmt/mgmt_test.go
+++ b/runtimes/google/rt/mgmt_test.go
@@ -1,30 +1,26 @@
-package mgmt
+package rt_test
import (
"fmt"
"os"
"testing"
- "veyron2/mgmt"
+ "veyron2"
_ "veyron/lib/testutil"
"veyron/lib/testutil/blackbox"
+ "veyron/runtimes/google/rt"
)
-// TestHelperProcess is boilerplate for the blackbox setup.
-func TestHelperProcess(t *testing.T) {
- blackbox.HelperProcess(t)
-}
-
// TestBasic verifies that the basic plumbing works: LocalStop calls result in
// stop messages being sent on the channel passed to WaitForStop.
func TestBasic(t *testing.T) {
- m := New()
+ m, _ := rt.New()
ch := make(chan string, 1)
m.WaitForStop(ch)
for i := 0; i < 10; i++ {
m.Stop()
- if want, got := mgmt.LocalStop, <-ch; want != got {
+ if want, got := veyron2.LocalStop, <-ch; want != got {
t.Errorf("WaitForStop want %q got %q", want, got)
}
select {
@@ -38,17 +34,17 @@
// TestMultipleWaiters verifies that the plumbing works with more than one
// registered wait channel.
func TestMultipleWaiters(t *testing.T) {
- m := New()
+ m, _ := rt.New()
ch1 := make(chan string, 1)
m.WaitForStop(ch1)
ch2 := make(chan string, 1)
m.WaitForStop(ch2)
for i := 0; i < 10; i++ {
m.Stop()
- if want, got := mgmt.LocalStop, <-ch1; want != got {
+ if want, got := veyron2.LocalStop, <-ch1; want != got {
t.Errorf("WaitForStop want %q got %q", want, got)
}
- if want, got := mgmt.LocalStop, <-ch2; want != got {
+ if want, got := veyron2.LocalStop, <-ch2; want != got {
t.Errorf("WaitForStop want %q got %q", want, got)
}
}
@@ -58,13 +54,13 @@
// channel is not being drained: once the channel's buffer fills up, future
// Stops become no-ops.
func TestMultipleStops(t *testing.T) {
- m := New()
+ m, _ := rt.New()
ch := make(chan string, 1)
m.WaitForStop(ch)
for i := 0; i < 10; i++ {
m.Stop()
}
- if want, got := mgmt.LocalStop, <-ch; want != got {
+ if want, got := veyron2.LocalStop, <-ch; want != got {
t.Errorf("WaitForStop want %q got %q", want, got)
}
select {
@@ -79,7 +75,7 @@
}
func noWaiters([]string) {
- m := New()
+ m, _ := rt.New()
fmt.Println("ready")
blackbox.WaitForEOFOnStdin()
m.Stop()
@@ -94,7 +90,7 @@
c.Cmd.Start()
c.Expect("ready")
c.CloseStdin()
- c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", mgmt.UnhandledStopExitCode))
+ c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", veyron2.UnhandledStopExitCode))
}
func init() {
@@ -102,7 +98,7 @@
}
func forceStop([]string) {
- m := New()
+ m, _ := rt.New()
fmt.Println("ready")
blackbox.WaitForEOFOnStdin()
m.WaitForStop(make(chan string, 1))
@@ -118,5 +114,5 @@
c.Cmd.Start()
c.Expect("ready")
c.CloseStdin()
- c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", mgmt.ForceStopExitCode))
+ c.ExpectEOFAndWaitForExitCode(fmt.Errorf("exit status %d", veyron2.ForceStopExitCode))
}
diff --git a/runtimes/google/rt/rt.go b/runtimes/google/rt/rt.go
index ec71daf..9960cbf 100644
--- a/runtimes/google/rt/rt.go
+++ b/runtimes/google/rt/rt.go
@@ -9,7 +9,6 @@
"veyron2"
"veyron2/ipc"
"veyron2/ipc/stream"
- "veyron2/mgmt"
"veyron2/naming"
"veyron2/product"
"veyron2/vlog"
@@ -17,10 +16,7 @@
imounttable "veyron/runtimes/google/naming/mounttable"
)
-type mgmtRT mgmt.Runtime
-
type vrt struct {
- mgmtRT
product product.T
sm stream.Manager
mt naming.MountTable
@@ -28,6 +24,7 @@
signals chan os.Signal
id veyron2.LocalIDOpt
client ipc.Client
+ mgmt *mgmtImpl
}
var (
@@ -38,7 +35,7 @@
// Implements veyron2/rt.New
func New(opts ...veyron2.ROpt) (veyron2.Runtime, error) {
- r := &vrt{}
+ r := &vrt{mgmt: new(mgmtImpl)}
return r, r.init(opts...)
}
@@ -119,8 +116,6 @@
return err
}
- rt.initMgmt()
-
if len(debug) > 0 {
rt.startHTTPDebugServer(debug, rt.sm)
}
diff --git a/runtimes/google/vsync/vsync.idl.go b/runtimes/google/vsync/vsync.idl.go
index 932a904..3a199e9 100644
--- a/runtimes/google/vsync/vsync.idl.go
+++ b/runtimes/google/vsync/vsync.idl.go
@@ -9,6 +9,7 @@
"veyron2/storage"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -161,7 +162,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/services/mgmt/application/application.idl.go b/services/mgmt/application/application.idl.go
index ffec1e0..175ae10 100644
--- a/services/mgmt/application/application.idl.go
+++ b/services/mgmt/application/application.idl.go
@@ -11,6 +11,7 @@
"veyron2/services/mgmt/application"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -82,7 +83,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/services/mgmt/profile/profile.idl.go b/services/mgmt/profile/profile.idl.go
index dceaade..22631f0 100644
--- a/services/mgmt/profile/profile.idl.go
+++ b/services/mgmt/profile/profile.idl.go
@@ -9,6 +9,7 @@
"veyron2/services/mgmt/profile"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -111,7 +112,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/services/mgmt/root/root.idl.go b/services/mgmt/root/root.idl.go
index 040a905..c48b85a 100644
--- a/services/mgmt/root/root.idl.go
+++ b/services/mgmt/root/root.idl.go
@@ -7,6 +7,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -55,7 +56,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/services/mounttable/lib/collection_test.idl.go b/services/mounttable/lib/collection_test.idl.go
index c7efbf1..d18251c 100644
--- a/services/mounttable/lib/collection_test.idl.go
+++ b/services/mounttable/lib/collection_test.idl.go
@@ -5,6 +5,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -63,7 +64,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/services/store/estore/service.idl.go b/services/store/estore/service.idl.go
index 5c50b58..9c832c3 100644
--- a/services/store/estore/service.idl.go
+++ b/services/store/estore/service.idl.go
@@ -14,6 +14,7 @@
"veyron2/storage"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -86,7 +87,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
diff --git a/tools/vrpc/test_base/test_base.idl.go b/tools/vrpc/test_base/test_base.idl.go
index 499c359..c627aab 100644
--- a/tools/vrpc/test_base/test_base.idl.go
+++ b/tools/vrpc/test_base/test_base.idl.go
@@ -5,6 +5,7 @@
import (
// The non-user imports are prefixed with "_gen_" to prevent collisions.
+ _gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
@@ -190,7 +191,7 @@
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
- case _gen_ipc.Runtime:
+ case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o