veyron2: Separate out options into a separate package.
A couple of "cleanups" here:
(1) All common options are moved to a separate package.
This clears up the godoc of the "veyron2" entrypoint package
(2) Apply consistent naming (no "Opt" suffices) and get rid of
helper functions. Now, there is only one exported type per
option (instead of one type and one helper function) at the
cost of possibly inconsistent syntax:
options.RemoteID("foo") vs. options.LocalID{localid}
Change-Id: Ie589a7451c29ca999530680d585f0d6a2a88359e
diff --git a/lib/modules/core/mounttable.go b/lib/modules/core/mounttable.go
index f1ff8fa..8ec1bd0 100644
--- a/lib/modules/core/mounttable.go
+++ b/lib/modules/core/mounttable.go
@@ -6,9 +6,9 @@
"os"
"strings"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron/lib/modules"
@@ -41,7 +41,7 @@
func runMT(root bool, stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
r := rt.Init()
- server, err := r.NewServer(veyron2.ServesMountTableOpt(true))
+ server, err := r.NewServer(options.ServesMountTable(true))
if err != nil {
return fmt.Errorf("root failed: %v", err)
}
diff --git a/lib/signals/signals_test.go b/lib/signals/signals_test.go
index 634e1d2..5d9f6a6 100644
--- a/lib/signals/signals_test.go
+++ b/lib/signals/signals_test.go
@@ -15,6 +15,7 @@
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/mgmt"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/services/mgmt/appcycle"
@@ -324,7 +325,7 @@
// TestCleanRemoteShutdown verifies that remote shutdown works correctly.
func TestCleanRemoteShutdown(t *testing.T) {
- r := rt.Init(veyron2.ForceNewSecurityModel{})
+ r := rt.Init(options.ForceNewSecurityModel{})
defer r.Cleanup()
sh := modules.NewShell()
diff --git a/lib/testutil/modules/mounttable.go b/lib/testutil/modules/mounttable.go
index 77ae0ac..e4ace22 100644
--- a/lib/testutil/modules/mounttable.go
+++ b/lib/testutil/modules/mounttable.go
@@ -7,8 +7,8 @@
"strconv"
"strings"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/vlog"
@@ -88,7 +88,7 @@
func serveMountTable(root bool, args []string) {
rt.Init()
fmt.Println("ready")
- server, err := rt.R().NewServer(veyron2.ServesMountTableOpt(true))
+ server, err := rt.R().NewServer(options.ServesMountTable(true))
if err != nil {
bbExitWithError(fmt.Sprintf("root failed: %v", err))
}
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index f75ee6a..5782fe8 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -14,11 +14,11 @@
isecurity "veyron.io/veyron/veyron/runtimes/google/security"
"veyron.io/veyron/veyron/runtimes/google/vtrace"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/verror"
"veyron.io/veyron/veyron2/vlog"
@@ -162,7 +162,7 @@
func getRetryTimeoutOpt(opts []ipc.CallOpt) (time.Duration, bool) {
for _, o := range opts {
- if r, ok := o.(veyron2.RetryTimeoutOpt); ok {
+ if r, ok := o.(options.RetryTimeout); ok {
return time.Duration(r), true
}
}
@@ -202,7 +202,7 @@
func getNoResolveOpt(opts []ipc.CallOpt) bool {
for _, o := range opts {
- if r, ok := o.(veyron2.NoResolveOpt); ok {
+ if r, ok := o.(options.NoResolve); ok {
return bool(r)
}
}
@@ -319,7 +319,7 @@
}
for _, o := range opts {
switch v := o.(type) {
- case veyron2.RemoteID:
+ case options.RemoteID:
if !security.BlessingPattern(v).MatchedBy(serverBlessings...) {
return nil, nil, fmt.Errorf("server %v does not match the provided pattern %q", serverBlessings, v)
}
diff --git a/runtimes/google/ipc/debug_test.go b/runtimes/google/ipc/debug_test.go
index 11968e0..b395f0f 100644
--- a/runtimes/google/ipc/debug_test.go
+++ b/runtimes/google/ipc/debug_test.go
@@ -5,9 +5,9 @@
"sort"
"testing"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/services/mounttable/types"
"veyron.io/veyron/veyron/lib/stats"
@@ -68,7 +68,7 @@
foo := stats.NewString("testing/foo")
foo.Set("The quick brown fox jumps over the lazy dog")
addr := naming.JoinAddressName(ep.String(), "__debug/stats/testing/foo")
- call, err := client.StartCall(ctx, addr, "Value", nil, veyron2.NoResolveOpt(true))
+ call, err := client.StartCall(ctx, addr, "Value", nil, options.NoResolve(true))
if err != nil {
t.Fatalf("client.StartCall failed: %v", err)
}
diff --git a/runtimes/google/ipc/discharges.go b/runtimes/google/ipc/discharges.go
index d88c31c..c261bda 100644
--- a/runtimes/google/ipc/discharges.go
+++ b/runtimes/google/ipc/discharges.go
@@ -3,9 +3,9 @@
import (
"sync"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/ipc"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vdl/vdlutil"
"veyron.io/veyron/veyron2/vlog"
@@ -99,10 +99,9 @@
// dischargesFromOpts fills in the nils in the out argument with discharges in
// opts that match the caveat at the same index in caveats.
// REQUIRES: len(caveats) == len(out)
-func dischargesFromOpts(caveats []security.ThirdPartyCaveat, opts []ipc.CallOpt,
- out []security.Discharge) {
+func dischargesFromOpts(caveats []security.ThirdPartyCaveat, opts []ipc.CallOpt, out []security.Discharge) {
for _, opt := range opts {
- d, ok := opt.(veyron2.DischargeOpt)
+ d, ok := opt.(options.Discharge)
if !ok {
continue
}
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 4e4a5bf..fb66f19 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -23,10 +23,10 @@
tnaming "veyron.io/veyron/veyron/runtimes/google/testing/mocks/naming"
vsecurity "veyron.io/veyron/veyron/security"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vdl/vdlutil"
"veyron.io/veyron/veyron2/verror"
@@ -358,7 +358,7 @@
t.Errorf("%s: failed ot create client: %v", name, err)
continue
}
- if call, err := client.StartCall(testContext(), "mountpoint/server/suffix", "Method", nil, veyron2.RemoteID(test.pattern)); !matchesErrorPattern(err, test.err) {
+ if call, err := client.StartCall(testContext(), "mountpoint/server/suffix", "Method", nil, options.RemoteID(test.pattern)); !matchesErrorPattern(err, test.err) {
t.Errorf(`%s: client.StartCall: got error "%v", want to match "%v"`, name, err, test.err)
} else if call != nil {
blessings, proof := call.RemoteBlessings()
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 608424f..3578abe 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -26,6 +26,7 @@
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
mttypes "veyron.io/veyron/veyron2/services/mounttable/types"
"veyron.io/veyron/veyron2/verror"
@@ -87,10 +88,10 @@
case stream.ListenerOpt:
// Collect all ServerOpts that are also ListenerOpts.
s.listenerOpts = append(s.listenerOpts, opt)
- case veyron2.ServesMountTableOpt:
+ case options.ServesMountTable:
s.servesMountTable = bool(opt)
- case veyron2.DebugAuthorizerOpt:
- s.debugAuthorizer = security.Authorizer(opt)
+ case options.DebugAuthorizer:
+ s.debugAuthorizer = opt.Authorizer
}
}
s.debugDisp = debug.NewDispatcher(vlog.Log.LogDir(), s.debugAuthorizer)
@@ -152,7 +153,7 @@
return nil, err
}
}
- // TODO(cnicolaou): pass ServesMountTableOpt to streamMgr.Listen so that
+ // TODO(cnicolaou): pass options.ServesMountTable to streamMgr.Listen so that
// it can more cleanly set the IsMountTable bit in the endpoint.
ln, ep, err := s.streamMgr.Listen(protocol, address, s.listenerOpts...)
if err != nil {
diff --git a/runtimes/google/ipc/stream/benchmark/throughput_flow.go b/runtimes/google/ipc/stream/benchmark/throughput_flow.go
index ff69e6f..321f313 100644
--- a/runtimes/google/ipc/stream/benchmark/throughput_flow.go
+++ b/runtimes/google/ipc/stream/benchmark/throughput_flow.go
@@ -5,15 +5,15 @@
"testing"
"veyron.io/veyron/veyron/runtimes/google/ipc/stream/manager"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
)
const (
// Shorthands
- securityNone = veyron2.VCSecurityNone
- securityTLS = veyron2.VCSecurityConfidential
+ securityNone = options.VCSecurityNone
+ securityTLS = options.VCSecurityConfidential
)
type listener struct {
@@ -24,7 +24,7 @@
// createListeners returns N (stream.Listener, naming.Endpoint) pairs, such
// that calling stream.Manager.Dial to each of the endpoints will end up
// creating a new VIF.
-func createListeners(mode veyron2.VCSecurityLevel, m stream.Manager, N int) (servers []listener, err error) {
+func createListeners(mode options.VCSecurityLevel, m stream.Manager, N int) (servers []listener, err error) {
for i := 0; i < N; i++ {
var l listener
if l.ln, l.ep, err = m.Listen("tcp", "127.0.0.1:0", mode); err != nil {
@@ -35,7 +35,7 @@
return
}
-func benchmarkFlow(b *testing.B, mode veyron2.VCSecurityLevel, nVIFs, nVCsPerVIF, nFlowsPerVC int) {
+func benchmarkFlow(b *testing.B, mode options.VCSecurityLevel, nVIFs, nVCsPerVIF, nFlowsPerVC int) {
client := manager.InternalNew(naming.FixedRoutingID(0xcccccccc))
server := manager.InternalNew(naming.FixedRoutingID(0x55555555))
diff --git a/runtimes/google/ipc/stream/vc/vc.go b/runtimes/google/ipc/stream/vc/vc.go
index 0093009..d7b79ca 100644
--- a/runtimes/google/ipc/stream/vc/vc.go
+++ b/runtimes/google/ipc/stream/vc/vc.go
@@ -17,10 +17,10 @@
"veyron.io/veyron/veyron/runtimes/google/lib/iobuf"
vsync "veyron.io/veyron/veyron/runtimes/google/lib/sync"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/ipc/version"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vlog"
)
@@ -382,28 +382,28 @@
var localID LocalID
var principal security.Principal
var tlsSessionCache crypto.TLSClientSessionCache
- var securityLevel veyron2.VCSecurityLevel
+ var securityLevel options.VCSecurityLevel
for _, o := range opts {
switch v := o.(type) {
case LocalID:
localID = v
case LocalPrincipal:
principal = v.Principal
- case veyron2.VCSecurityLevel:
+ case options.VCSecurityLevel:
securityLevel = v
case crypto.TLSClientSessionCache:
tlsSessionCache = v
}
}
switch securityLevel {
- case veyron2.VCSecurityConfidential:
+ case options.VCSecurityConfidential:
if localID == nil {
localID = FixedLocalID(anonymousID)
}
if principal == nil {
principal = anonymousPrincipal
}
- case veyron2.VCSecurityNone:
+ case options.VCSecurityNone:
return nil
default:
return fmt.Errorf("unrecognized VC security level: %v", securityLevel)
@@ -491,14 +491,14 @@
}
var localID LocalID
var principal security.Principal
- var securityLevel veyron2.VCSecurityLevel
+ var securityLevel options.VCSecurityLevel
for _, o := range opts {
switch v := o.(type) {
case LocalID:
localID = v
case LocalPrincipal:
principal = v.Principal
- case veyron2.VCSecurityLevel:
+ case options.VCSecurityLevel:
securityLevel = v
}
}
@@ -511,14 +511,14 @@
}
vc.helper.AddReceiveBuffers(vc.VCI(), SharedFlowID, DefaultBytesBufferedPerFlow)
switch securityLevel {
- case veyron2.VCSecurityConfidential:
+ case options.VCSecurityConfidential:
if localID == nil {
localID = FixedLocalID(anonymousID)
}
if principal == nil {
principal = anonymousPrincipal
}
- case veyron2.VCSecurityNone:
+ case options.VCSecurityNone:
return finish(ln, nil)
default:
ln.Close()
diff --git a/runtimes/google/ipc/stream/vc/vc_test.go b/runtimes/google/ipc/stream/vc/vc_test.go
index c469fe6..a9c4ae4 100644
--- a/runtimes/google/ipc/stream/vc/vc_test.go
+++ b/runtimes/google/ipc/stream/vc/vc_test.go
@@ -21,10 +21,10 @@
"veyron.io/veyron/veyron/runtimes/google/lib/bqueue/drrqueue"
"veyron.io/veyron/veyron/runtimes/google/lib/iobuf"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/ipc/version"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
)
@@ -32,8 +32,8 @@
// Convenience alias to avoid conflicts between the package name "vc" and variables called "vc".
DefaultBytesBufferedPerFlow = vc.DefaultBytesBufferedPerFlow
// Shorthands
- SecurityNone = veyron2.VCSecurityNone
- SecurityTLS = veyron2.VCSecurityConfidential
+ SecurityNone = options.VCSecurityNone
+ SecurityTLS = options.VCSecurityConfidential
LatestVersion = version.IPCVersion4
)
@@ -157,7 +157,7 @@
}
}
-func testConnect_Small(t *testing.T, security veyron2.VCSecurityLevel) {
+func testConnect_Small(t *testing.T, security options.VCSecurityLevel) {
h, vc := New(security, LatestVersion, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
defer h.Close()
flow, err := vc.Connect()
@@ -169,7 +169,7 @@
func TestConnect_Small(t *testing.T) { testConnect_Small(t, SecurityNone) }
func TestConnect_SmallTLS(t *testing.T) { testConnect_Small(t, SecurityTLS) }
-func testConnect(t *testing.T, security veyron2.VCSecurityLevel) {
+func testConnect(t *testing.T, security options.VCSecurityLevel) {
h, vc := New(security, LatestVersion, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
defer h.Close()
flow, err := vc.Connect()
@@ -181,7 +181,7 @@
func TestConnect(t *testing.T) { testConnect(t, SecurityNone) }
func TestConnectTLS(t *testing.T) { testConnect(t, SecurityTLS) }
-func testConnect_Version3(t *testing.T, security veyron2.VCSecurityLevel) {
+func testConnect_Version3(t *testing.T, security options.VCSecurityLevel) {
h, vc := New(security, version.IPCVersion3, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
defer h.Close()
flow, err := vc.Connect()
@@ -196,7 +196,7 @@
// helper function for testing concurrent operations on multiple flows over the
// same VC. Such tests are most useful when running the race detector.
// (go test -race ...)
-func testConcurrentFlows(t *testing.T, security veyron2.VCSecurityLevel, flows, gomaxprocs int) {
+func testConcurrentFlows(t *testing.T, security options.VCSecurityLevel, flows, gomaxprocs int) {
mp := runtime.GOMAXPROCS(gomaxprocs)
defer runtime.GOMAXPROCS(mp)
h, vc := New(security, LatestVersion, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
@@ -224,7 +224,7 @@
func TestConcurrentFlows_10(t *testing.T) { testConcurrentFlows(t, SecurityNone, 10, 10) }
func TestConcurrentFlows_10TLS(t *testing.T) { testConcurrentFlows(t, SecurityTLS, 10, 10) }
-func testListen(t *testing.T, security veyron2.VCSecurityLevel) {
+func testListen(t *testing.T, security options.VCSecurityLevel) {
data := "the dark knight"
h, vc := New(security, LatestVersion, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
defer h.Close()
@@ -272,7 +272,7 @@
func TestListen(t *testing.T) { testListen(t, SecurityNone) }
func TestListenTLS(t *testing.T) { testListen(t, SecurityTLS) }
-func testNewFlowAfterClose(t *testing.T, security veyron2.VCSecurityLevel) {
+func testNewFlowAfterClose(t *testing.T, security options.VCSecurityLevel) {
h, _ := New(security, LatestVersion, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
defer h.Close()
h.VC.Close("reason")
@@ -283,7 +283,7 @@
func TestNewFlowAfterClose(t *testing.T) { testNewFlowAfterClose(t, SecurityNone) }
func TestNewFlowAfterCloseTLS(t *testing.T) { testNewFlowAfterClose(t, SecurityTLS) }
-func testConnectAfterClose(t *testing.T, security veyron2.VCSecurityLevel) {
+func testConnectAfterClose(t *testing.T, security options.VCSecurityLevel) {
h, vc := New(security, LatestVersion, sectest.NewPrincipal("client"), sectest.NewPrincipal("server"))
defer h.Close()
h.VC.Close("myerr")
@@ -306,7 +306,7 @@
// New creates both ends of a VC but returns only the "client" end (i.e., the
// one that initiated the VC). The "server" end (the one that "accepted" the VC)
// listens for flows and simply echoes data read.
-func New(security veyron2.VCSecurityLevel, v version.IPCVersion, client, server security.Principal) (*helper, stream.VC) {
+func New(security options.VCSecurityLevel, v version.IPCVersion, client, server security.Principal) (*helper, stream.VC) {
clientH := &helper{bq: drrqueue.New(vc.MaxPayloadSizeBytes)}
serverH := &helper{bq: drrqueue.New(vc.MaxPayloadSizeBytes)}
clientH.otherEnd = serverH
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 5d707c5..a346615 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -15,6 +15,7 @@
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/services/mounttable"
@@ -174,7 +175,7 @@
}
func run(t *testing.T, sr veyron2.Runtime, disp ipc.Dispatcher, mountPoint string, mt bool) *serverEntry {
- s, err := sr.NewServer(veyron2.ServesMountTableOpt(mt))
+ s, err := sr.NewServer(options.ServesMountTable(mt))
if err != nil {
boom(t, "r.NewServer: %s", err)
}
diff --git a/runtimes/google/rt/ipc.go b/runtimes/google/rt/ipc.go
index d7f1a5b..65e1474 100644
--- a/runtimes/google/rt/ipc.go
+++ b/runtimes/google/rt/ipc.go
@@ -10,13 +10,13 @@
iversion "veyron.io/veyron/veyron/runtimes/google/ipc/version"
ivtrace "veyron.io/veyron/veyron/runtimes/google/vtrace"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/i18n"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/ipc/version"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/verror2"
"veyron.io/veyron/veyron2/vtrace"
@@ -93,11 +93,11 @@
var otherOpts []ipc.ClientOpt
for _, opt := range opts {
switch topt := opt.(type) {
- case veyron2.StreamManagerOpt:
+ case options.StreamManager:
sm = topt.Manager
- case veyron2.NamespaceOpt:
+ case options.Namespace:
ns = topt.Namespace
- case veyron2.LocalIDOpt:
+ case options.LocalID:
id = topt.PublicID
default:
otherOpts = append(otherOpts, opt)
@@ -160,9 +160,9 @@
var otherOpts []ipc.ServerOpt
for _, opt := range opts {
switch topt := opt.(type) {
- case veyron2.NamespaceOpt:
+ case options.Namespace:
ns = topt
- case veyron2.LocalIDOpt:
+ case options.LocalID:
id = topt.PublicID
default:
otherOpts = append(otherOpts, opt)
diff --git a/runtimes/google/rt/ipc_test.go b/runtimes/google/rt/ipc_test.go
index 91492a5..1d30796 100644
--- a/runtimes/google/rt/ipc_test.go
+++ b/runtimes/google/rt/ipc_test.go
@@ -7,6 +7,7 @@
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
@@ -22,7 +23,7 @@
}
func newRT() veyron2.Runtime {
- r, err := rt.New(veyron2.ForceNewSecurityModel{})
+ r, err := rt.New(options.ForceNewSecurityModel{})
if err != nil {
panic(err)
}
diff --git a/runtimes/google/rt/mgmt_test.go b/runtimes/google/rt/mgmt_test.go
index 069cbeb..fe9e22c 100644
--- a/runtimes/google/rt/mgmt_test.go
+++ b/runtimes/google/rt/mgmt_test.go
@@ -13,6 +13,7 @@
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/mgmt"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/services/mgmt/appcycle"
"veyron.io/veyron/veyron/lib/expect"
@@ -280,7 +281,7 @@
// refer to the global rt.R() function), but we take care to make sure
// that the "google" runtime we are trying to test in this package is
// the one being used.
- r, _ := rt.New(veyron2.RuntimeOpt{veyron2.GoogleRuntimeName}, veyron2.ForceNewSecurityModel{})
+ r, _ := rt.New(options.GoogleRuntime, options.ForceNewSecurityModel{})
childcreds := security.NewVeyronCredentials(r.Principal(), appCmd)
configServer, configServiceName, ch := createConfigServer(t, r)
diff --git a/runtimes/google/rt/rt.go b/runtimes/google/rt/rt.go
index d33e95e..c321b2c 100644
--- a/runtimes/google/rt/rt.go
+++ b/runtimes/google/rt/rt.go
@@ -14,6 +14,7 @@
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/ipc/stream"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vlog"
@@ -61,23 +62,21 @@
nsRoots := []string{}
for _, o := range opts {
switch v := o.(type) {
- case veyron2.RuntimePrincipal:
+ case options.RuntimePrincipal:
rt.principal = v.Principal
- case veyron2.RuntimeIDOpt:
+ case options.RuntimeID:
rt.id = v.PrivateID
- case veyron2.RuntimePublicIDStoreOpt:
- rt.store = v
- case veyron2.ProfileOpt:
+ case options.Profile:
rt.profile = v.Profile
- case veyron2.NamespaceRoots:
+ case options.NamespaceRoots:
nsRoots = v
- case veyron2.HTTPDebugOpt:
+ case options.HTTPDebug:
rt.debug.addr = string(v)
- case veyron2.RuntimeOpt:
- if v.Name != "google" && v.Name != "" {
- return nil, fmt.Errorf("%q is the wrong name for this runtime", v.Name)
+ case options.RuntimeName:
+ if v != "google" && v != "" {
+ return nil, fmt.Errorf("%q is the wrong name for this runtime", v)
}
- case veyron2.ForceNewSecurityModel:
+ case options.ForceNewSecurityModel:
rt.useNewSecurityModelInIPCClients = true
default:
return nil, fmt.Errorf("option has wrong type %T", o)
diff --git a/runtimes/google/rt/rt_test.go b/runtimes/google/rt/rt_test.go
index 05164f0..fd521d9 100644
--- a/runtimes/google/rt/rt_test.go
+++ b/runtimes/google/rt/rt_test.go
@@ -12,6 +12,7 @@
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vlog"
@@ -167,7 +168,7 @@
t.Fatalf("NewPrincipal() failed: %v", err)
}
- r, err := rt.New(veyron2.RuntimePrincipal{p})
+ r, err := rt.New(options.RuntimePrincipal{p})
if err != nil {
t.Fatalf("rt.New failed: %v", err)
}
diff --git a/runtimes/google/rt/security.go b/runtimes/google/rt/security.go
index d141d3e..a61edc1 100644
--- a/runtimes/google/rt/security.go
+++ b/runtimes/google/rt/security.go
@@ -10,7 +10,7 @@
vsecurity "veyron.io/veyron/veyron/security"
"veyron.io/veyron/veyron/security/agent"
- "veyron.io/veyron/veyron2"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vlog"
)
@@ -184,7 +184,7 @@
}
func (rt *vrt) connectToAgent() (security.PrivateID, error) {
- client, err := rt.NewClient(veyron2.VCSecurityNone)
+ client, err := rt.NewClient(options.VCSecurityNone)
if err != nil {
return nil, err
}
diff --git a/runtimes/google/rt/signal_test.go b/runtimes/google/rt/signal_test.go
index 5c400a9..5aa1b3d 100644
--- a/runtimes/google/rt/signal_test.go
+++ b/runtimes/google/rt/signal_test.go
@@ -9,7 +9,7 @@
"testing"
"time"
- "veyron.io/veyron/veyron2"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron/lib/expect"
@@ -34,7 +34,7 @@
// Make sure that we use "google" runtime implementation in this
// package even though we have to use the public API which supports
// arbitrary runtime implementations.
- rt.Init(veyron2.RuntimeOpt{veyron2.GoogleRuntimeName})
+ rt.Init(options.GoogleRuntime)
simpleEchoProgram(stdin, stdout)
return nil
}
diff --git a/security/agent/agent_test.go b/security/agent/agent_test.go
index d88ead9..9721b38 100644
--- a/security/agent/agent_test.go
+++ b/security/agent/agent_test.go
@@ -9,7 +9,7 @@
"testing"
"veyron.io/veyron/veyron/security/agent"
"veyron.io/veyron/veyron/security/agent/server"
- "veyron.io/veyron/veyron2"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
)
@@ -32,7 +32,7 @@
panic(err)
}
defer sock.Close()
- client, err := runtime.NewClient(veyron2.VCSecurityNone)
+ client, err := runtime.NewClient(options.VCSecurityNone)
if err != nil {
panic(err)
}
diff --git a/security/agent/server/server.go b/security/agent/server/server.go
index 043699b..0cf8759 100644
--- a/security/agent/server/server.go
+++ b/security/agent/server/server.go
@@ -16,6 +16,7 @@
"veyron.io/veyron/veyron/lib/unixfd"
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/security/wire"
"veyron.io/veyron/veyron2/vlog"
@@ -37,7 +38,7 @@
func RunAnonymousAgent(runtime veyron2.Runtime, signer Signer) (client *os.File, err error) {
// VCSecurityNone is safe since we're using anonymous unix sockets.
// Only our child process can possibly communicate on the socket.
- s, err := runtime.NewServer(veyron2.VCSecurityNone)
+ s, err := runtime.NewServer(options.VCSecurityNone)
if err != nil {
return nil, err
}
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index 33499c7..8fd7f9a 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -15,6 +15,7 @@
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/verror"
@@ -325,7 +326,7 @@
}
id = audit.NewPrivateID(id, auditor)
}
- return veyron2.RuntimeID(id)
+ return options.RuntimeID{id}
}
func httpaddress() string {
diff --git a/services/mgmt/node/impl/impl_test.go b/services/mgmt/node/impl/impl_test.go
index 83510d5..29099ea 100644
--- a/services/mgmt/node/impl/impl_test.go
+++ b/services/mgmt/node/impl/impl_test.go
@@ -35,6 +35,7 @@
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/services/mgmt/application"
@@ -47,7 +48,7 @@
// TestHelperProcess is blackbox boilerplate.
func TestHelperProcess(t *testing.T) {
// All TestHelperProcess invocations need a Runtime. Create it here.
- rt.Init(veyron2.ForceNewSecurityModel{})
+ rt.Init(options.ForceNewSecurityModel{})
// Disable the cache because we will be manipulating/using the namespace
// across multiple processes and want predictable behaviour without
@@ -68,7 +69,7 @@
}
// All the tests require a runtime; so just create it here.
- rt.Init(veyron2.ForceNewSecurityModel{})
+ rt.Init(options.ForceNewSecurityModel{})
// Disable the cache because we will be manipulating/using the namespace
// across multiple processes and want predictable behaviour without
@@ -718,7 +719,7 @@
}
func newRuntime(t *testing.T) veyron2.Runtime {
- runtime, err := rt.New(veyron2.ForceNewSecurityModel{})
+ runtime, err := rt.New(options.ForceNewSecurityModel{})
if err != nil {
t.Fatalf("rt.New() failed: %v", err)
}
diff --git a/services/mgmt/node/impl/util_test.go b/services/mgmt/node/impl/util_test.go
index 3788352..92be69a 100644
--- a/services/mgmt/node/impl/util_test.go
+++ b/services/mgmt/node/impl/util_test.go
@@ -10,6 +10,7 @@
"veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/services/mgmt/node"
"veyron.io/veyron/veyron2/verror"
@@ -33,7 +34,7 @@
// setupLocalNamespace sets up a mounttable and sets the local namespace root
// to point to it. Returns a cleanup function.
func setupLocalNamespace(t *testing.T) func() {
- server, err := rt.R().NewServer(veyron2.ServesMountTableOpt(true))
+ server, err := rt.R().NewServer(options.ServesMountTable(true))
if err != nil {
t.Fatalf("NewServer() failed: %v", err)
}
diff --git a/services/mounttable/lib/mounttable_test.go b/services/mounttable/lib/mounttable_test.go
index a8a6286..5195126 100644
--- a/services/mounttable/lib/mounttable_test.go
+++ b/services/mounttable/lib/mounttable_test.go
@@ -14,6 +14,7 @@
"veyron.io/veyron/veyron2/context"
"veyron.io/veyron/veyron2/ipc"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/services/mounttable"
@@ -44,7 +45,7 @@
// quuxClient returns an ipc.Client that would be used by the provided runtime
// and uses the simple namespace for name resolution.
func quuxClient(r veyron2.Runtime) ipc.Client {
- c, err := r.NewClient(veyron2.Namespace(stupidNS{r}))
+ c, err := r.NewClient(options.Namespace{stupidNS{r}})
if err != nil {
panic(err)
}
@@ -122,7 +123,7 @@
if err != nil {
boom(t, "Failed to BindMountTable: %s", err)
}
- if err := mtpt.Mount(as.NewContext(), service, uint32(ttlSecs), 0, veyron2.RetryTimeoutOpt(0)); err != nil {
+ if err := mtpt.Mount(as.NewContext(), service, uint32(ttlSecs), 0, options.RetryTimeout(0)); err != nil {
if shouldSucceed {
boom(t, "Failed to Mount %s onto %s: %s", service, name, err)
}
@@ -136,7 +137,7 @@
if err != nil {
boom(t, "Failed to BindMountTable: %s", err)
}
- if err := mtpt.Unmount(as.NewContext(), service, veyron2.RetryTimeoutOpt(0)); err != nil {
+ if err := mtpt.Unmount(as.NewContext(), service, options.RetryTimeout(0)); err != nil {
if shouldSucceed {
boom(t, "Failed to Unmount %s onto %s: %s", service, name, err)
}
@@ -160,7 +161,7 @@
if err != nil {
boom(t, "Failed to BindCollection: %s", err)
}
- contents, err := objectPtr.Lookup(as.NewContext(), veyron2.RetryTimeoutOpt(0))
+ contents, err := objectPtr.Lookup(as.NewContext(), options.RetryTimeout(0))
if err != nil {
if shouldSucceed {
boom(t, "Failed to Lookup %s: %s", name, err)
@@ -176,7 +177,7 @@
}
func newMT(t *testing.T, acl string) (ipc.Server, string) {
- server, err := rootRT.NewServer(veyron2.ServesMountTableOpt(true))
+ server, err := rootRT.NewServer(options.ServesMountTable(true))
if err != nil {
boom(t, "r.NewServer: %s", err)
}
@@ -469,12 +470,12 @@
func init() {
// Create the runtime for each of the three "processes"
- rootRT = rt.Init(veyron2.ForceNewSecurityModel{})
+ rootRT = rt.Init(options.ForceNewSecurityModel{})
var err error
- if aliceRT, err = rt.New(veyron2.ForceNewSecurityModel{}); err != nil {
+ if aliceRT, err = rt.New(options.ForceNewSecurityModel{}); err != nil {
panic(err)
}
- if bobRT, err = rt.New(veyron2.ForceNewSecurityModel{}); err != nil {
+ if bobRT, err = rt.New(options.ForceNewSecurityModel{}); err != nil {
panic(err)
}
diff --git a/services/mounttable/mounttabled/mounttable.go b/services/mounttable/mounttabled/mounttable.go
index fa7c27a..651c444 100644
--- a/services/mounttable/mounttabled/mounttable.go
+++ b/services/mounttable/mounttabled/mounttable.go
@@ -6,8 +6,8 @@
"net"
"os"
- "veyron.io/veyron/veyron2"
"veyron.io/veyron/veyron2/naming"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/vlog"
@@ -27,7 +27,7 @@
r := rt.Init()
defer r.Cleanup()
- mtServer, err := r.NewServer(veyron2.ServesMountTableOpt(true))
+ mtServer, err := r.NewServer(options.ServesMountTable(true))
if err != nil {
vlog.Errorf("r.NewServer failed: %v", err)
os.Exit(1)
@@ -60,7 +60,7 @@
if port != "" {
neighborhoodListenSpec.Address = net.JoinHostPort(host, "0")
}
- nhServer, err := r.NewServer(veyron2.ServesMountTableOpt(true))
+ nhServer, err := r.NewServer(options.ServesMountTable(true))
if err != nil {
vlog.Errorf("r.NewServer failed: %v", err)
os.Exit(1)
diff --git a/tools/identity/main.go b/tools/identity/main.go
index 24c8569..2479804 100644
--- a/tools/identity/main.go
+++ b/tools/identity/main.go
@@ -23,7 +23,7 @@
"veyron.io/veyron/veyron/services/identity"
"veyron.io/veyron/veyron/services/identity/util"
- "veyron.io/veyron/veyron2"
+ "veyron.io/veyron/veyron2/options"
"veyron.io/veyron/veyron2/rt"
"veyron.io/veyron/veyron2/security"
"veyron.io/veyron/veyron2/vdl/vdlutil"
@@ -203,7 +203,7 @@
return err
}
var err error
- if r, err = rt.New(veyron2.RuntimeID(id)); err != nil {
+ if r, err = rt.New(options.RuntimeID{id}); err != nil {
return err
}
}