wspr: The vdl "any" type is now generated as go *vdl.Value.
MultiPart: 2/7
Change-Id: I7bb8845e0a255ad8558251da42097dd5c6bac32f
diff --git a/services/wsprd/app/app.go b/services/wsprd/app/app.go
index fc6b964..749a833 100644
--- a/services/wsprd/app/app.go
+++ b/services/wsprd/app/app.go
@@ -9,6 +9,7 @@
"flag"
"fmt"
"io"
+ "reflect"
"sync"
"time"
@@ -158,11 +159,11 @@
w.Error(verror.New(marshallingError, ctx, "ResponseStreamClose"))
}
}
- results := make([]interface{}, msg.NumOutArgs)
- // This array will have pointers to the values in result.
+ results := make([]*vdl.Value, msg.NumOutArgs)
+ // This array will have pointers to the values in results.
resultptrs := make([]interface{}, msg.NumOutArgs)
- for ax := range results {
- resultptrs[ax] = &results[ax]
+ for i := range results {
+ resultptrs[i] = &results[i]
}
if err := clientCall.Finish(resultptrs...); err != nil {
// return the call system error as is
@@ -172,17 +173,12 @@
c.sendRPCResponse(ctx, w, span, results)
}
-func (c *Controller) sendRPCResponse(ctx *context.T, w lib.ClientWriter, span vtrace.Span, results []interface{}) {
- outargs := make([]vdl.AnyRep, len(results))
- for i := range outargs {
- outargs[i] = results[i]
- }
-
+func (c *Controller) sendRPCResponse(ctx *context.T, w lib.ClientWriter, span vtrace.Span, results []*vdl.Value) {
span.Finish()
traceRecord := vtrace.GetStore(ctx).TraceRecord(span.Trace())
response := VeyronRPCResponse{
- OutArgs: outargs,
+ OutArgs: results,
TraceResponse: vtrace.Response{
Flags: vtrace.CollectInMemory,
Trace: *traceRecord,
@@ -351,7 +347,7 @@
type localCall struct {
ctx *context.T
vrpc *VeyronRPCRequest
- tags []interface{}
+ tags []*vdl.Value
}
func (l *localCall) Send(interface{}) error { return nil }
@@ -361,7 +357,7 @@
func (l *localCall) Context() *context.T { return l.ctx }
func (l *localCall) Timestamp() (t time.Time) { return }
func (l *localCall) Method() string { return l.vrpc.Method }
-func (l *localCall) MethodTags() []interface{} { return l.tags }
+func (l *localCall) MethodTags() []*vdl.Value { return l.tags }
func (l *localCall) Name() string { return l.vrpc.Name }
func (l *localCall) Suffix() string { return "" }
func (l *localCall) RemoteDischarges() map[string]security.Discharge { return nil }
@@ -393,7 +389,17 @@
w.Error(verror.Convert(verror.ErrInternal, ctx, err))
return
}
- c.sendRPCResponse(ctx, w, span, results)
+ // Convert results from []interface{} to []*vdl.Value.
+ vresults := make([]*vdl.Value, len(results))
+ for i, res := range results {
+ vv, err := vdl.ValueFromReflect(reflect.ValueOf(res))
+ if err != nil {
+ w.Error(verror.Convert(verror.ErrInternal, ctx, err))
+ return
+ }
+ vresults[i] = vv
+ }
+ c.sendRPCResponse(ctx, w, span, vresults)
}
// HandleVeyronRequest starts a veyron rpc and returns before the rpc has been completed.
diff --git a/services/wsprd/app/app.vdl.go b/services/wsprd/app/app.vdl.go
index adf9666..74545f3 100644
--- a/services/wsprd/app/app.vdl.go
+++ b/services/wsprd/app/app.vdl.go
@@ -29,7 +29,7 @@
}
type VeyronRPCResponse struct {
- OutArgs []vdl.AnyRep
+ OutArgs []*vdl.Value
TraceResponse vtrace.Response
}
diff --git a/services/wsprd/app/app_test.go b/services/wsprd/app/app_test.go
index b69c802..7a334ce 100644
--- a/services/wsprd/app/app_test.go
+++ b/services/wsprd/app/app_test.go
@@ -245,7 +245,7 @@
}
}
-func makeRPCResponse(outArgs ...vdl.AnyRep) string {
+func makeRPCResponse(outArgs ...*vdl.Value) string {
return lib.VomEncodeOrDie(VeyronRPCResponse{
OutArgs: outArgs,
TraceResponse: vtrace.Response{
@@ -261,7 +261,7 @@
numOutArgs: 1,
expectedStream: []lib.Response{
lib.Response{
- Message: makeRPCResponse(int32(5)),
+ Message: makeRPCResponse(vdl.Int32Value(5)),
Type: lib.ResponseFinal,
},
},
@@ -304,7 +304,7 @@
Type: lib.ResponseStreamClose,
},
lib.Response{
- Message: makeRPCResponse(int32(10)),
+ Message: makeRPCResponse(vdl.Int32Value(10)),
Type: lib.ResponseFinal,
},
},
@@ -450,7 +450,7 @@
serverStream []interface{}
// The final response sent by the Javascript server to the
// app.
- finalResponse interface{}
+ finalResponse *vdl.Value
// The final error sent by the Javascript server to the app.
err error
@@ -547,7 +547,7 @@
expectedStream = expectedStream[1:]
}
- var result interface{}
+ var result *vdl.Value
err = call.Finish(&result)
// Make sure the err matches either test.authError or test.err.
@@ -563,8 +563,8 @@
t.Errorf("unexpected error: got %#v, want nil", err)
}
- if !reflect.DeepEqual(result, test.finalResponse) {
- t.Errorf("unexected final response: got %v, expected %v", result, test.finalResponse)
+ if got, want := result, test.finalResponse; !vdl.EqualValue(got, want) {
+ t.Errorf("unexected final response: got %v, want %v", got, want)
}
}
@@ -572,7 +572,7 @@
runJsServerTestCase(t, jsServerTestCase{
method: "Add",
inArgs: []interface{}{int32(1), int32(2)},
- finalResponse: int32(3),
+ finalResponse: vdl.Int32Value(3),
})
}
@@ -580,7 +580,7 @@
runJsServerTestCase(t, jsServerTestCase{
method: "Add",
inArgs: []interface{}{int32(1), int32(2)},
- finalResponse: int32(3),
+ finalResponse: vdl.Int32Value(3),
hasAuthorizer: true,
})
}
@@ -607,7 +607,7 @@
runJsServerTestCase(t, jsServerTestCase{
method: "StreamingAdd",
clientStream: []interface{}{int32(3), int32(4)},
- finalResponse: int32(10),
+ finalResponse: vdl.Int32Value(10),
})
}
@@ -615,7 +615,7 @@
runJsServerTestCase(t, jsServerTestCase{
method: "StreamingAdd",
serverStream: []interface{}{int32(3), int32(4)},
- finalResponse: int32(10),
+ finalResponse: vdl.Int32Value(10),
})
}
@@ -624,7 +624,7 @@
method: "StreamingAdd",
clientStream: []interface{}{int32(1), int32(2)},
serverStream: []interface{}{int32(3), int32(4)},
- finalResponse: int32(10),
+ finalResponse: vdl.Int32Value(10),
})
}
diff --git a/services/wsprd/app/mock_jsServer_test.go b/services/wsprd/app/mock_jsServer_test.go
index 21c230e..56f1c82 100644
--- a/services/wsprd/app/mock_jsServer_test.go
+++ b/services/wsprd/app/mock_jsServer_test.go
@@ -26,7 +26,7 @@
hasAuthorizer bool
authError error
inArgs []interface{}
- finalResponse interface{}
+ finalResponse *vdl.Value
finalError error
hasCalledAuth bool
// Right now we keep track of the flow count by hand, but maybe we
@@ -261,7 +261,7 @@
func (m *mockJSServer) handleStreamClose(msg interface{}) error {
m.sender.Wait()
reply := lib.ServerRPCReply{
- Results: []vdl.AnyRep{m.finalResponse},
+ Results: []*vdl.Value{m.finalResponse},
Err: m.finalError,
}
vomReply, err := lib.VomEncode(reply)
diff --git a/services/wsprd/browspr/browspr.go b/services/wsprd/browspr/browspr.go
index db88c62..1c5f6b5 100644
--- a/services/wsprd/browspr/browspr.go
+++ b/services/wsprd/browspr/browspr.go
@@ -3,11 +3,13 @@
import (
"fmt"
+ "reflect"
"sync"
"v.io/core/veyron2"
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
+ "v.io/core/veyron2/vdl"
"v.io/core/veyron2/vlog"
"v.io/core/veyron2/vtrace"
"v.io/wspr/veyron/services/wsprd/account"
@@ -85,10 +87,10 @@
// HandleCleanupRpc cleans up the specified instance state. (For instance,
// when a browser tab is closed)
-func (b *Browspr) HandleCleanupRpc(val interface{}) (interface{}, error) {
- msg, found := val.(CleanupMessage)
- if !found {
- return nil, fmt.Errorf("HandleCleanupRpc did not receive CleanupMessage, received: %v", val)
+func (b *Browspr) HandleCleanupRpc(val *vdl.Value) (*vdl.Value, error) {
+ var msg CleanupMessage
+ if err := vdl.Convert(&msg, val); err != nil {
+ return nil, fmt.Errorf("HandleCleanupRpc did not receive CleanupMessage, received: %v, %v", val, err)
}
b.mu.Lock()
@@ -113,10 +115,10 @@
// which is exchanged for blessings from the veyron blessing server.
// An account based on the blessings is then added to WSPR's principal
// manager, and the set of blessing strings are returned to the client.
-func (b *Browspr) HandleAuthCreateAccountRpc(val interface{}) (interface{}, error) {
- msg, found := val.(CreateAccountMessage)
- if !found {
- return nil, fmt.Errorf("HandleAuthCreateAccountRpc did not receive CreateAccountMessage, received: %v", val)
+func (b *Browspr) HandleAuthCreateAccountRpc(val *vdl.Value) (*vdl.Value, error) {
+ var msg CreateAccountMessage
+ if err := vdl.Convert(&msg, val); err != nil {
+ return nil, fmt.Errorf("HandleAuthCreateAccountRpc did not receive CreateAccountMessage, received: %v, %v", val, err)
}
ctx, _ := vtrace.SetNewTrace(b.ctx)
@@ -125,14 +127,14 @@
return nil, err
}
- return account, nil
+ return vdl.ValueFromReflect(reflect.ValueOf(account))
}
// HandleAssociateAccountMessage associates an account with the specified origin.
-func (b *Browspr) HandleAuthAssociateAccountRpc(val interface{}) (interface{}, error) {
- msg, found := val.(AssociateAccountMessage)
- if !found {
- return nil, fmt.Errorf("HandleAuthAssociateAccountRpc did not receive AssociateAccountMessage, received: %v", val)
+func (b *Browspr) HandleAuthAssociateAccountRpc(val *vdl.Value) (*vdl.Value, error) {
+ var msg AssociateAccountMessage
+ if err := vdl.Convert(&msg, val); err != nil {
+ return nil, fmt.Errorf("HandleAuthAssociateAccountRpc did not receive AssociateAccountMessage, received: %v, %v", val, err)
}
if err := b.accountManager.AssociateAccount(msg.Origin, msg.Account, msg.Caveats); err != nil {
@@ -142,17 +144,18 @@
}
// HandleAuthGetAccountsRpc gets the root account name from the account manager.
-func (b *Browspr) HandleAuthGetAccountsRpc(interface{}) (interface{}, error) {
- return b.accountManager.GetAccounts(), nil
+func (b *Browspr) HandleAuthGetAccountsRpc(*vdl.Value) (*vdl.Value, error) {
+ return vdl.ValueFromReflect(reflect.ValueOf(b.accountManager.GetAccounts()))
}
// HandleAuthOriginHasAccountRpc returns true iff the origin has an associated
// principal.
-func (b *Browspr) HandleAuthOriginHasAccountRpc(val interface{}) (interface{}, error) {
- msg, found := val.(OriginHasAccountMessage)
- if !found {
- return nil, fmt.Errorf("HandleAuthOriginHasAccountRpc did not receive OriginHasAccountMessage, received: %v", val)
+func (b *Browspr) HandleAuthOriginHasAccountRpc(val *vdl.Value) (*vdl.Value, error) {
+ var msg OriginHasAccountMessage
+ if err := vdl.Convert(&msg, val); err != nil {
+ return nil, fmt.Errorf("HandleAuthOriginHasAccountRpc did not receive OriginHasAccountMessage, received: %v, %v", val, err)
}
- return b.accountManager.OriginHasAccount(msg.Origin), nil
+ res := b.accountManager.OriginHasAccount(msg.Origin)
+ return vdl.ValueFromReflect(reflect.ValueOf(res))
}
diff --git a/services/wsprd/browspr/browspr_account_test.go b/services/wsprd/browspr/browspr_account_test.go
index 5200ea0..119c91c 100644
--- a/services/wsprd/browspr/browspr_account_test.go
+++ b/services/wsprd/browspr/browspr_account_test.go
@@ -2,13 +2,13 @@
import (
"fmt"
- "reflect"
"testing"
"v.io/core/veyron2"
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/security"
+ "v.io/core/veyron2/vdl"
"v.io/core/veyron/lib/testutil"
_ "v.io/core/veyron/profiles"
@@ -60,26 +60,26 @@
defer teardown()
// Verify that HandleAuthGetAccountsRpc returns empty.
- nilValue := GetAccountsMessage{}
+ nilValue := vdl.ValueOf(GetAccountsMessage{})
a, err := browspr.HandleAuthGetAccountsRpc(nilValue)
if err != nil {
t.Fatal("browspr.HandleAuthGetAccountsRpc(%v) failed: %v", nilValue, err)
}
- if len(a.([]string)) > 0 {
+ if a.Len() > 0 {
t.Fatalf("Expected accounts to be empty array but got %v", a)
}
// Add one account.
- message1 := CreateAccountMessage{
+ message1 := vdl.ValueOf(CreateAccountMessage{
Token: "mock-access-token-1",
- }
+ })
account1, err := browspr.HandleAuthCreateAccountRpc(message1)
if err != nil {
t.Fatalf("browspr.HandleAuthCreateAccountRpc(%v) failed: %v", message1, err)
}
// Verify that principalManager has the new account
- if b, err := browspr.principalManager.BlessingsForAccount(account1.(string)); err != nil || b == nil {
+ if b, err := browspr.principalManager.BlessingsForAccount(account1.RawString()); err != nil || b == nil {
t.Fatalf("Failed to get Blessings for account %v: got %v, %v", account1, b, err)
}
@@ -88,14 +88,14 @@
if err != nil {
t.Fatal("browspr.HandleAuthGetAccountsRpc(%v) failed: %v", nilValue, err)
}
- if want := []string{account1.(string)}; !reflect.DeepEqual(want, gotAccounts1) {
+ if want := vdl.ValueOf([]string{account1.RawString()}); !vdl.EqualValue(want, gotAccounts1) {
t.Fatalf("Expected account to be %v but got empty but got %v", want, gotAccounts1)
}
// Add another account
- message2 := CreateAccountMessage{
+ message2 := vdl.ValueOf(CreateAccountMessage{
Token: "mock-access-token-2",
- }
+ })
account2, err := browspr.HandleAuthCreateAccountRpc(message2)
if err != nil {
t.Fatalf("browspr.HandleAuthCreateAccountsRpc(%v) failed: %v", message2, err)
@@ -106,15 +106,15 @@
if err != nil {
t.Fatal("browspr.HandleAuthGetAccountsRpc(%v) failed: %v", nilValue, err)
}
- if want := []string{account1.(string), account2.(string)}; !reflect.DeepEqual(want, gotAccounts2) {
+ if want := vdl.ValueOf([]string{account1.RawString(), account2.RawString()}); !vdl.EqualValue(want, gotAccounts2) {
t.Fatalf("Expected account to be %v but got empty but got %v", want, gotAccounts2)
}
// Verify that principalManager has both accounts
- if b, err := browspr.principalManager.BlessingsForAccount(account1.(string)); err != nil || b == nil {
+ if b, err := browspr.principalManager.BlessingsForAccount(account1.RawString()); err != nil || b == nil {
t.Fatalf("Failed to get Blessings for account %v: got %v, %v", account1, b, err)
}
- if b, err := browspr.principalManager.BlessingsForAccount(account2.(string)); err != nil || b == nil {
+ if b, err := browspr.principalManager.BlessingsForAccount(account2.RawString()); err != nil || b == nil {
t.Fatalf("Failed to get Blessings for account %v: got %v, %v", account2, b, err)
}
}
@@ -137,21 +137,21 @@
origin := "https://my.webapp.com:443"
// Verify that HandleAuthOriginHasAccountRpc returns false
- hasAccountMessage := OriginHasAccountMessage{
+ hasAccountMessage := vdl.ValueOf(OriginHasAccountMessage{
Origin: origin,
- }
+ })
hasAccount, err := browspr.HandleAuthOriginHasAccountRpc(hasAccountMessage)
if err != nil {
t.Fatal(err)
}
- if hasAccount.(bool) {
+ if hasAccount.Bool() {
t.Fatal("Expected browspr.HandleAuthOriginHasAccountRpc(%v) to be false but was true", hasAccountMessage)
}
- assocAccountMessage := AssociateAccountMessage{
+ assocAccountMessage := vdl.ValueOf(AssociateAccountMessage{
Account: account,
Origin: origin,
- }
+ })
if _, err := browspr.HandleAuthAssociateAccountRpc(assocAccountMessage); err != nil {
t.Fatalf("browspr.HandleAuthAssociateAccountRpc(%v) failed: %v", assocAccountMessage, err)
@@ -162,7 +162,7 @@
if err != nil {
t.Fatal(err)
}
- if !hasAccount.(bool) {
+ if !hasAccount.Bool() {
t.Fatal("Expected browspr.HandleAuthOriginHasAccountRpc(%v) to be true but was false", hasAccountMessage)
}
@@ -183,10 +183,10 @@
account := "mock-account"
origin := "https://my.webapp.com:443"
- message := AssociateAccountMessage{
+ message := vdl.ValueOf(AssociateAccountMessage{
Account: account,
Origin: origin,
- }
+ })
if _, err := browspr.HandleAuthAssociateAccountRpc(message); err == nil {
t.Fatalf("browspr.HandleAuthAssociateAccountRpc(%v) should have failed but did not.")
@@ -203,14 +203,14 @@
}
// Verify that HandleAuthOriginHasAccountRpc returns false
- hasAccountMessage := OriginHasAccountMessage{
+ hasAccountMessage := vdl.ValueOf(OriginHasAccountMessage{
Origin: origin,
- }
+ })
hasAccount, err := browspr.HandleAuthOriginHasAccountRpc(hasAccountMessage)
if err != nil {
t.Fatal(err)
}
- if hasAccount.(bool) {
+ if hasAccount.Bool() {
t.Fatal("Expected browspr.HandleAuthOriginHasAccountRpc(%v) to be false but was true", hasAccountMessage)
}
}
diff --git a/services/wsprd/browspr/browspr_test.go b/services/wsprd/browspr/browspr_test.go
index 23da685..36279eb 100644
--- a/services/wsprd/browspr/browspr_test.go
+++ b/services/wsprd/browspr/browspr_test.go
@@ -4,7 +4,6 @@
"bytes"
"encoding/hex"
"encoding/json"
- "reflect"
"strings"
"testing"
"time"
@@ -14,6 +13,7 @@
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/options"
+ "v.io/core/veyron2/vdl"
"v.io/core/veyron2/vom"
"v.io/core/veyron/lib/testutil"
@@ -248,7 +248,7 @@
if err := lib.VomDecode(outArg, &result); err != nil {
t.Errorf("Failed to vom decode args from %v: %v", outArg, err)
}
- if got, want := result.OutArgs[0], "[InputValue]"; !reflect.DeepEqual(got, want) {
+ if got, want := result.OutArgs[0], vdl.StringValue("[InputValue]"); !vdl.EqualValue(got, want) {
t.Errorf("Result got %v, want %v", got, want)
}
}
diff --git a/services/wsprd/browspr/main/main_nacl.go b/services/wsprd/browspr/main/main_nacl.go
index d98b695..7d50e19 100644
--- a/services/wsprd/browspr/main/main_nacl.go
+++ b/services/wsprd/browspr/main/main_nacl.go
@@ -13,6 +13,7 @@
vsecurity "v.io/core/veyron/security"
"v.io/core/veyron2"
"v.io/core/veyron2/security"
+ "v.io/core/veyron2/vdl"
"v.io/core/veyron2/vlog"
"v.io/wspr/veyron/services/wsprd/browspr"
"v.io/wspr/veyron/services/wsprd/channel/channel_nacl"
@@ -140,12 +141,11 @@
return security.UnmarshalPublicKey(decodedK)
}
-func (inst *browsprInstance) HandleStartMessage(val interface{}) (interface{}, error) {
+func (inst *browsprInstance) HandleStartMessage(val *vdl.Value) (*vdl.Value, error) {
vlog.VI(1).Info("Starting Browspr")
-
- msg, found := val.(browspr.StartMessage)
- if !found {
- return nil, fmt.Errorf("HandleStartMessage did not receive StartMessage, received: %v", val)
+ var msg browspr.StartMessage
+ if err := vdl.Convert(&msg, val); err != nil {
+ return nil, fmt.Errorf("HandleStartMessage did not receive StartMessage, received: %v, %v", val, err)
}
principal, err := inst.newPersistantPrincipal(msg.IdentitydBlessingRoot.Names)
diff --git a/services/wsprd/channel/channel.go b/services/wsprd/channel/channel.go
index 1e16121..ec1071b 100644
--- a/services/wsprd/channel/channel.go
+++ b/services/wsprd/channel/channel.go
@@ -3,9 +3,11 @@
import (
"fmt"
"sync"
+
+ "v.io/core/veyron2/vdl"
)
-type RequestHandler func(interface{}) (interface{}, error)
+type RequestHandler func(*vdl.Value) (*vdl.Value, error)
type MessageSender func(Message)
@@ -26,7 +28,7 @@
}
}
-func (c *Channel) PerformRpc(typ string, body interface{}) (interface{}, error) {
+func (c *Channel) PerformRpc(typ string, body *vdl.Value) (*vdl.Value, error) {
c.lock.Lock()
c.lastSeq++
lastSeq := c.lastSeq
diff --git a/services/wsprd/channel/channel.vdl.go b/services/wsprd/channel/channel.vdl.go
index 3e4efd1..9e328fe 100644
--- a/services/wsprd/channel/channel.vdl.go
+++ b/services/wsprd/channel/channel.vdl.go
@@ -11,7 +11,7 @@
type Request struct {
Type string
Seq uint32
- Body vdl.AnyRep
+ Body *vdl.Value
}
func (Request) __VDLReflect(struct {
@@ -22,7 +22,7 @@
type Response struct {
ReqSeq uint32
Err string // TODO(bprosnitz) change this back to error when it is possible to do so. (issue 368)
- Body vdl.AnyRep
+ Body *vdl.Value
}
func (Response) __VDLReflect(struct {
diff --git a/services/wsprd/channel/channel_nacl/channel_nacl.go b/services/wsprd/channel/channel_nacl/channel_nacl.go
index ea51559..6b20261 100644
--- a/services/wsprd/channel/channel_nacl/channel_nacl.go
+++ b/services/wsprd/channel/channel_nacl/channel_nacl.go
@@ -42,12 +42,8 @@
c.impl.RegisterRequestHandler(typ, handler)
}
-func (c *Channel) PerformRpc(typ string, body interface{}) (*vdl.Value, error) {
- iface, err := c.impl.PerformRpc(typ, body)
- if err != nil {
- return nil, err
- }
- return iface.(*vdl.Value), nil
+func (c *Channel) PerformRpc(typ string, body *vdl.Value) (*vdl.Value, error) {
+ return c.impl.PerformRpc(typ, body)
}
func (c *Channel) HandleMessage(v ppapi.Var) {
diff --git a/services/wsprd/channel/channel_test.go b/services/wsprd/channel/channel_test.go
index 8139f65..9b1de1d 100644
--- a/services/wsprd/channel/channel_test.go
+++ b/services/wsprd/channel/channel_test.go
@@ -4,6 +4,8 @@
"fmt"
"sync"
"testing"
+
+ "v.io/core/veyron2/vdl"
"v.io/wspr/veyron/services/wsprd/channel"
)
@@ -43,12 +45,12 @@
numCalls := 0
// reusedHandler handles requests to the same type name.
- reusedHandler := func(v interface{}) (interface{}, error) {
+ reusedHandler := func(v *vdl.Value) (*vdl.Value, error) {
callCountLock.Lock()
numCalls++
callCountLock.Unlock()
- return v.(int) - 1000, nil
+ return vdl.Int64Value(v.Int() - 1000), nil
}
wg := sync.WaitGroup{}
@@ -58,25 +60,25 @@
// Get the message handler. Either the reused handle or a unique handle for this
// test, depending on the type name.
- var handler func(v interface{}) (interface{}, error)
+ var handler func(v *vdl.Value) (*vdl.Value, error)
if test.Type == reusedTypeName {
handler = reusedHandler
} else {
- handler = func(v interface{}) (interface{}, error) {
+ handler = func(v *vdl.Value) (*vdl.Value, error) {
callCountLock.Lock()
numCalls++
callCountLock.Unlock()
- if test.ReqVal != v.(int) {
- t.Errorf("For test %d, expected request value was %d but got %d", i, test.ReqVal, v.(int))
+ if got, want := v, vdl.Int64Value(int64(test.ReqVal)); !vdl.EqualValue(got, want) {
+ t.Errorf("For test %d, got %v, want %v", i, got, want)
}
- return test.RespVal, test.Err
+ return vdl.Int64Value(int64(test.RespVal)), test.Err
}
}
test.RecvChannel.RegisterRequestHandler(test.Type, handler)
// Perform the RPC.
- result, err := test.SendChannel.PerformRpc(test.Type, test.ReqVal)
+ result, err := test.SendChannel.PerformRpc(test.Type, vdl.Int64Value(int64(test.ReqVal)))
if test.Err != nil {
if err == nil {
t.Errorf("For test %d, expected an error but didn't get one", i)
@@ -86,8 +88,8 @@
t.Errorf("For test %d, received unexpected error %v", i, err)
return
}
- if result.(int) != test.RespVal {
- t.Errorf("For test %d, expected response value was %d but got %d", i, test.RespVal, result.(int))
+ if got, want := result, vdl.Int64Value(int64(test.RespVal)); !vdl.EqualValue(got, want) {
+ t.Errorf("For test %d, got %v, want %v", i, got, want)
}
}
}
diff --git a/services/wsprd/ipc/server/dispatcher_test.go b/services/wsprd/ipc/server/dispatcher_test.go
index 41cef8a..602e15c 100644
--- a/services/wsprd/ipc/server/dispatcher_test.go
+++ b/services/wsprd/ipc/server/dispatcher_test.go
@@ -7,6 +7,7 @@
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/security"
+ "v.io/core/veyron2/vdl"
"v.io/core/veyron2/vdl/vdlroot/src/signature"
"v.io/wspr/veyron/services/wsprd/lib"
"v.io/wspr/veyron/services/wsprd/lib/testwriter"
@@ -28,8 +29,8 @@
hasGlobber bool
}
-func (m mockInvoker) Prepare(string, int) ([]interface{}, []interface{}, error) {
- return nil, []interface{}{}, nil
+func (m mockInvoker) Prepare(string, int) ([]interface{}, []*vdl.Value, error) {
+ return nil, nil, nil
}
func (mockInvoker) Invoke(string, ipc.ServerCall, []interface{}) ([]interface{}, error) {
diff --git a/services/wsprd/ipc/server/invoker.go b/services/wsprd/ipc/server/invoker.go
index 8935741..f2f9877 100644
--- a/services/wsprd/ipc/server/invoker.go
+++ b/services/wsprd/ipc/server/invoker.go
@@ -39,7 +39,7 @@
}
// Prepare implements the Invoker interface.
-func (i *invoker) Prepare(methodName string, numArgs int) ([]interface{}, []interface{}, error) {
+func (i *invoker) Prepare(methodName string, numArgs int) ([]interface{}, []*vdl.Value, error) {
method, err := i.MethodSignature(nil, methodName)
if err != nil {
return nil, nil, err
@@ -51,13 +51,7 @@
for ix, arg := range method.InArgs {
argptrs[ix] = vdl.ZeroValue(arg.Type)
}
-
- tags := make([]interface{}, len(method.Tags))
- for ix, tag := range method.Tags {
- tags[ix] = (interface{})(tag)
- }
-
- return argptrs, tags, nil
+ return argptrs, method.Tags, nil
}
// Invoke implements the Invoker interface.
@@ -71,10 +65,10 @@
return nil, reply.Err
}
- // Convert the reply.Results from []vdl.AnyRep to []interface{}
+ // Convert the reply.Results from []*vdl.Value to []interface{}
results := make([]interface{}, len(reply.Results))
for i, r := range reply.Results {
- results[i] = interface{}(r)
+ results[i] = r
}
return results, nil
}
diff --git a/services/wsprd/ipc/server/server.go b/services/wsprd/ipc/server/server.go
index 173f9ba..50e5a74 100644
--- a/services/wsprd/ipc/server/server.go
+++ b/services/wsprd/ipc/server/server.go
@@ -16,6 +16,7 @@
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/security"
+ "v.io/core/veyron2/vdl"
"v.io/core/veyron2/vdl/vdlroot/src/signature"
"v.io/core/veyron2/verror"
"v.io/core/veyron2/vlog"
@@ -67,7 +68,7 @@
type SecurityContext struct {
Method string
Suffix string
- MethodTags []interface{}
+ MethodTags []*vdl.Value
LocalBlessings principal.BlessingsHandle
LocalBlessingStrings []string
RemoteBlessings principal.BlessingsHandle
diff --git a/services/wsprd/lib/writer.vdl.go b/services/wsprd/lib/writer.vdl.go
index 52d528f..78cf271 100644
--- a/services/wsprd/lib/writer.vdl.go
+++ b/services/wsprd/lib/writer.vdl.go
@@ -10,7 +10,7 @@
// The response from the javascript server to the proxy.
type ServerRPCReply struct {
- Results []vdl.AnyRep
+ Results []*vdl.Value
Err error
}