Merge "veyron2/vdl: New API for generated Go interfaces."
diff --git a/lib/signals/signals_test.go b/lib/signals/signals_test.go
index cfe3f16..5588610 100644
--- a/lib/signals/signals_test.go
+++ b/lib/signals/signals_test.go
@@ -317,7 +317,7 @@
if ep, err = server.Listen(profiles.LocalListenSpec); err != nil {
t.Fatalf("Got error: %v", err)
}
- if err := server.Serve("", node.NewServerConfig(&configServer{ch}), vflag.NewAuthorizerOrDie()); err != nil {
+ if err := server.Serve("", node.ConfigServer(&configServer{ch}), vflag.NewAuthorizerOrDie()); err != nil {
t.Fatalf("Got error: %v", err)
}
return server, naming.JoinAddressName(ep.String(), ""), ch
@@ -350,10 +350,7 @@
s := expect.NewSession(t, h.Stdout(), time.Minute)
appCycleName := <-ch
s.Expect("ready")
- appCycle, err := appcycle.BindAppCycle(appCycleName)
- if err != nil {
- t.Fatalf("Got error: %v", err)
- }
+ appCycle := appcycle.AppCycleClient(appCycleName)
stream, err := appCycle.Stop(r.NewContext())
if err != nil {
t.Fatalf("Got error: %v", err)
diff --git a/runtimes/google/appcycle/appcycle.go b/runtimes/google/appcycle/appcycle.go
index 85979e2..e434523 100644
--- a/runtimes/google/appcycle/appcycle.go
+++ b/runtimes/google/appcycle/appcycle.go
@@ -12,52 +12,68 @@
"veyron.io/veyron/veyron2/ipc"
)
-// AppCycleService is the interface the server implements.
-type AppCycleService interface {
-
- // Stop initiates shutdown of the server. It streams back periodic updates
- // to give the client an idea of how the shutdown is progressing.
- Stop(context ipc.ServerContext, stream AppCycleServiceStopStream) (err error)
- // ForceStop tells the server to shut down right away. It can be issued while
- // a Stop is outstanding if for example the client does not want to wait any
- // longer.
- ForceStop(context ipc.ServerContext) (err error)
+// AppCycleServerMethods is the interface a server writer
+// implements for AppCycle.
+//
+// AppCycle interfaces with the process running a veyron runtime.
+type AppCycleServerMethods interface {
+ // Stop initiates shutdown of the server. It streams back periodic
+ // updates to give the client an idea of how the shutdown is
+ // progressing.
+ Stop(AppCycleStopContext) error
+ // ForceStop tells the server to shut down right away. It can be issued
+ // while a Stop is outstanding if for example the client does not want
+ // to wait any longer.
+ ForceStop(ipc.ServerContext) error
}
-// NewServerAppCycle creates a new receiver from the given AppCycleService.
-func NewServerAppCycle(server AppCycleService) interface{} {
- return &ServerStubAppCycle{
- service: server,
+// AppCycleServer returns a server stub for AppCycle.
+// It converts an implementation of AppCycleServerMethods into
+// an object that may be used by ipc.Server.
+func AppCycleServer(impl AppCycleServerMethods) AppCycleServerStub {
+ return AppCycleServerStub{impl}
+}
+
+type AppCycleServerStub struct {
+ impl AppCycleServerMethods
+}
+
+func (s AppCycleServerStub) Stop(call ipc.ServerCall) error {
+ ctx := &implAppCycleStopContext{call, implAppCycleStopServerSend{call}}
+ return s.impl.Stop(ctx)
+}
+
+func (s AppCycleServerStub) ForceStop(call ipc.ServerCall) error {
+ return s.impl.ForceStop(call)
+}
+
+// AppCycleStopContext represents the context passed to AppCycle.Stop.
+type AppCycleStopContext interface {
+ ipc.ServerContext
+ // SendStream returns the send side of the server stream.
+ SendStream() interface {
+ // Send places the item onto the output stream. Returns errors encountered
+ // while sending. Blocks if there is no buffer space; will unblock when
+ // buffer space is available.
+ Send(item veyron2.Task) error
}
}
-type AppCycleServiceStopStream interface {
- // Send places the item onto the output stream, blocking if there is no buffer
- // space available.
+type implAppCycleStopServerSend struct {
+ call ipc.ServerCall
+}
+
+func (s *implAppCycleStopServerSend) Send(item veyron2.Task) error {
+ return s.call.Send(item)
+}
+
+type implAppCycleStopContext struct {
+ ipc.ServerContext
+ send implAppCycleStopServerSend
+}
+
+func (s *implAppCycleStopContext) SendStream() interface {
Send(item veyron2.Task) error
-}
-
-// Implementation of the AppCycleServiceStopStream interface that is not exported.
-type implAppCycleServiceStopStream struct {
- serverCall ipc.ServerCall
-}
-
-func (s *implAppCycleServiceStopStream) Send(item veyron2.Task) error {
- return s.serverCall.Send(item)
-}
-
-// ServerStubAppCycle wraps a server that implements
-// AppCycleService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubAppCycle struct {
- service AppCycleService
-}
-
-func (s *ServerStubAppCycle) Stop(call ipc.ServerCall) error {
- stream := &implAppCycleServiceStopStream{serverCall: call}
- return s.service.Stop(call, stream)
-}
-
-func (s *ServerStubAppCycle) ForceStop(call ipc.ServerCall) error {
- return s.service.ForceStop(call)
+} {
+ return &s.send
}
diff --git a/runtimes/google/ipc/benchmarks/client.go b/runtimes/google/ipc/benchmarks/client.go
index 7d7c871..1ed3a21 100644
--- a/runtimes/google/ipc/benchmarks/client.go
+++ b/runtimes/google/ipc/benchmarks/client.go
@@ -19,11 +19,7 @@
payload[i] = byte(i & 0xff)
}
- stub, err := BindBenchmark(address)
- if err != nil {
- vlog.Fatalf("BindBenchmark(%q) failed: %v", address, err)
- }
-
+ stub := BenchmarkClient(address)
for i := 0; i < iterations; i++ {
start := time.Now()
result, err := stub.Echo(ctx, payload)
@@ -49,11 +45,7 @@
payload[i] = byte(i & 0xff)
}
- stub, err := BindBenchmark(address)
- if err != nil {
- vlog.Fatalf("BindBenchmark(%q) failed: %v", address, err)
- }
-
+ stub := BenchmarkClient(address)
for i := 0; i < rpcCount; i++ {
start := time.Now()
ctx, _ := rt.R().NewContext().WithTimeout(time.Hour)
diff --git a/runtimes/google/ipc/benchmarks/service.vdl.go b/runtimes/google/ipc/benchmarks/service.vdl.go
index 646f0b0..d3f44ee 100644
--- a/runtimes/google/ipc/benchmarks/service.vdl.go
+++ b/runtimes/google/ipc/benchmarks/service.vdl.go
@@ -6,149 +6,186 @@
package benchmarks
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_io "io"
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __io "io"
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
-// Benchmark is the interface the client binds and uses.
-// Benchmark_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Benchmark_ExcludingUniversal interface {
+// BenchmarkClientMethods is the client interface
+// containing Benchmark methods.
+type BenchmarkClientMethods interface {
// Echo returns the payload that it receives.
- Echo(ctx _gen_context.T, Payload []byte, opts ..._gen_ipc.CallOpt) (reply []byte, err error)
+ Echo(ctx __context.T, Payload []byte, opts ...__ipc.CallOpt) ([]byte, error)
// EchoStream returns the payload that it receives via the stream.
- EchoStream(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply BenchmarkEchoStreamCall, err error)
-}
-type Benchmark interface {
- _gen_ipc.UniversalServiceMethods
- Benchmark_ExcludingUniversal
+ EchoStream(__context.T, ...__ipc.CallOpt) (BenchmarkEchoStreamCall, error)
}
-// BenchmarkService is the interface the server implements.
-type BenchmarkService interface {
-
- // Echo returns the payload that it receives.
- Echo(context _gen_ipc.ServerContext, Payload []byte) (reply []byte, err error)
- // EchoStream returns the payload that it receives via the stream.
- EchoStream(context _gen_ipc.ServerContext, stream BenchmarkServiceEchoStreamStream) (err error)
+// BenchmarkClientStub adds universal methods to BenchmarkClientMethods.
+type BenchmarkClientStub interface {
+ BenchmarkClientMethods
+ __ipc.UniversalServiceMethods
}
-// BenchmarkEchoStreamCall is the interface for call object of the method
-// EchoStream in the service interface Benchmark.
-type BenchmarkEchoStreamCall interface {
- // RecvStream returns the recv portion of the stream
+// BenchmarkClient returns a client stub for Benchmark.
+func BenchmarkClient(name string, opts ...__ipc.BindOpt) BenchmarkClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
+ client = clientOpt
+ }
+ }
+ return implBenchmarkClientStub{name, client}
+}
+
+type implBenchmarkClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implBenchmarkClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implBenchmarkClientStub) Echo(ctx __context.T, i0 []byte, opts ...__ipc.CallOpt) (o0 []byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Echo", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implBenchmarkClientStub) EchoStream(ctx __context.T, opts ...__ipc.CallOpt) (ocall BenchmarkEchoStreamCall, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoStream", nil, opts...); err != nil {
+ return
+ }
+ ocall = &implBenchmarkEchoStreamCall{call, implBenchmarkEchoStreamClientRecv{call: call}, implBenchmarkEchoStreamClientSend{call}}
+ return
+}
+
+func (c implBenchmarkClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implBenchmarkClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// BenchmarkEchoStreamClientStream is the client stream for Benchmark.EchoStream.
+type BenchmarkEchoStreamClientStream interface {
+ // RecvStream returns the receiver side of the client stream.
RecvStream() interface {
- // Advance stages an element so the client can retrieve it
- // with Value. Advance returns true iff there is an
- // element to retrieve. The client must call Advance before
- // calling Value. Advance may block if an element is not
- // immediately available.
+ // Advance stages an item so that it may be retrieved via Value. Returns
+ // true iff there is an item to retrieve. Advance must be called before
+ // Value is called. May block if an item is not available.
Advance() bool
-
- // Value returns the element that was staged by Advance.
- // Value may panic if Advance returned false or was not
- // called at all. Value does not block.
+ // Value returns the item that was staged by Advance. May panic if Advance
+ // returned false or was not called. Never blocks.
Value() []byte
-
- // Err returns a non-nil error iff the stream encountered
- // any errors. Err does not block.
+ // Err returns any error encountered by Advance. Never blocks.
Err() error
}
-
- // SendStream returns the send portion of the stream
+ // SendStream returns the send side of the client stream.
SendStream() interface {
- // Send places the item onto the output stream, blocking if there is no
- // buffer space available. Calls to Send after having called Close
- // or Cancel will fail. Any blocked Send calls will be unblocked upon
- // calling Cancel.
+ // Send places the item onto the output stream. Returns errors encountered
+ // while sending, or if Send is called after Close or Cancel. Blocks if
+ // there is no buffer space; will unblock when buffer space is available or
+ // after Cancel.
Send(item []byte) error
-
- // Close indicates to the server that no more items will be sent;
- // server Recv calls will receive io.EOF after all sent items. This is
- // an optional call - it's used by streaming clients that need the
- // server to receive the io.EOF terminator before the client calls
- // Finish (for example, if the client needs to continue receiving items
- // from the server after having finished sending).
- // Calls to Close after having called Cancel will fail.
- // Like Send, Close blocks when there's no buffer space available.
+ // Close indicates to the server that no more items will be sent; server
+ // Recv calls will receive io.EOF after all sent items. This is an optional
+ // call - e.g. a client might call Close if it needs to continue receiving
+ // items from the server after it's done sending. Returns errors
+ // encountered while closing, or if Close is called after Cancel. Like
+ // Send, blocks if there is no buffer space available.
Close() error
}
+}
- // Finish performs the equivalent of SendStream().Close, then blocks until the server
- // is done, and returns the positional return values for call.
- // If Cancel has been called, Finish will return immediately; the output of
- // Finish could either be an error signalling cancelation, or the correct
- // positional return values from the server depending on the timing of the
- // call.
+// BenchmarkEchoStreamCall represents the call returned from Benchmark.EchoStream.
+type BenchmarkEchoStreamCall interface {
+ BenchmarkEchoStreamClientStream
+ // Finish performs the equivalent of SendStream().Close, then blocks until
+ // the server is done, and returns the positional return values for the call.
+ //
+ // Finish returns immediately if Cancel has been called; depending on the
+ // timing the output could either be an error signaling cancelation, or the
+ // valid positional return values from the server.
//
// Calling Finish is mandatory for releasing stream resources, unless Cancel
- // has been called or any of the other methods return an error.
- // Finish should be called at most once.
- Finish() (err error)
-
- // Cancel cancels the RPC, notifying the server to stop processing. It
- // is safe to call Cancel concurrently with any of the other stream methods.
+ // has been called or any of the other methods return an error. Finish should
+ // be called at most once.
+ Finish() error
+ // Cancel cancels the RPC, notifying the server to stop processing. It is
+ // safe to call Cancel concurrently with any of the other stream methods.
// Calling Cancel after Finish has returned is a no-op.
Cancel()
}
-type implBenchmarkEchoStreamStreamSender struct {
- clientCall _gen_ipc.Call
+type implBenchmarkEchoStreamClientRecv struct {
+ call __ipc.Call
+ val []byte
+ err error
}
-func (c *implBenchmarkEchoStreamStreamSender) Send(item []byte) error {
- return c.clientCall.Send(item)
-}
-
-func (c *implBenchmarkEchoStreamStreamSender) Close() error {
- return c.clientCall.CloseSend()
-}
-
-type implBenchmarkEchoStreamStreamIterator struct {
- clientCall _gen_ipc.Call
- val []byte
- err error
-}
-
-func (c *implBenchmarkEchoStreamStreamIterator) Advance() bool {
- c.err = c.clientCall.Recv(&c.val)
+func (c *implBenchmarkEchoStreamClientRecv) Advance() bool {
+ c.err = c.call.Recv(&c.val)
return c.err == nil
}
-
-func (c *implBenchmarkEchoStreamStreamIterator) Value() []byte {
+func (c *implBenchmarkEchoStreamClientRecv) Value() []byte {
return c.val
}
-
-func (c *implBenchmarkEchoStreamStreamIterator) Err() error {
- if c.err == _gen_io.EOF {
+func (c *implBenchmarkEchoStreamClientRecv) Err() error {
+ if c.err == __io.EOF {
return nil
}
return c.err
}
-// Implementation of the BenchmarkEchoStreamCall interface that is not exported.
-type implBenchmarkEchoStreamCall struct {
- clientCall _gen_ipc.Call
- writeStream implBenchmarkEchoStreamStreamSender
- readStream implBenchmarkEchoStreamStreamIterator
+type implBenchmarkEchoStreamClientSend struct {
+ call __ipc.Call
}
-func (c *implBenchmarkEchoStreamCall) SendStream() interface {
- Send(item []byte) error
- Close() error
-} {
- return &c.writeStream
+func (c *implBenchmarkEchoStreamClientSend) Send(item []byte) error {
+ return c.call.Send(item)
+}
+func (c *implBenchmarkEchoStreamClientSend) Close() error {
+ return c.call.CloseSend()
+}
+
+type implBenchmarkEchoStreamCall struct {
+ call __ipc.Call
+ recv implBenchmarkEchoStreamClientRecv
+ send implBenchmarkEchoStreamClientSend
}
func (c *implBenchmarkEchoStreamCall) RecvStream() interface {
@@ -156,245 +193,91 @@
Value() []byte
Err() error
} {
- return &c.readStream
+ return &c.recv
}
-
+func (c *implBenchmarkEchoStreamCall) SendStream() interface {
+ Send(item []byte) error
+ Close() error
+} {
+ return &c.send
+}
func (c *implBenchmarkEchoStreamCall) Finish() (err error) {
- if ierr := c.clientCall.Finish(&err); ierr != nil {
+ if ierr := c.call.Finish(&err); ierr != nil {
err = ierr
}
return
}
-
func (c *implBenchmarkEchoStreamCall) Cancel() {
- c.clientCall.Cancel()
+ c.call.Cancel()
}
-type implBenchmarkServiceEchoStreamStreamSender struct {
- serverCall _gen_ipc.ServerCall
+// BenchmarkServerMethods is the interface a server writer
+// implements for Benchmark.
+type BenchmarkServerMethods interface {
+ // Echo returns the payload that it receives.
+ Echo(ctx __ipc.ServerContext, Payload []byte) ([]byte, error)
+ // EchoStream returns the payload that it receives via the stream.
+ EchoStream(BenchmarkEchoStreamContext) error
}
-func (s *implBenchmarkServiceEchoStreamStreamSender) Send(item []byte) error {
- return s.serverCall.Send(item)
+// BenchmarkServerStubMethods is the server interface containing
+// Benchmark methods, as expected by ipc.Server. The difference between
+// this interface and BenchmarkServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type BenchmarkServerStubMethods interface {
+ // Echo returns the payload that it receives.
+ Echo(call __ipc.ServerCall, Payload []byte) ([]byte, error)
+ // EchoStream returns the payload that it receives via the stream.
+ EchoStream(__ipc.ServerCall) error
}
-type implBenchmarkServiceEchoStreamStreamIterator struct {
- serverCall _gen_ipc.ServerCall
- val []byte
- err error
+// BenchmarkServerStub adds universal methods to BenchmarkServerStubMethods.
+type BenchmarkServerStub interface {
+ BenchmarkServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
}
-func (s *implBenchmarkServiceEchoStreamStreamIterator) Advance() bool {
- s.err = s.serverCall.Recv(&s.val)
- return s.err == nil
-}
-
-func (s *implBenchmarkServiceEchoStreamStreamIterator) Value() []byte {
- return s.val
-}
-
-func (s *implBenchmarkServiceEchoStreamStreamIterator) Err() error {
- if s.err == _gen_io.EOF {
- return nil
+// BenchmarkServer returns a server stub for Benchmark.
+// It converts an implementation of BenchmarkServerMethods into
+// an object that may be used by ipc.Server.
+func BenchmarkServer(impl BenchmarkServerMethods) BenchmarkServerStub {
+ stub := implBenchmarkServerStub{
+ impl: impl,
}
- return s.err
-}
-
-// BenchmarkServiceEchoStreamStream is the interface for streaming responses of the method
-// EchoStream in the service interface Benchmark.
-type BenchmarkServiceEchoStreamStream interface {
- // SendStream returns the send portion of the stream.
- SendStream() interface {
- // Send places the item onto the output stream, blocking if there is no buffer
- // space available. If the client has canceled, an error is returned.
- Send(item []byte) error
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // RecvStream returns the recv portion of the stream
- RecvStream() interface {
- // Advance stages an element so the client can retrieve it
- // with Value. Advance returns true iff there is an
- // element to retrieve. The client must call Advance before
- // calling Value. Advance may block if an element is not
- // immediately available.
- Advance() bool
-
- // Value returns the element that was staged by Advance.
- // Value may panic if Advance returned false or was not
- // called at all. Value does not block.
- Value() []byte
-
- // Err returns a non-nil error iff the stream encountered
- // any errors. Err does not block.
- Err() error
- }
-}
-
-// Implementation of the BenchmarkServiceEchoStreamStream interface that is not exported.
-type implBenchmarkServiceEchoStreamStream struct {
- writer implBenchmarkServiceEchoStreamStreamSender
- reader implBenchmarkServiceEchoStreamStreamIterator
-}
-
-func (s *implBenchmarkServiceEchoStreamStream) SendStream() interface {
- // Send places the item onto the output stream, blocking if there is no buffer
- // space available. If the client has canceled, an error is returned.
- Send(item []byte) error
-} {
- return &s.writer
-}
-
-func (s *implBenchmarkServiceEchoStreamStream) RecvStream() interface {
- // Advance stages an element so the client can retrieve it
- // with Value. Advance returns true iff there is an
- // element to retrieve. The client must call Advance before
- // calling Value. The client must call Cancel if it does
- // not iterate through all elements (i.e. until Advance
- // returns false). Advance may block if an element is not
- // immediately available.
- Advance() bool
-
- // Value returns the element that was staged by Advance.
- // Value may panic if Advance returned false or was not
- // called at all. Value does not block.
- Value() []byte
-
- // Err returns a non-nil error iff the stream encountered
- // any errors. Err does not block.
- Err() error
-} {
- return &s.reader
-}
-
-// BindBenchmark returns the client stub implementing the Benchmark
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindBenchmark(name string, opts ..._gen_ipc.BindOpt) (Benchmark, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
- client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
- }
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
- }
- stub := &clientStubBenchmark{defaultClient: client, name: name}
-
- return stub, nil
-}
-
-// NewServerBenchmark creates a new server stub.
-//
-// It takes a regular server implementing the BenchmarkService
-// interface, and returns a new server stub.
-func NewServerBenchmark(server BenchmarkService) interface{} {
- stub := &ServerStubBenchmark{
- service: server,
- }
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubBenchmark implements Benchmark.
-type clientStubBenchmark struct {
- defaultClient _gen_ipc.Client
- name string
+type implBenchmarkServerStub struct {
+ impl BenchmarkServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubBenchmark) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implBenchmarkServerStub) Echo(call __ipc.ServerCall, i0 []byte) ([]byte, error) {
+ return s.impl.Echo(call, i0)
}
-func (__gen_c *clientStubBenchmark) Echo(ctx _gen_context.T, Payload []byte, opts ..._gen_ipc.CallOpt) (reply []byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Echo", []interface{}{Payload}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implBenchmarkServerStub) EchoStream(call __ipc.ServerCall) error {
+ ctx := &implBenchmarkEchoStreamContext{call, implBenchmarkEchoStreamServerRecv{call: call}, implBenchmarkEchoStreamServerSend{call}}
+ return s.impl.EchoStream(ctx)
}
-func (__gen_c *clientStubBenchmark) EchoStream(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply BenchmarkEchoStreamCall, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoStream", nil, opts...); err != nil {
- return
- }
- reply = &implBenchmarkEchoStreamCall{clientCall: call, writeStream: implBenchmarkEchoStreamStreamSender{clientCall: call}, readStream: implBenchmarkEchoStreamStreamIterator{clientCall: call}}
- return
+func (s implBenchmarkServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubBenchmark) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubBenchmark) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubBenchmark) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubBenchmark wraps a server that implements
-// BenchmarkService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubBenchmark struct {
- service BenchmarkService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubBenchmark) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implBenchmarkServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Echo":
return []interface{}{}, nil
@@ -405,61 +288,105 @@
}
}
-func (__gen_s *ServerStubBenchmark) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Echo"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implBenchmarkServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Echo"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Payload", Type: 66},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 66},
{Name: "", Type: 67},
},
}
- result.Methods["EchoStream"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoStream"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 67},
},
InStream: 66,
OutStream: 66,
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-func (__gen_s *ServerStubBenchmark) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
+// BenchmarkEchoStreamServerStream is the server stream for Benchmark.EchoStream.
+type BenchmarkEchoStreamServerStream interface {
+ // RecvStream returns the receiver side of the server stream.
+ RecvStream() interface {
+ // Advance stages an item so that it may be retrieved via Value. Returns
+ // true iff there is an item to retrieve. Advance must be called before
+ // Value is called. May block if an item is not available.
+ Advance() bool
+ // Value returns the item that was staged by Advance. May panic if Advance
+ // returned false or was not called. Never blocks.
+ Value() []byte
+ // Err returns any error encountered by Advance. Never blocks.
+ Err() error
}
- if call.Server() == nil {
- return
+ // SendStream returns the send side of the server stream.
+ SendStream() interface {
+ // Send places the item onto the output stream. Returns errors encountered
+ // while sending. Blocks if there is no buffer space; will unblock when
+ // buffer space is available.
+ Send(item []byte) error
}
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
}
-func (__gen_s *ServerStubBenchmark) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
+// BenchmarkEchoStreamContext represents the context passed to Benchmark.EchoStream.
+type BenchmarkEchoStreamContext interface {
+ __ipc.ServerContext
+ BenchmarkEchoStreamServerStream
}
-func (__gen_s *ServerStubBenchmark) Echo(call _gen_ipc.ServerCall, Payload []byte) (reply []byte, err error) {
- reply, err = __gen_s.service.Echo(call, Payload)
- return
+type implBenchmarkEchoStreamServerRecv struct {
+ call __ipc.ServerCall
+ val []byte
+ err error
}
-func (__gen_s *ServerStubBenchmark) EchoStream(call _gen_ipc.ServerCall) (err error) {
- stream := &implBenchmarkServiceEchoStreamStream{reader: implBenchmarkServiceEchoStreamStreamIterator{serverCall: call}, writer: implBenchmarkServiceEchoStreamStreamSender{serverCall: call}}
- err = __gen_s.service.EchoStream(call, stream)
- return
+func (s *implBenchmarkEchoStreamServerRecv) Advance() bool {
+ s.err = s.call.Recv(&s.val)
+ return s.err == nil
+}
+func (s *implBenchmarkEchoStreamServerRecv) Value() []byte {
+ return s.val
+}
+func (s *implBenchmarkEchoStreamServerRecv) Err() error {
+ if s.err == __io.EOF {
+ return nil
+ }
+ return s.err
+}
+
+type implBenchmarkEchoStreamServerSend struct {
+ call __ipc.ServerCall
+}
+
+func (s *implBenchmarkEchoStreamServerSend) Send(item []byte) error {
+ return s.call.Send(item)
+}
+
+type implBenchmarkEchoStreamContext struct {
+ __ipc.ServerContext
+ recv implBenchmarkEchoStreamServerRecv
+ send implBenchmarkEchoStreamServerSend
+}
+
+func (s *implBenchmarkEchoStreamContext) RecvStream() interface {
+ Advance() bool
+ Value() []byte
+ Err() error
+} {
+ return &s.recv
+}
+func (s *implBenchmarkEchoStreamContext) SendStream() interface {
+ Send(item []byte) error
+} {
+ return &s.send
}
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index da85431..8a10577 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -466,7 +466,7 @@
mu sync.Mutex
}
-func (g *GlobbableServer) Glob(ipc.ServerContext, string, mounttable.GlobbableServiceGlobStream) error {
+func (g *GlobbableServer) Glob(mounttable.GlobbableGlobContext, string) error {
g.mu.Lock()
defer g.mu.Unlock()
g.callCount++
@@ -492,7 +492,7 @@
globServer := &GlobbableServer{}
name := naming.JoinAddressName(mts["mt4/foo/bar"].name, "glob")
- runningGlobServer := runServer(t, r, ipc.LeafDispatcher(mounttable.NewServerGlobbable(globServer), nil), name)
+ runningGlobServer := runServer(t, r, ipc.LeafDispatcher(mounttable.GlobbableServer(globServer), nil), name)
defer runningGlobServer.server.Stop()
ns := r.Namespace()
diff --git a/runtimes/google/naming/namespace/resolve.go b/runtimes/google/naming/namespace/resolve.go
index 1d6e572..7d700e9 100644
--- a/runtimes/google/naming/namespace/resolve.go
+++ b/runtimes/google/naming/namespace/resolve.go
@@ -181,6 +181,7 @@
return newNames, unresolveErr
}
+// TODO(caprita): UnresolveStep no longer exists.
func unresolveAgainstServer(ctx context.T, client ipc.Client, names []string) ([]string, error) {
finalErr := errors.New("no servers to unresolve")
for _, name := range names {
diff --git a/runtimes/google/rt/mgmt.go b/runtimes/google/rt/mgmt.go
index a6cac2a..33dc8c2 100644
--- a/runtimes/google/rt/mgmt.go
+++ b/runtimes/google/rt/mgmt.go
@@ -69,7 +69,7 @@
if err != nil {
return err
}
- if err := m.server.Serve("", appcycle.NewServerAppCycle(m), nil); err != nil {
+ if err := m.server.Serve("", appcycle.AppCycleServer(m), nil); err != nil {
return err
}
return m.callbackToParent(parentName, naming.JoinAddressName(ep.String(), ""))
@@ -174,7 +174,7 @@
rt.advanceTask(delta, 0)
}
-func (m *mgmtImpl) Stop(_ ipc.ServerContext, stream appcycle.AppCycleServiceStopStream) error {
+func (m *mgmtImpl) Stop(ctx appcycle.AppCycleStopContext) error {
// The size of the channel should be reasonably sized to expect not to
// miss updates while we're waiting for the stream to unblock.
ch := make(chan veyron2.Task, 10)
@@ -187,7 +187,7 @@
// Channel closed, meaning process shutdown is imminent.
break
}
- stream.Send(task)
+ ctx.SendStream().Send(task)
}
return nil
}
diff --git a/runtimes/google/rt/mgmt_test.go b/runtimes/google/rt/mgmt_test.go
index 002cc2e..512303c 100644
--- a/runtimes/google/rt/mgmt_test.go
+++ b/runtimes/google/rt/mgmt_test.go
@@ -273,14 +273,14 @@
if ep, err = server.Listen(profiles.LocalListenSpec); err != nil {
t.Fatalf("Got error: %v", err)
}
- if err := server.Serve("", node.NewServerConfig(&configServer{ch}), vflag.NewAuthorizerOrDie()); err != nil {
+ if err := server.Serve("", node.ConfigServer(&configServer{ch}), vflag.NewAuthorizerOrDie()); err != nil {
t.Fatalf("Got error: %v", err)
}
return server, naming.JoinAddressName(ep.String(), ""), ch
}
-func setupRemoteAppCycleMgr(t *testing.T) (veyron2.Runtime, modules.Handle, appcycle.AppCycle, func()) {
+func setupRemoteAppCycleMgr(t *testing.T) (veyron2.Runtime, modules.Handle, appcycle.AppCycleClientMethods, func()) {
// We need to use the public API since stubs are used below (and they
// 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
@@ -300,10 +300,7 @@
}
appCycleName := <-ch
- appCycle, err := appcycle.BindAppCycle(appCycleName)
- if err != nil {
- t.Fatalf("Got error: %v", err)
- }
+ appCycle := appcycle.AppCycleClient(appCycleName)
return r, h, appCycle, func() {
configServer.Stop()
sh.Cleanup(os.Stderr, os.Stderr)
diff --git a/security/acl/authorizer_test.go b/security/acl/authorizer_test.go
index 59137b5..f5c88f7 100644
--- a/security/acl/authorizer_test.go
+++ b/security/acl/authorizer_test.go
@@ -208,7 +208,7 @@
}
func methodTags(method string) []interface{} {
- server := &test.ServerStubMyObject{}
+ server := test.MyObjectServer(nil)
tags, _ := server.GetMethodTags(nil, method)
return tags
}
diff --git a/security/acl/test/vdl.vdl.go b/security/acl/test/vdl.vdl.go
index 91e5790..92ed7fb 100644
--- a/security/acl/test/vdl.vdl.go
+++ b/security/acl/test/vdl.vdl.go
@@ -5,15 +5,19 @@
package test
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
+// TODO(toddw): Remove this line once the new signature support is done.
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
+// bootstrap types are used on interfaces.
+const _ = __wiretype.TypeIDInvalid
+
// Any package can define tags (of arbitrary types) to be attached to methods.
// This type can be used to index into a TaggedACLMap.
type MyTag string
@@ -26,201 +30,206 @@
const Execute = MyTag("X")
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
-
+// MyObjectClientMethods is the client interface
+// containing MyObject methods.
+//
// MyObject demonstrates how tags are attached to methods.
-// MyObject is the interface the client binds and uses.
-// MyObject_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type MyObject_ExcludingUniversal interface {
- Get(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error)
- Put(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error)
- Resolve(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error)
- NoTags(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) // No tags attached to this.
- AllTags(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error)
-}
-type MyObject interface {
- _gen_ipc.UniversalServiceMethods
- MyObject_ExcludingUniversal
+type MyObjectClientMethods interface {
+ Get(__context.T, ...__ipc.CallOpt) error
+ Put(__context.T, ...__ipc.CallOpt) error
+ Resolve(__context.T, ...__ipc.CallOpt) error
+ NoTags(__context.T, ...__ipc.CallOpt) error // No tags attached to this.
+ AllTags(__context.T, ...__ipc.CallOpt) error
}
-// MyObjectService is the interface the server implements.
-type MyObjectService interface {
- Get(context _gen_ipc.ServerContext) (err error)
- Put(context _gen_ipc.ServerContext) (err error)
- Resolve(context _gen_ipc.ServerContext) (err error)
- NoTags(context _gen_ipc.ServerContext) (err error) // No tags attached to this.
- AllTags(context _gen_ipc.ServerContext) (err error)
+// MyObjectClientStub adds universal methods to MyObjectClientMethods.
+type MyObjectClientStub interface {
+ MyObjectClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindMyObject returns the client stub implementing the MyObject
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindMyObject(name string, opts ..._gen_ipc.BindOpt) (MyObject, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// MyObjectClient returns a client stub for MyObject.
+func MyObjectClient(name string, opts ...__ipc.BindOpt) MyObjectClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubMyObject{defaultClient: client, name: name}
-
- return stub, nil
+ return implMyObjectClientStub{name, client}
}
-// NewServerMyObject creates a new server stub.
+type implMyObjectClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implMyObjectClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implMyObjectClientStub) Get(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Get", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMyObjectClientStub) Put(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Put", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMyObjectClientStub) Resolve(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Resolve", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMyObjectClientStub) NoTags(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "NoTags", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMyObjectClientStub) AllTags(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "AllTags", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMyObjectClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMyObjectClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// MyObjectServerMethods is the interface a server writer
+// implements for MyObject.
//
-// It takes a regular server implementing the MyObjectService
-// interface, and returns a new server stub.
-func NewServerMyObject(server MyObjectService) interface{} {
- stub := &ServerStubMyObject{
- service: server,
+// MyObject demonstrates how tags are attached to methods.
+type MyObjectServerMethods interface {
+ Get(__ipc.ServerContext) error
+ Put(__ipc.ServerContext) error
+ Resolve(__ipc.ServerContext) error
+ NoTags(__ipc.ServerContext) error // No tags attached to this.
+ AllTags(__ipc.ServerContext) error
+}
+
+// MyObjectServerStubMethods is the server interface containing
+// MyObject methods, as expected by ipc.Server. The difference between
+// this interface and MyObjectServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type MyObjectServerStubMethods interface {
+ Get(__ipc.ServerCall) error
+ Put(__ipc.ServerCall) error
+ Resolve(__ipc.ServerCall) error
+ NoTags(__ipc.ServerCall) error // No tags attached to this.
+ AllTags(__ipc.ServerCall) error
+}
+
+// MyObjectServerStub adds universal methods to MyObjectServerStubMethods.
+type MyObjectServerStub interface {
+ MyObjectServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// MyObjectServer returns a server stub for MyObject.
+// It converts an implementation of MyObjectServerMethods into
+// an object that may be used by ipc.Server.
+func MyObjectServer(impl MyObjectServerMethods) MyObjectServerStub {
+ stub := implMyObjectServerStub{
+ impl: impl,
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubMyObject implements MyObject.
-type clientStubMyObject struct {
- defaultClient _gen_ipc.Client
- name string
+type implMyObjectServerStub struct {
+ impl MyObjectServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubMyObject) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implMyObjectServerStub) Get(call __ipc.ServerCall) error {
+ return s.impl.Get(call)
}
-func (__gen_c *clientStubMyObject) Get(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Get", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implMyObjectServerStub) Put(call __ipc.ServerCall) error {
+ return s.impl.Put(call)
}
-func (__gen_c *clientStubMyObject) Put(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Put", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implMyObjectServerStub) Resolve(call __ipc.ServerCall) error {
+ return s.impl.Resolve(call)
}
-func (__gen_c *clientStubMyObject) Resolve(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Resolve", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implMyObjectServerStub) NoTags(call __ipc.ServerCall) error {
+ return s.impl.NoTags(call)
}
-func (__gen_c *clientStubMyObject) NoTags(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "NoTags", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implMyObjectServerStub) AllTags(call __ipc.ServerCall) error {
+ return s.impl.AllTags(call)
}
-func (__gen_c *clientStubMyObject) AllTags(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "AllTags", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implMyObjectServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubMyObject) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubMyObject) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubMyObject) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubMyObject wraps a server that implements
-// MyObjectService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubMyObject struct {
- service MyObjectService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubMyObject) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implMyObjectServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Get":
return []interface{}{MyTag("R")}, nil
@@ -237,88 +246,42 @@
}
}
-func (__gen_s *ServerStubMyObject) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["AllTags"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+func (s implMyObjectServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["AllTags"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.Methods["Get"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Get"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.Methods["NoTags"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["NoTags"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.Methods["Put"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Put"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.Methods["Resolve"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Resolve"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubMyObject) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubMyObject) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubMyObject) Get(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.Get(call)
- return
-}
-
-func (__gen_s *ServerStubMyObject) Put(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.Put(call)
- return
-}
-
-func (__gen_s *ServerStubMyObject) Resolve(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.Resolve(call)
- return
-}
-
-func (__gen_s *ServerStubMyObject) NoTags(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.NoTags(call)
- return
-}
-
-func (__gen_s *ServerStubMyObject) AllTags(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.AllTags(call)
- return
-}
diff --git a/security/agent/pingpong/main.go b/security/agent/pingpong/main.go
index 1fa34fb..e09ef7b 100644
--- a/security/agent/pingpong/main.go
+++ b/security/agent/pingpong/main.go
@@ -26,11 +26,7 @@
log := runtime.Logger()
log.Info("Pinging...")
- s, err := BindPingPong("pingpong")
- if err != nil {
- log.Fatal("error binding to server: ", err)
- }
-
+ s := PingPongClient("pingpong")
pong, err := s.Ping(runtime.NewContext(), "ping")
if err != nil {
log.Fatal("error pinging: ", err)
@@ -47,7 +43,7 @@
}
log.Info("Waiting for ping")
- serverPong := NewServerPingPong(&pongd{})
+ serverPong := PingPongServer(&pongd{})
if endpoint, err := s.Listen(ipc.ListenSpec{Protocol: "tcp", Address: "127.0.0.1:0"}); err == nil {
fmt.Printf("Listening at: %v\n", endpoint)
diff --git a/security/agent/pingpong/wire.vdl.go b/security/agent/pingpong/wire.vdl.go
index 35862ff..5b969bd 100644
--- a/security/agent/pingpong/wire.vdl.go
+++ b/security/agent/pingpong/wire.vdl.go
@@ -4,158 +4,147 @@
package main
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// PingPongClientMethods is the client interface
+// containing PingPong methods.
+//
// Simple service used in the agent tests.
-// PingPong is the interface the client binds and uses.
-// PingPong_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type PingPong_ExcludingUniversal interface {
- Ping(ctx _gen_context.T, message string, opts ..._gen_ipc.CallOpt) (reply string, err error)
-}
-type PingPong interface {
- _gen_ipc.UniversalServiceMethods
- PingPong_ExcludingUniversal
+type PingPongClientMethods interface {
+ Ping(ctx __context.T, message string, opts ...__ipc.CallOpt) (string, error)
}
-// PingPongService is the interface the server implements.
-type PingPongService interface {
- Ping(context _gen_ipc.ServerContext, message string) (reply string, err error)
+// PingPongClientStub adds universal methods to PingPongClientMethods.
+type PingPongClientStub interface {
+ PingPongClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindPingPong returns the client stub implementing the PingPong
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindPingPong(name string, opts ..._gen_ipc.BindOpt) (PingPong, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// PingPongClient returns a client stub for PingPong.
+func PingPongClient(name string, opts ...__ipc.BindOpt) PingPongClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubPingPong{defaultClient: client, name: name}
-
- return stub, nil
+ return implPingPongClientStub{name, client}
}
-// NewServerPingPong creates a new server stub.
+type implPingPongClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implPingPongClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implPingPongClientStub) Ping(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (o0 string, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Ping", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implPingPongClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implPingPongClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// PingPongServerMethods is the interface a server writer
+// implements for PingPong.
//
-// It takes a regular server implementing the PingPongService
-// interface, and returns a new server stub.
-func NewServerPingPong(server PingPongService) interface{} {
- stub := &ServerStubPingPong{
- service: server,
+// Simple service used in the agent tests.
+type PingPongServerMethods interface {
+ Ping(ctx __ipc.ServerContext, message string) (string, error)
+}
+
+// PingPongServerStubMethods is the server interface containing
+// PingPong methods, as expected by ipc.Server. The difference between
+// this interface and PingPongServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type PingPongServerStubMethods interface {
+ Ping(call __ipc.ServerCall, message string) (string, error)
+}
+
+// PingPongServerStub adds universal methods to PingPongServerStubMethods.
+type PingPongServerStub interface {
+ PingPongServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// PingPongServer returns a server stub for PingPong.
+// It converts an implementation of PingPongServerMethods into
+// an object that may be used by ipc.Server.
+func PingPongServer(impl PingPongServerMethods) PingPongServerStub {
+ stub := implPingPongServerStub{
+ impl: impl,
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubPingPong implements PingPong.
-type clientStubPingPong struct {
- defaultClient _gen_ipc.Client
- name string
+type implPingPongServerStub struct {
+ impl PingPongServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubPingPong) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implPingPongServerStub) Ping(call __ipc.ServerCall, i0 string) (string, error) {
+ return s.impl.Ping(call, i0)
}
-func (__gen_c *clientStubPingPong) Ping(ctx _gen_context.T, message string, opts ..._gen_ipc.CallOpt) (reply string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Ping", []interface{}{message}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implPingPongServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubPingPong) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubPingPong) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubPingPong) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubPingPong wraps a server that implements
-// PingPongService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubPingPong struct {
- service PingPongService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubPingPong) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implPingPongServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Ping":
return []interface{}{}, nil
@@ -164,47 +153,21 @@
}
}
-func (__gen_s *ServerStubPingPong) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Ping"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implPingPongServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Ping"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "message", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 3},
{Name: "", Type: 65},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubPingPong) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubPingPong) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubPingPong) Ping(call _gen_ipc.ServerCall, message string) (reply string, err error) {
- reply, err = __gen_s.service.Ping(call, message)
- return
-}
diff --git a/security/agent/server/server.go b/security/agent/server/server.go
index 9cfb422..a59effb 100644
--- a/security/agent/server/server.go
+++ b/security/agent/server/server.go
@@ -170,7 +170,7 @@
func startAgent(conn *net.UnixConn, runtime veyron2.Runtime, principal security.Principal) error {
agent := &agentd{principal: principal}
- serverAgent := NewServerAgent(agent)
+ serverAgent := AgentServer(agent)
go func() {
buf := make([]byte, 1)
for {
diff --git a/security/agent/server/wire.vdl.go b/security/agent/server/wire.vdl.go
index 2870d8e..dbc8646 100644
--- a/security/agent/server/wire.vdl.go
+++ b/security/agent/server/wire.vdl.go
@@ -6,326 +6,377 @@
import (
"veyron.io/veyron/veyron2/security"
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
-// Agent is the interface the client binds and uses.
-// Agent_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Agent_ExcludingUniversal interface {
- Bless(ctx _gen_context.T, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error)
- BlessSelf(ctx _gen_context.T, name string, caveats []security.Caveat, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error)
- Sign(ctx _gen_context.T, message []byte, opts ..._gen_ipc.CallOpt) (reply security.Signature, err error)
- MintDischarge(ctx _gen_context.T, tp _gen_vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat, opts ..._gen_ipc.CallOpt) (reply _gen_vdlutil.Any, err error)
- PublicKey(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []byte, err error)
- AddToRoots(ctx _gen_context.T, blessing security.WireBlessings, opts ..._gen_ipc.CallOpt) (err error)
- BlessingStoreSet(ctx _gen_context.T, blessings security.WireBlessings, forPeers security.BlessingPattern, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error)
- BlessingStoreForPeer(ctx _gen_context.T, peerBlessings []string, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error)
- BlessingStoreSetDefault(ctx _gen_context.T, blessings security.WireBlessings, opts ..._gen_ipc.CallOpt) (err error)
- BlessingStoreDefault(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error)
- BlessingStoreDebugString(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply string, err error)
- BlessingRootsAdd(ctx _gen_context.T, root []byte, pattern security.BlessingPattern, opts ..._gen_ipc.CallOpt) (err error)
- BlessingRootsRecognized(ctx _gen_context.T, root []byte, blessing string, opts ..._gen_ipc.CallOpt) (err error)
- BlessingRootsDebugString(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply string, err error)
-}
-type Agent interface {
- _gen_ipc.UniversalServiceMethods
- Agent_ExcludingUniversal
+// AgentClientMethods is the client interface
+// containing Agent methods.
+type AgentClientMethods interface {
+ Bless(ctx __context.T, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat, opts ...__ipc.CallOpt) (security.WireBlessings, error)
+ BlessSelf(ctx __context.T, name string, caveats []security.Caveat, opts ...__ipc.CallOpt) (security.WireBlessings, error)
+ Sign(ctx __context.T, message []byte, opts ...__ipc.CallOpt) (security.Signature, error)
+ MintDischarge(ctx __context.T, tp __vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat, opts ...__ipc.CallOpt) (__vdlutil.Any, error)
+ PublicKey(__context.T, ...__ipc.CallOpt) ([]byte, error)
+ AddToRoots(ctx __context.T, blessing security.WireBlessings, opts ...__ipc.CallOpt) error
+ BlessingStoreSet(ctx __context.T, blessings security.WireBlessings, forPeers security.BlessingPattern, opts ...__ipc.CallOpt) (security.WireBlessings, error)
+ BlessingStoreForPeer(ctx __context.T, peerBlessings []string, opts ...__ipc.CallOpt) (security.WireBlessings, error)
+ BlessingStoreSetDefault(ctx __context.T, blessings security.WireBlessings, opts ...__ipc.CallOpt) error
+ BlessingStoreDefault(__context.T, ...__ipc.CallOpt) (security.WireBlessings, error)
+ BlessingStoreDebugString(__context.T, ...__ipc.CallOpt) (string, error)
+ BlessingRootsAdd(ctx __context.T, root []byte, pattern security.BlessingPattern, opts ...__ipc.CallOpt) error
+ BlessingRootsRecognized(ctx __context.T, root []byte, blessing string, opts ...__ipc.CallOpt) error
+ BlessingRootsDebugString(__context.T, ...__ipc.CallOpt) (string, error)
}
-// AgentService is the interface the server implements.
-type AgentService interface {
- Bless(context _gen_ipc.ServerContext, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat) (reply security.WireBlessings, err error)
- BlessSelf(context _gen_ipc.ServerContext, name string, caveats []security.Caveat) (reply security.WireBlessings, err error)
- Sign(context _gen_ipc.ServerContext, message []byte) (reply security.Signature, err error)
- MintDischarge(context _gen_ipc.ServerContext, tp _gen_vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat) (reply _gen_vdlutil.Any, err error)
- PublicKey(context _gen_ipc.ServerContext) (reply []byte, err error)
- AddToRoots(context _gen_ipc.ServerContext, blessing security.WireBlessings) (err error)
- BlessingStoreSet(context _gen_ipc.ServerContext, blessings security.WireBlessings, forPeers security.BlessingPattern) (reply security.WireBlessings, err error)
- BlessingStoreForPeer(context _gen_ipc.ServerContext, peerBlessings []string) (reply security.WireBlessings, err error)
- BlessingStoreSetDefault(context _gen_ipc.ServerContext, blessings security.WireBlessings) (err error)
- BlessingStoreDefault(context _gen_ipc.ServerContext) (reply security.WireBlessings, err error)
- BlessingStoreDebugString(context _gen_ipc.ServerContext) (reply string, err error)
- BlessingRootsAdd(context _gen_ipc.ServerContext, root []byte, pattern security.BlessingPattern) (err error)
- BlessingRootsRecognized(context _gen_ipc.ServerContext, root []byte, blessing string) (err error)
- BlessingRootsDebugString(context _gen_ipc.ServerContext) (reply string, err error)
+// AgentClientStub adds universal methods to AgentClientMethods.
+type AgentClientStub interface {
+ AgentClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindAgent returns the client stub implementing the Agent
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindAgent(name string, opts ..._gen_ipc.BindOpt) (Agent, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// AgentClient returns a client stub for Agent.
+func AgentClient(name string, opts ...__ipc.BindOpt) AgentClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubAgent{defaultClient: client, name: name}
-
- return stub, nil
+ return implAgentClientStub{name, client}
}
-// NewServerAgent creates a new server stub.
-//
-// It takes a regular server implementing the AgentService
-// interface, and returns a new server stub.
-func NewServerAgent(server AgentService) interface{} {
- stub := &ServerStubAgent{
- service: server,
+type implAgentClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implAgentClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implAgentClientStub) Bless(ctx __context.T, i0 []byte, i1 security.WireBlessings, i2 string, i3 security.Caveat, i4 []security.Caveat, opts ...__ipc.CallOpt) (o0 security.WireBlessings, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Bless", []interface{}{i0, i1, i2, i3, i4}, opts...); err != nil {
+ return
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
}
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
+ return
+}
+
+func (c implAgentClientStub) BlessSelf(ctx __context.T, i0 string, i1 []security.Caveat, opts ...__ipc.CallOpt) (o0 security.WireBlessings, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessSelf", []interface{}{i0, i1}, opts...); err != nil {
+ return
}
- stub.gs = &gs
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) Sign(ctx __context.T, i0 []byte, opts ...__ipc.CallOpt) (o0 security.Signature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Sign", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) MintDischarge(ctx __context.T, i0 __vdlutil.Any, i1 security.Caveat, i2 []security.Caveat, opts ...__ipc.CallOpt) (o0 __vdlutil.Any, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "MintDischarge", []interface{}{i0, i1, i2}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) PublicKey(ctx __context.T, opts ...__ipc.CallOpt) (o0 []byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "PublicKey", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) AddToRoots(ctx __context.T, i0 security.WireBlessings, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "AddToRoots", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingStoreSet(ctx __context.T, i0 security.WireBlessings, i1 security.BlessingPattern, opts ...__ipc.CallOpt) (o0 security.WireBlessings, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingStoreSet", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingStoreForPeer(ctx __context.T, i0 []string, opts ...__ipc.CallOpt) (o0 security.WireBlessings, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingStoreForPeer", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingStoreSetDefault(ctx __context.T, i0 security.WireBlessings, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingStoreSetDefault", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingStoreDefault(ctx __context.T, opts ...__ipc.CallOpt) (o0 security.WireBlessings, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingStoreDefault", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingStoreDebugString(ctx __context.T, opts ...__ipc.CallOpt) (o0 string, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingStoreDebugString", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingRootsAdd(ctx __context.T, i0 []byte, i1 security.BlessingPattern, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingRootsAdd", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingRootsRecognized(ctx __context.T, i0 []byte, i1 string, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingRootsRecognized", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) BlessingRootsDebugString(ctx __context.T, opts ...__ipc.CallOpt) (o0 string, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessingRootsDebugString", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implAgentClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// AgentServerMethods is the interface a server writer
+// implements for Agent.
+type AgentServerMethods interface {
+ Bless(ctx __ipc.ServerContext, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat) (security.WireBlessings, error)
+ BlessSelf(ctx __ipc.ServerContext, name string, caveats []security.Caveat) (security.WireBlessings, error)
+ Sign(ctx __ipc.ServerContext, message []byte) (security.Signature, error)
+ MintDischarge(ctx __ipc.ServerContext, tp __vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat) (__vdlutil.Any, error)
+ PublicKey(__ipc.ServerContext) ([]byte, error)
+ AddToRoots(ctx __ipc.ServerContext, blessing security.WireBlessings) error
+ BlessingStoreSet(ctx __ipc.ServerContext, blessings security.WireBlessings, forPeers security.BlessingPattern) (security.WireBlessings, error)
+ BlessingStoreForPeer(ctx __ipc.ServerContext, peerBlessings []string) (security.WireBlessings, error)
+ BlessingStoreSetDefault(ctx __ipc.ServerContext, blessings security.WireBlessings) error
+ BlessingStoreDefault(__ipc.ServerContext) (security.WireBlessings, error)
+ BlessingStoreDebugString(__ipc.ServerContext) (string, error)
+ BlessingRootsAdd(ctx __ipc.ServerContext, root []byte, pattern security.BlessingPattern) error
+ BlessingRootsRecognized(ctx __ipc.ServerContext, root []byte, blessing string) error
+ BlessingRootsDebugString(__ipc.ServerContext) (string, error)
+}
+
+// AgentServerStubMethods is the server interface containing
+// Agent methods, as expected by ipc.Server. The difference between
+// this interface and AgentServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type AgentServerStubMethods interface {
+ Bless(call __ipc.ServerCall, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat) (security.WireBlessings, error)
+ BlessSelf(call __ipc.ServerCall, name string, caveats []security.Caveat) (security.WireBlessings, error)
+ Sign(call __ipc.ServerCall, message []byte) (security.Signature, error)
+ MintDischarge(call __ipc.ServerCall, tp __vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat) (__vdlutil.Any, error)
+ PublicKey(__ipc.ServerCall) ([]byte, error)
+ AddToRoots(call __ipc.ServerCall, blessing security.WireBlessings) error
+ BlessingStoreSet(call __ipc.ServerCall, blessings security.WireBlessings, forPeers security.BlessingPattern) (security.WireBlessings, error)
+ BlessingStoreForPeer(call __ipc.ServerCall, peerBlessings []string) (security.WireBlessings, error)
+ BlessingStoreSetDefault(call __ipc.ServerCall, blessings security.WireBlessings) error
+ BlessingStoreDefault(__ipc.ServerCall) (security.WireBlessings, error)
+ BlessingStoreDebugString(__ipc.ServerCall) (string, error)
+ BlessingRootsAdd(call __ipc.ServerCall, root []byte, pattern security.BlessingPattern) error
+ BlessingRootsRecognized(call __ipc.ServerCall, root []byte, blessing string) error
+ BlessingRootsDebugString(__ipc.ServerCall) (string, error)
+}
+
+// AgentServerStub adds universal methods to AgentServerStubMethods.
+type AgentServerStub interface {
+ AgentServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// AgentServer returns a server stub for Agent.
+// It converts an implementation of AgentServerMethods into
+// an object that may be used by ipc.Server.
+func AgentServer(impl AgentServerMethods) AgentServerStub {
+ stub := implAgentServerStub{
+ impl: impl,
+ }
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
+ }
return stub
}
-// clientStubAgent implements Agent.
-type clientStubAgent struct {
- defaultClient _gen_ipc.Client
- name string
+type implAgentServerStub struct {
+ impl AgentServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubAgent) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implAgentServerStub) Bless(call __ipc.ServerCall, i0 []byte, i1 security.WireBlessings, i2 string, i3 security.Caveat, i4 []security.Caveat) (security.WireBlessings, error) {
+ return s.impl.Bless(call, i0, i1, i2, i3, i4)
}
-func (__gen_c *clientStubAgent) Bless(ctx _gen_context.T, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Bless", []interface{}{key, wit, extension, caveat, additionalCaveats}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessSelf(call __ipc.ServerCall, i0 string, i1 []security.Caveat) (security.WireBlessings, error) {
+ return s.impl.BlessSelf(call, i0, i1)
}
-func (__gen_c *clientStubAgent) BlessSelf(ctx _gen_context.T, name string, caveats []security.Caveat, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessSelf", []interface{}{name, caveats}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) Sign(call __ipc.ServerCall, i0 []byte) (security.Signature, error) {
+ return s.impl.Sign(call, i0)
}
-func (__gen_c *clientStubAgent) Sign(ctx _gen_context.T, message []byte, opts ..._gen_ipc.CallOpt) (reply security.Signature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Sign", []interface{}{message}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) MintDischarge(call __ipc.ServerCall, i0 __vdlutil.Any, i1 security.Caveat, i2 []security.Caveat) (__vdlutil.Any, error) {
+ return s.impl.MintDischarge(call, i0, i1, i2)
}
-func (__gen_c *clientStubAgent) MintDischarge(ctx _gen_context.T, tp _gen_vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat, opts ..._gen_ipc.CallOpt) (reply _gen_vdlutil.Any, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "MintDischarge", []interface{}{tp, caveat, additionalCaveats}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) PublicKey(call __ipc.ServerCall) ([]byte, error) {
+ return s.impl.PublicKey(call)
}
-func (__gen_c *clientStubAgent) PublicKey(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "PublicKey", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) AddToRoots(call __ipc.ServerCall, i0 security.WireBlessings) error {
+ return s.impl.AddToRoots(call, i0)
}
-func (__gen_c *clientStubAgent) AddToRoots(ctx _gen_context.T, blessing security.WireBlessings, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "AddToRoots", []interface{}{blessing}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingStoreSet(call __ipc.ServerCall, i0 security.WireBlessings, i1 security.BlessingPattern) (security.WireBlessings, error) {
+ return s.impl.BlessingStoreSet(call, i0, i1)
}
-func (__gen_c *clientStubAgent) BlessingStoreSet(ctx _gen_context.T, blessings security.WireBlessings, forPeers security.BlessingPattern, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingStoreSet", []interface{}{blessings, forPeers}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingStoreForPeer(call __ipc.ServerCall, i0 []string) (security.WireBlessings, error) {
+ return s.impl.BlessingStoreForPeer(call, i0)
}
-func (__gen_c *clientStubAgent) BlessingStoreForPeer(ctx _gen_context.T, peerBlessings []string, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingStoreForPeer", []interface{}{peerBlessings}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingStoreSetDefault(call __ipc.ServerCall, i0 security.WireBlessings) error {
+ return s.impl.BlessingStoreSetDefault(call, i0)
}
-func (__gen_c *clientStubAgent) BlessingStoreSetDefault(ctx _gen_context.T, blessings security.WireBlessings, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingStoreSetDefault", []interface{}{blessings}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingStoreDefault(call __ipc.ServerCall) (security.WireBlessings, error) {
+ return s.impl.BlessingStoreDefault(call)
}
-func (__gen_c *clientStubAgent) BlessingStoreDefault(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingStoreDefault", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingStoreDebugString(call __ipc.ServerCall) (string, error) {
+ return s.impl.BlessingStoreDebugString(call)
}
-func (__gen_c *clientStubAgent) BlessingStoreDebugString(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingStoreDebugString", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingRootsAdd(call __ipc.ServerCall, i0 []byte, i1 security.BlessingPattern) error {
+ return s.impl.BlessingRootsAdd(call, i0, i1)
}
-func (__gen_c *clientStubAgent) BlessingRootsAdd(ctx _gen_context.T, root []byte, pattern security.BlessingPattern, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingRootsAdd", []interface{}{root, pattern}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingRootsRecognized(call __ipc.ServerCall, i0 []byte, i1 string) error {
+ return s.impl.BlessingRootsRecognized(call, i0, i1)
}
-func (__gen_c *clientStubAgent) BlessingRootsRecognized(ctx _gen_context.T, root []byte, blessing string, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingRootsRecognized", []interface{}{root, blessing}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) BlessingRootsDebugString(call __ipc.ServerCall) (string, error) {
+ return s.impl.BlessingRootsDebugString(call)
}
-func (__gen_c *clientStubAgent) BlessingRootsDebugString(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessingRootsDebugString", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implAgentServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubAgent) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubAgent) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubAgent) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubAgent wraps a server that implements
-// AgentService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubAgent struct {
- service AgentService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubAgent) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implAgentServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Bless":
return []interface{}{}, nil
@@ -360,253 +411,162 @@
}
}
-func (__gen_s *ServerStubAgent) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["AddToRoots"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implAgentServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["AddToRoots"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "blessing", Type: 74},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 75},
},
}
- result.Methods["Bless"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Bless"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "key", Type: 66},
{Name: "wit", Type: 74},
{Name: "extension", Type: 3},
{Name: "caveat", Type: 67},
{Name: "additionalCaveats", Type: 68},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 74},
{Name: "", Type: 75},
},
}
- result.Methods["BlessSelf"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessSelf"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "name", Type: 3},
{Name: "caveats", Type: 68},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 74},
{Name: "", Type: 75},
},
}
- result.Methods["BlessingRootsAdd"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingRootsAdd"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "root", Type: 66},
{Name: "pattern", Type: 77},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 75},
},
}
- result.Methods["BlessingRootsDebugString"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingRootsDebugString"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 3},
{Name: "", Type: 75},
},
}
- result.Methods["BlessingRootsRecognized"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingRootsRecognized"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "root", Type: 66},
{Name: "blessing", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 75},
},
}
- result.Methods["BlessingStoreDebugString"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingStoreDebugString"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 3},
{Name: "", Type: 75},
},
}
- result.Methods["BlessingStoreDefault"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingStoreDefault"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 74},
{Name: "", Type: 75},
},
}
- result.Methods["BlessingStoreForPeer"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingStoreForPeer"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "peerBlessings", Type: 61},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 74},
{Name: "", Type: 75},
},
}
- result.Methods["BlessingStoreSet"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingStoreSet"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "blessings", Type: 74},
{Name: "forPeers", Type: 77},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 74},
{Name: "", Type: 75},
},
}
- result.Methods["BlessingStoreSetDefault"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["BlessingStoreSetDefault"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "blessings", Type: 74},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 75},
},
}
- result.Methods["MintDischarge"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["MintDischarge"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "tp", Type: 76},
{Name: "caveat", Type: 67},
{Name: "additionalCaveats", Type: 68},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 76},
{Name: "", Type: 75},
},
}
- result.Methods["PublicKey"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["PublicKey"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 66},
{Name: "", Type: 75},
},
}
- result.Methods["Sign"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Sign"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "message", Type: 66},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 70},
{Name: "", Type: 75},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
},
"veyron.io/veyron/veyron2/security.Caveat", []string(nil)},
- _gen_wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.Hash", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x42, Name: "Purpose"},
- _gen_wiretype.FieldType{Type: 0x45, Name: "Hash"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "R"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "S"},
+ __wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.Hash", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x42, Name: "Purpose"},
+ __wiretype.FieldType{Type: 0x45, Name: "Hash"},
+ __wiretype.FieldType{Type: 0x42, Name: "R"},
+ __wiretype.FieldType{Type: 0x42, Name: "S"},
},
"veyron.io/veyron/veyron2/security.Signature", []string(nil)},
- _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x3, Name: "Extension"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
- _gen_wiretype.FieldType{Type: 0x44, Name: "Caveats"},
- _gen_wiretype.FieldType{Type: 0x46, Name: "Signature"},
+ __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x3, Name: "Extension"},
+ __wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
+ __wiretype.FieldType{Type: 0x44, Name: "Caveats"},
+ __wiretype.FieldType{Type: 0x46, Name: "Signature"},
},
"veyron.io/veyron/veyron2/security.Certificate", []string(nil)},
- _gen_wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
+ __wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
},
"veyron.io/veyron/veyron2/security.WireBlessings", []string(nil)},
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.BlessingPattern", Tags: []string(nil)}}
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.BlessingPattern", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubAgent) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubAgent) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubAgent) Bless(call _gen_ipc.ServerCall, key []byte, wit security.WireBlessings, extension string, caveat security.Caveat, additionalCaveats []security.Caveat) (reply security.WireBlessings, err error) {
- reply, err = __gen_s.service.Bless(call, key, wit, extension, caveat, additionalCaveats)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessSelf(call _gen_ipc.ServerCall, name string, caveats []security.Caveat) (reply security.WireBlessings, err error) {
- reply, err = __gen_s.service.BlessSelf(call, name, caveats)
- return
-}
-
-func (__gen_s *ServerStubAgent) Sign(call _gen_ipc.ServerCall, message []byte) (reply security.Signature, err error) {
- reply, err = __gen_s.service.Sign(call, message)
- return
-}
-
-func (__gen_s *ServerStubAgent) MintDischarge(call _gen_ipc.ServerCall, tp _gen_vdlutil.Any, caveat security.Caveat, additionalCaveats []security.Caveat) (reply _gen_vdlutil.Any, err error) {
- reply, err = __gen_s.service.MintDischarge(call, tp, caveat, additionalCaveats)
- return
-}
-
-func (__gen_s *ServerStubAgent) PublicKey(call _gen_ipc.ServerCall) (reply []byte, err error) {
- reply, err = __gen_s.service.PublicKey(call)
- return
-}
-
-func (__gen_s *ServerStubAgent) AddToRoots(call _gen_ipc.ServerCall, blessing security.WireBlessings) (err error) {
- err = __gen_s.service.AddToRoots(call, blessing)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingStoreSet(call _gen_ipc.ServerCall, blessings security.WireBlessings, forPeers security.BlessingPattern) (reply security.WireBlessings, err error) {
- reply, err = __gen_s.service.BlessingStoreSet(call, blessings, forPeers)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingStoreForPeer(call _gen_ipc.ServerCall, peerBlessings []string) (reply security.WireBlessings, err error) {
- reply, err = __gen_s.service.BlessingStoreForPeer(call, peerBlessings)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingStoreSetDefault(call _gen_ipc.ServerCall, blessings security.WireBlessings) (err error) {
- err = __gen_s.service.BlessingStoreSetDefault(call, blessings)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingStoreDefault(call _gen_ipc.ServerCall) (reply security.WireBlessings, err error) {
- reply, err = __gen_s.service.BlessingStoreDefault(call)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingStoreDebugString(call _gen_ipc.ServerCall) (reply string, err error) {
- reply, err = __gen_s.service.BlessingStoreDebugString(call)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingRootsAdd(call _gen_ipc.ServerCall, root []byte, pattern security.BlessingPattern) (err error) {
- err = __gen_s.service.BlessingRootsAdd(call, root, pattern)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingRootsRecognized(call _gen_ipc.ServerCall, root []byte, blessing string) (err error) {
- err = __gen_s.service.BlessingRootsRecognized(call, root, blessing)
- return
-}
-
-func (__gen_s *ServerStubAgent) BlessingRootsDebugString(call _gen_ipc.ServerCall) (reply string, err error) {
- reply, err = __gen_s.service.BlessingRootsDebugString(call)
- return
-}
diff --git a/services/identity/blesser/macaroon.go b/services/identity/blesser/macaroon.go
index 6517ab2..04611d0 100644
--- a/services/identity/blesser/macaroon.go
+++ b/services/identity/blesser/macaroon.go
@@ -26,8 +26,8 @@
// NewMacaroonBlesserServer provides an identity.MacaroonBlesser Service that generates blessings
// after unpacking a BlessingMacaroon.
-func NewMacaroonBlesserServer(key []byte) interface{} {
- return identity.NewServerMacaroonBlesser(&macaroonBlesser{key})
+func NewMacaroonBlesserServer(key []byte) identity.MacaroonBlesserServerStub {
+ return identity.MacaroonBlesserServer(&macaroonBlesser{key})
}
func (b *macaroonBlesser) Bless(ctx ipc.ServerContext, macaroon string) (security.WireBlessings, error) {
diff --git a/services/identity/blesser/macaroon_test.go b/services/identity/blesser/macaroon_test.go
index 2792efa..2aa9e3e 100644
--- a/services/identity/blesser/macaroon_test.go
+++ b/services/identity/blesser/macaroon_test.go
@@ -8,7 +8,6 @@
"time"
vsecurity "veyron.io/veyron/veyron/security"
- "veyron.io/veyron/veyron/services/identity"
"veyron.io/veyron/veyron/services/identity/util"
"veyron.io/veyron/veyron2/ipc"
@@ -30,7 +29,7 @@
if _, err := rand.Read(key); err != nil {
t.Fatal(err)
}
- blesser := NewMacaroonBlesserServer(key).(*identity.ServerStubMacaroonBlesser)
+ blesser := NewMacaroonBlesserServer(key)
m := BlessingMacaroon{Creation: time.Now().Add(-1 * time.Hour), Name: "foo"}
if got, err := blesser.Bless(context, newMacaroon(t, key, m)); err == nil || err.Error() != "macaroon has expired" {
diff --git a/services/identity/blesser/oauth.go b/services/identity/blesser/oauth.go
index 7062c13..7b59171 100644
--- a/services/identity/blesser/oauth.go
+++ b/services/identity/blesser/oauth.go
@@ -54,7 +54,7 @@
// Blessings generated by this server expire after duration. If domain is non-empty, then blessings
// are generated only for email addresses from that domain.
func NewGoogleOAuthBlesserServer(p GoogleParams) interface{} {
- return identity.NewServerOAuthBlesser(&googleOAuth{
+ return identity.OAuthBlesserServer(&googleOAuth{
duration: p.BlessingDuration,
domain: p.DomainRestriction,
dischargerLocation: p.DischargerLocation,
diff --git a/services/identity/identity.vdl.go b/services/identity/identity.vdl.go
index 60a4fc0..28d2b7d 100644
--- a/services/identity/identity.vdl.go
+++ b/services/identity/identity.vdl.go
@@ -7,20 +7,22 @@
import (
"veyron.io/veyron/veyron2/security"
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// OAuthBlesserClientMethods is the client interface
+// containing OAuthBlesser methods.
+//
// OAuthBlesser exchanges OAuth access tokens for
// an email address from an OAuth-based identity provider and uses the email
// address obtained to bless the client.
@@ -34,148 +36,148 @@
// veyron virtual circuit).
// Thus, if Mallory possesses the access token associated with Alice's account,
// she may be able to obtain a blessing with Alice's name on it.
-// OAuthBlesser is the interface the client binds and uses.
-// OAuthBlesser_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type OAuthBlesser_ExcludingUniversal interface {
+type OAuthBlesserClientMethods interface {
// BlessUsingAccessToken uses the provided access token to obtain the email
// address and returns a blessing along with the email address.
- BlessUsingAccessToken(ctx _gen_context.T, token string, opts ..._gen_ipc.CallOpt) (blessing security.WireBlessings, email string, err error)
-}
-type OAuthBlesser interface {
- _gen_ipc.UniversalServiceMethods
- OAuthBlesser_ExcludingUniversal
+ BlessUsingAccessToken(ctx __context.T, token string, opts ...__ipc.CallOpt) (blessing security.WireBlessings, email string, err error)
}
-// OAuthBlesserService is the interface the server implements.
-type OAuthBlesserService interface {
-
- // BlessUsingAccessToken uses the provided access token to obtain the email
- // address and returns a blessing along with the email address.
- BlessUsingAccessToken(context _gen_ipc.ServerContext, token string) (blessing security.WireBlessings, email string, err error)
+// OAuthBlesserClientStub adds universal methods to OAuthBlesserClientMethods.
+type OAuthBlesserClientStub interface {
+ OAuthBlesserClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindOAuthBlesser returns the client stub implementing the OAuthBlesser
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindOAuthBlesser(name string, opts ..._gen_ipc.BindOpt) (OAuthBlesser, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// OAuthBlesserClient returns a client stub for OAuthBlesser.
+func OAuthBlesserClient(name string, opts ...__ipc.BindOpt) OAuthBlesserClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubOAuthBlesser{defaultClient: client, name: name}
-
- return stub, nil
+ return implOAuthBlesserClientStub{name, client}
}
-// NewServerOAuthBlesser creates a new server stub.
+type implOAuthBlesserClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implOAuthBlesserClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implOAuthBlesserClientStub) BlessUsingAccessToken(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (o0 security.WireBlessings, o1 string, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "BlessUsingAccessToken", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &o1, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implOAuthBlesserClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implOAuthBlesserClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// OAuthBlesserServerMethods is the interface a server writer
+// implements for OAuthBlesser.
//
-// It takes a regular server implementing the OAuthBlesserService
-// interface, and returns a new server stub.
-func NewServerOAuthBlesser(server OAuthBlesserService) interface{} {
- stub := &ServerStubOAuthBlesser{
- service: server,
+// OAuthBlesser exchanges OAuth access tokens for
+// an email address from an OAuth-based identity provider and uses the email
+// address obtained to bless the client.
+//
+// OAuth is described in RFC 6749 (http://tools.ietf.org/html/rfc6749),
+// though the Google implementation also has informative documentation at
+// https://developers.google.com/accounts/docs/OAuth2
+//
+// WARNING: There is no binding between the channel over which the access token
+// was obtained (typically https) and the channel used to make the RPC (a
+// veyron virtual circuit).
+// Thus, if Mallory possesses the access token associated with Alice's account,
+// she may be able to obtain a blessing with Alice's name on it.
+type OAuthBlesserServerMethods interface {
+ // BlessUsingAccessToken uses the provided access token to obtain the email
+ // address and returns a blessing along with the email address.
+ BlessUsingAccessToken(ctx __ipc.ServerContext, token string) (blessing security.WireBlessings, email string, err error)
+}
+
+// OAuthBlesserServerStubMethods is the server interface containing
+// OAuthBlesser methods, as expected by ipc.Server. The difference between
+// this interface and OAuthBlesserServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type OAuthBlesserServerStubMethods interface {
+ // BlessUsingAccessToken uses the provided access token to obtain the email
+ // address and returns a blessing along with the email address.
+ BlessUsingAccessToken(call __ipc.ServerCall, token string) (blessing security.WireBlessings, email string, err error)
+}
+
+// OAuthBlesserServerStub adds universal methods to OAuthBlesserServerStubMethods.
+type OAuthBlesserServerStub interface {
+ OAuthBlesserServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// OAuthBlesserServer returns a server stub for OAuthBlesser.
+// It converts an implementation of OAuthBlesserServerMethods into
+// an object that may be used by ipc.Server.
+func OAuthBlesserServer(impl OAuthBlesserServerMethods) OAuthBlesserServerStub {
+ stub := implOAuthBlesserServerStub{
+ impl: impl,
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubOAuthBlesser implements OAuthBlesser.
-type clientStubOAuthBlesser struct {
- defaultClient _gen_ipc.Client
- name string
+type implOAuthBlesserServerStub struct {
+ impl OAuthBlesserServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubOAuthBlesser) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implOAuthBlesserServerStub) BlessUsingAccessToken(call __ipc.ServerCall, i0 string) (security.WireBlessings, string, error) {
+ return s.impl.BlessUsingAccessToken(call, i0)
}
-func (__gen_c *clientStubOAuthBlesser) BlessUsingAccessToken(ctx _gen_context.T, token string, opts ..._gen_ipc.CallOpt) (blessing security.WireBlessings, email string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "BlessUsingAccessToken", []interface{}{token}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&blessing, &email, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implOAuthBlesserServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubOAuthBlesser) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubOAuthBlesser) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubOAuthBlesser) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubOAuthBlesser wraps a server that implements
-// OAuthBlesserService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubOAuthBlesser struct {
- service OAuthBlesserService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubOAuthBlesser) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implOAuthBlesserServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "BlessUsingAccessToken":
return []interface{}{}, nil
@@ -184,221 +186,186 @@
}
}
-func (__gen_s *ServerStubOAuthBlesser) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["BlessUsingAccessToken"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implOAuthBlesserServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["BlessUsingAccessToken"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "token", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "blessing", Type: 74},
{Name: "email", Type: 3},
{Name: "err", Type: 75},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
},
"veyron.io/veyron/veyron2/security.Caveat", []string(nil)},
- _gen_wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.Hash", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x42, Name: "Purpose"},
- _gen_wiretype.FieldType{Type: 0x45, Name: "Hash"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "R"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "S"},
+ __wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.Hash", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x42, Name: "Purpose"},
+ __wiretype.FieldType{Type: 0x45, Name: "Hash"},
+ __wiretype.FieldType{Type: 0x42, Name: "R"},
+ __wiretype.FieldType{Type: 0x42, Name: "S"},
},
"veyron.io/veyron/veyron2/security.Signature", []string(nil)},
- _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x3, Name: "Extension"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
- _gen_wiretype.FieldType{Type: 0x44, Name: "Caveats"},
- _gen_wiretype.FieldType{Type: 0x46, Name: "Signature"},
+ __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x3, Name: "Extension"},
+ __wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
+ __wiretype.FieldType{Type: 0x44, Name: "Caveats"},
+ __wiretype.FieldType{Type: 0x46, Name: "Signature"},
},
"veyron.io/veyron/veyron2/security.Certificate", []string(nil)},
- _gen_wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
+ __wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
},
"veyron.io/veyron/veyron2/security.WireBlessings", []string(nil)},
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-func (__gen_s *ServerStubOAuthBlesser) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubOAuthBlesser) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubOAuthBlesser) BlessUsingAccessToken(call _gen_ipc.ServerCall, token string) (blessing security.WireBlessings, email string, err error) {
- blessing, email, err = __gen_s.service.BlessUsingAccessToken(call, token)
- return
-}
-
+// MacaroonBlesserClientMethods is the client interface
+// containing MacaroonBlesser methods.
+//
// MacaroonBlesser returns a blessing given the provided macaroon string.
-// MacaroonBlesser is the interface the client binds and uses.
-// MacaroonBlesser_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type MacaroonBlesser_ExcludingUniversal interface {
+type MacaroonBlesserClientMethods interface {
// Bless uses the provided macaroon (which contains email and caveats)
// to return a blessing for the client.
- Bless(ctx _gen_context.T, macaroon string, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error)
-}
-type MacaroonBlesser interface {
- _gen_ipc.UniversalServiceMethods
- MacaroonBlesser_ExcludingUniversal
+ Bless(ctx __context.T, macaroon string, opts ...__ipc.CallOpt) (blessing security.WireBlessings, err error)
}
-// MacaroonBlesserService is the interface the server implements.
-type MacaroonBlesserService interface {
-
- // Bless uses the provided macaroon (which contains email and caveats)
- // to return a blessing for the client.
- Bless(context _gen_ipc.ServerContext, macaroon string) (reply security.WireBlessings, err error)
+// MacaroonBlesserClientStub adds universal methods to MacaroonBlesserClientMethods.
+type MacaroonBlesserClientStub interface {
+ MacaroonBlesserClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindMacaroonBlesser returns the client stub implementing the MacaroonBlesser
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindMacaroonBlesser(name string, opts ..._gen_ipc.BindOpt) (MacaroonBlesser, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// MacaroonBlesserClient returns a client stub for MacaroonBlesser.
+func MacaroonBlesserClient(name string, opts ...__ipc.BindOpt) MacaroonBlesserClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubMacaroonBlesser{defaultClient: client, name: name}
-
- return stub, nil
+ return implMacaroonBlesserClientStub{name, client}
}
-// NewServerMacaroonBlesser creates a new server stub.
+type implMacaroonBlesserClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implMacaroonBlesserClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implMacaroonBlesserClientStub) Bless(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (o0 security.WireBlessings, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Bless", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMacaroonBlesserClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implMacaroonBlesserClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// MacaroonBlesserServerMethods is the interface a server writer
+// implements for MacaroonBlesser.
//
-// It takes a regular server implementing the MacaroonBlesserService
-// interface, and returns a new server stub.
-func NewServerMacaroonBlesser(server MacaroonBlesserService) interface{} {
- stub := &ServerStubMacaroonBlesser{
- service: server,
+// MacaroonBlesser returns a blessing given the provided macaroon string.
+type MacaroonBlesserServerMethods interface {
+ // Bless uses the provided macaroon (which contains email and caveats)
+ // to return a blessing for the client.
+ Bless(ctx __ipc.ServerContext, macaroon string) (blessing security.WireBlessings, err error)
+}
+
+// MacaroonBlesserServerStubMethods is the server interface containing
+// MacaroonBlesser methods, as expected by ipc.Server. The difference between
+// this interface and MacaroonBlesserServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type MacaroonBlesserServerStubMethods interface {
+ // Bless uses the provided macaroon (which contains email and caveats)
+ // to return a blessing for the client.
+ Bless(call __ipc.ServerCall, macaroon string) (blessing security.WireBlessings, err error)
+}
+
+// MacaroonBlesserServerStub adds universal methods to MacaroonBlesserServerStubMethods.
+type MacaroonBlesserServerStub interface {
+ MacaroonBlesserServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// MacaroonBlesserServer returns a server stub for MacaroonBlesser.
+// It converts an implementation of MacaroonBlesserServerMethods into
+// an object that may be used by ipc.Server.
+func MacaroonBlesserServer(impl MacaroonBlesserServerMethods) MacaroonBlesserServerStub {
+ stub := implMacaroonBlesserServerStub{
+ impl: impl,
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubMacaroonBlesser implements MacaroonBlesser.
-type clientStubMacaroonBlesser struct {
- defaultClient _gen_ipc.Client
- name string
+type implMacaroonBlesserServerStub struct {
+ impl MacaroonBlesserServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubMacaroonBlesser) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implMacaroonBlesserServerStub) Bless(call __ipc.ServerCall, i0 string) (security.WireBlessings, error) {
+ return s.impl.Bless(call, i0)
}
-func (__gen_c *clientStubMacaroonBlesser) Bless(ctx _gen_context.T, macaroon string, opts ..._gen_ipc.CallOpt) (reply security.WireBlessings, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Bless", []interface{}{macaroon}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implMacaroonBlesserServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubMacaroonBlesser) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubMacaroonBlesser) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubMacaroonBlesser) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubMacaroonBlesser wraps a server that implements
-// MacaroonBlesserService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubMacaroonBlesser struct {
- service MacaroonBlesserService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubMacaroonBlesser) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implMacaroonBlesserServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Bless":
return []interface{}{}, nil
@@ -407,73 +374,47 @@
}
}
-func (__gen_s *ServerStubMacaroonBlesser) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Bless"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implMacaroonBlesserServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Bless"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "macaroon", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "blessing", Type: 74},
{Name: "err", Type: 75},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
},
"veyron.io/veyron/veyron2/security.Caveat", []string(nil)},
- _gen_wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.Hash", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x42, Name: "Purpose"},
- _gen_wiretype.FieldType{Type: 0x45, Name: "Hash"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "R"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "S"},
+ __wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.Hash", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x42, Name: "Purpose"},
+ __wiretype.FieldType{Type: 0x45, Name: "Hash"},
+ __wiretype.FieldType{Type: 0x42, Name: "R"},
+ __wiretype.FieldType{Type: 0x42, Name: "S"},
},
"veyron.io/veyron/veyron2/security.Signature", []string(nil)},
- _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x3, Name: "Extension"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
- _gen_wiretype.FieldType{Type: 0x44, Name: "Caveats"},
- _gen_wiretype.FieldType{Type: 0x46, Name: "Signature"},
+ __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x3, Name: "Extension"},
+ __wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
+ __wiretype.FieldType{Type: 0x44, Name: "Caveats"},
+ __wiretype.FieldType{Type: 0x46, Name: "Signature"},
},
"veyron.io/veyron/veyron2/security.Certificate", []string(nil)},
- _gen_wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
+ __wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
},
"veyron.io/veyron/veyron2/security.WireBlessings", []string(nil)},
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubMacaroonBlesser) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubMacaroonBlesser) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubMacaroonBlesser) Bless(call _gen_ipc.ServerCall, macaroon string) (reply security.WireBlessings, err error) {
- reply, err = __gen_s.service.Bless(call, macaroon)
- return
-}
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index f267b89..6665804 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -145,7 +145,7 @@
func newDispatcher(googleParams blesser.GoogleParams, macaroonKey []byte) ipc.Dispatcher {
d := dispatcher(map[string]ipc.Invoker{
macaroonService: ipc.ReflectInvoker(blesser.NewMacaroonBlesserServer(macaroonKey)),
- dischargerService: ipc.ReflectInvoker(services.NewServerDischarger(discharger.NewDischarger())),
+ dischargerService: ipc.ReflectInvoker(services.DischargerServer(discharger.NewDischarger())),
})
if len(*googleConfigChrome) > 0 || len(*googleConfigAndroid) > 0 {
d[googleService] = ipc.ReflectInvoker(blesser.NewGoogleOAuthBlesserServer(googleParams))
diff --git a/services/identity/revocation/revoker_test.go b/services/identity/revocation/revoker_test.go
index 6bb2148..7f5338b 100644
--- a/services/identity/revocation/revoker_test.go
+++ b/services/identity/revocation/revoker_test.go
@@ -31,7 +31,7 @@
if err != nil {
t.Fatalf("dischargerServer.Listen failed: %v", err)
}
- dischargerServiceStub := services.NewServerDischarger(discharger.NewDischarger())
+ dischargerServiceStub := services.DischargerServer(discharger.NewDischarger())
if err := dischargerServer.Serve("", dischargerServiceStub, nil); err != nil {
t.Fatalf("dischargerServer.Serve revoker: %s", err)
}
@@ -49,11 +49,7 @@
dcKey, dc, revoker, closeFunc, r := revokerSetup(t)
defer closeFunc()
- discharger, err := services.BindDischarger(dc)
- if err != nil {
- t.Fatalf("error binding to server: ", err)
- }
-
+ discharger := services.DischargerClient(dc)
cav, err := revoker.NewCaveat(dcKey, dc)
if err != nil {
t.Fatalf("failed to create public key caveat: %s", err)
diff --git a/services/mgmt/application/impl/dispatcher.go b/services/mgmt/application/impl/dispatcher.go
index 48b6c4f..a130f16 100644
--- a/services/mgmt/application/impl/dispatcher.go
+++ b/services/mgmt/application/impl/dispatcher.go
@@ -30,6 +30,6 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.NewServerApplication(NewInvoker(d.store, d.storeRoot, suffix)))
+ invoker := ipc.ReflectInvoker(repository.ApplicationServer(NewInvoker(d.store, d.storeRoot, suffix)))
return invoker, d.auth, nil
}
diff --git a/services/mgmt/application/impl/impl_test.go b/services/mgmt/application/impl/impl_test.go
index c073c99..2c706d3 100644
--- a/services/mgmt/application/impl/impl_test.go
+++ b/services/mgmt/application/impl/impl_test.go
@@ -50,18 +50,9 @@
}
// Create client stubs for talking to the server.
- stub, err := repository.BindApplication(naming.JoinAddressName(endpoint.String(), "//search"))
- if err != nil {
- t.Fatalf("BindRepository() failed: %v", err)
- }
- stubV1, err := repository.BindApplication(naming.JoinAddressName(endpoint.String(), "//search/v1"))
- if err != nil {
- t.Fatalf("BindRepository() failed: %v", err)
- }
- stubV2, err := repository.BindApplication(naming.JoinAddressName(endpoint.String(), "//search/v2"))
- if err != nil {
- t.Fatalf("BindRepository() failed: %v", err)
- }
+ stub := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "//search"))
+ stubV1 := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "//search/v1"))
+ stubV2 := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "//search/v2"))
// Create example envelopes.
envelopeV1 := application.Envelope{
diff --git a/services/mgmt/binary/impl/dispatcher.go b/services/mgmt/binary/impl/dispatcher.go
index 1b80de9..e9196e3 100644
--- a/services/mgmt/binary/impl/dispatcher.go
+++ b/services/mgmt/binary/impl/dispatcher.go
@@ -28,6 +28,6 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.NewServerBinary(newInvoker(d.state, suffix)))
+ invoker := ipc.ReflectInvoker(repository.BinaryServer(newInvoker(d.state, suffix)))
return invoker, d.auth, nil
}
diff --git a/services/mgmt/binary/impl/impl_test.go b/services/mgmt/binary/impl/impl_test.go
index a38ef40..886674c 100644
--- a/services/mgmt/binary/impl/impl_test.go
+++ b/services/mgmt/binary/impl/impl_test.go
@@ -33,7 +33,7 @@
// invokeUpload invokes the Upload RPC using the given client binary
// <binary> and streams the given binary <binary> to it.
-func invokeUpload(t *testing.T, binary repository.Binary, data []byte, part int32) (error, error) {
+func invokeUpload(t *testing.T, binary repository.BinaryClientMethods, data []byte, part int32) (error, error) {
stream, err := binary.Upload(rt.R().NewContext(), part)
if err != nil {
t.Errorf("Upload() failed: %v", err)
@@ -65,7 +65,7 @@
// invokeDownload invokes the Download RPC using the given client binary
// <binary> and streams binary from to it.
-func invokeDownload(t *testing.T, binary repository.Binary, part int32) ([]byte, error, error) {
+func invokeDownload(t *testing.T, binary repository.BinaryClientMethods, part int32) ([]byte, error, error) {
stream, err := binary.Download(rt.R().NewContext(), part)
if err != nil {
t.Errorf("Download() failed: %v", err)
@@ -95,7 +95,7 @@
}
// startServer starts the binary repository server.
-func startServer(t *testing.T, depth int) (repository.Binary, string, func()) {
+func startServer(t *testing.T, depth int) (repository.BinaryClientMethods, string, func()) {
// Setup the root of the binary repository.
root, err := ioutil.TempDir("", veyronPrefix)
if err != nil {
@@ -133,10 +133,7 @@
t.Fatalf("Serve(%q) failed: %v", dontPublishName, err)
}
name := naming.JoinAddressName(endpoint.String(), "//test")
- binary, err := repository.BindBinary(name)
- if err != nil {
- t.Fatalf("BindBinary(%v) failed: %v", name, err)
- }
+ binary := repository.BinaryClient(name)
return binary, fmt.Sprintf("http://%s/test", listener.Addr()), func() {
// Shutdown the binary repository server.
if err := server.Stop(); err != nil {
diff --git a/services/mgmt/binary/impl/invoker.go b/services/mgmt/binary/impl/invoker.go
index 182b128..8b18141 100644
--- a/services/mgmt/binary/impl/invoker.go
+++ b/services/mgmt/binary/impl/invoker.go
@@ -157,7 +157,7 @@
return nil
}
-func (i *invoker) Download(context ipc.ServerContext, part int32, stream repository.BinaryServiceDownloadStream) error {
+func (i *invoker) Download(context repository.BinaryDownloadContext, part int32) error {
vlog.Infof("%v.Download(%v)", i.suffix, part)
path := i.generatePartPath(int(part))
if err := checksumExists(path); err != nil {
@@ -171,7 +171,7 @@
}
defer file.Close()
buffer := make([]byte, bufferLength)
- sender := stream.SendStream()
+ sender := context.SendStream()
for {
n, err := file.Read(buffer)
if err != nil && err != io.EOF {
@@ -228,7 +228,7 @@
return result, nil
}
-func (i *invoker) Upload(context ipc.ServerContext, part int32, stream repository.BinaryServiceUploadStream) error {
+func (i *invoker) Upload(context repository.BinaryUploadContext, part int32) error {
vlog.Infof("%v.Upload(%v)", i.suffix, part)
path, suffix := i.generatePartPath(int(part)), ""
err := checksumExists(path)
@@ -258,7 +258,7 @@
}
defer file.Close()
h := md5.New()
- rStream := stream.RecvStream()
+ rStream := context.RecvStream()
for rStream.Advance() {
bytes := rStream.Value()
if _, err := file.Write(bytes); err != nil {
diff --git a/services/mgmt/build/buildd/main.go b/services/mgmt/build/buildd/main.go
index 6d05b59..09f7070 100644
--- a/services/mgmt/build/buildd/main.go
+++ b/services/mgmt/build/buildd/main.go
@@ -35,7 +35,7 @@
vlog.Errorf("Listen(%s) failed: %v", roaming.ListenSpec, err)
return
}
- if err := server.Serve(*name, build.NewServerBuilder(impl.NewInvoker(*gobin, *goroot)), vflag.NewAuthorizerOrDie()); err != nil {
+ if err := server.Serve(*name, build.BuilderServer(impl.NewInvoker(*gobin, *goroot)), vflag.NewAuthorizerOrDie()); err != nil {
vlog.Errorf("Serve(%v) failed: %v", *name, err)
return
}
diff --git a/services/mgmt/build/impl/impl_test.go b/services/mgmt/build/impl/impl_test.go
index 37f0f5a..2c07891 100644
--- a/services/mgmt/build/impl/impl_test.go
+++ b/services/mgmt/build/impl/impl_test.go
@@ -46,7 +46,7 @@
}
// startServer starts the build server.
-func startServer(t *testing.T) (build.Builder, func()) {
+func startServer(t *testing.T) (build.BuilderClientMethods, func()) {
gobin, goroot := findGoBinary(t, "go")
server, err := rt.R().NewServer()
if err != nil {
@@ -57,22 +57,18 @@
t.Fatalf("Listen(%s) failed: %v", profiles.LocalListenSpec, err)
}
unpublished := ""
- if err := server.Serve(unpublished, build.NewServerBuilder(NewInvoker(gobin, goroot)), nil); err != nil {
+ if err := server.Serve(unpublished, build.BuilderServer(NewInvoker(gobin, goroot)), nil); err != nil {
t.Fatalf("Serve(%q) failed: %v", unpublished, err)
}
name := "/" + endpoint.String()
- client, err := build.BindBuilder(name)
- if err != nil {
- t.Fatalf("BindBuilder(%v) failed: %v", name, err)
- }
- return client, func() {
+ return build.BuilderClient(name), func() {
if err := server.Stop(); err != nil {
t.Fatalf("Stop() failed: %v", err)
}
}
}
-func invokeBuild(t *testing.T, client build.Builder, files []build.File) ([]byte, []build.File, error) {
+func invokeBuild(t *testing.T, client build.BuilderClientMethods, files []build.File) ([]byte, []build.File, error) {
arch, opsys := getArch(), getOS()
stream, err := client.Build(rt.R().NewContext(), arch, opsys)
if err != nil {
diff --git a/services/mgmt/build/impl/invoker.go b/services/mgmt/build/impl/invoker.go
index 051099c..fc798ac 100644
--- a/services/mgmt/build/impl/invoker.go
+++ b/services/mgmt/build/impl/invoker.go
@@ -42,7 +42,7 @@
//
// TODO(jsimsa): Analyze the binary files for shared library
// dependencies and ship these back.
-func (i *invoker) Build(_ ipc.ServerContext, arch build.Architecture, opsys build.OperatingSystem, stream build.BuilderServiceBuildStream) ([]byte, error) {
+func (i *invoker) Build(ctx build.BuilderBuildContext, arch build.Architecture, opsys build.OperatingSystem) ([]byte, error) {
vlog.VI(1).Infof("Build(%v, %v) called.", arch, opsys)
dir, prefix := "", ""
dirPerm, filePerm := os.FileMode(0700), os.FileMode(0600)
@@ -57,7 +57,7 @@
vlog.Errorf("MkdirAll(%v, %v) failed: %v", srcDir, dirPerm, err)
return nil, errInternalError
}
- iterator := stream.RecvStream()
+ iterator := ctx.RecvStream()
for iterator.Advance() {
srcFile := iterator.Value()
filePath := filepath.Join(srcDir, filepath.FromSlash(srcFile.Name))
@@ -112,7 +112,7 @@
Name: "bin/" + file.Name(),
Contents: bytes,
}
- if err := stream.SendStream().Send(result); err != nil {
+ if err := ctx.SendStream().Send(result); err != nil {
vlog.Errorf("Send() failed: %v", err)
return nil, errInternalError
}
diff --git a/services/mgmt/debug/debug.vdl.go b/services/mgmt/debug/debug.vdl.go
index 34514b4..9f01f70 100644
--- a/services/mgmt/debug/debug.vdl.go
+++ b/services/mgmt/debug/debug.vdl.go
@@ -10,30 +10,29 @@
"veyron.io/veyron/veyron2/services/mgmt/stats"
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// DebugClientMethods is the client interface
+// containing Debug methods.
+//
// This interface exists only for the purpose of generating a valid Signature
// for all the interfaces that are served by the debug server. It should be
// removed when https://code.google.com/p/envyor/issues/detail?id=285 is
// resolved.
-// Debug is the interface the client binds and uses.
-// Debug_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Debug_ExcludingUniversal interface {
+type DebugClientMethods interface {
// LogFile can be used to access log files remotely.
- logreader.LogFile_ExcludingUniversal
+ logreader.LogFileClientMethods
// The Stats interface is used to access stats for troubleshooting and
// monitoring purposes. The stats objects are discoverable via the Globbable
// interface and watchable via the GlobWatcher interface.
@@ -41,218 +40,214 @@
// The types of the object values are implementation specific, but should be
// primarily numeric in nature, e.g. counters, memory usage, latency metrics,
// etc.
- stats.Stats_ExcludingUniversal
- pprof.PProf_ExcludingUniversal
-}
-type Debug interface {
- _gen_ipc.UniversalServiceMethods
- Debug_ExcludingUniversal
+ stats.StatsClientMethods
+ pprof.PProfClientMethods
}
-// DebugService is the interface the server implements.
-type DebugService interface {
-
- // LogFile can be used to access log files remotely.
- logreader.LogFileService
- // The Stats interface is used to access stats for troubleshooting and
- // monitoring purposes. The stats objects are discoverable via the Globbable
- // interface and watchable via the GlobWatcher interface.
- //
- // The types of the object values are implementation specific, but should be
- // primarily numeric in nature, e.g. counters, memory usage, latency metrics,
- // etc.
- stats.StatsService
- pprof.PProfService
+// DebugClientStub adds universal methods to DebugClientMethods.
+type DebugClientStub interface {
+ DebugClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindDebug returns the client stub implementing the Debug
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindDebug(name string, opts ..._gen_ipc.BindOpt) (Debug, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// DebugClient returns a client stub for Debug.
+func DebugClient(name string, opts ...__ipc.BindOpt) DebugClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubDebug{defaultClient: client, name: name}
- stub.LogFile_ExcludingUniversal, _ = logreader.BindLogFile(name, client)
- stub.Stats_ExcludingUniversal, _ = stats.BindStats(name, client)
- stub.PProf_ExcludingUniversal, _ = pprof.BindPProf(name, client)
-
- return stub, nil
+ return implDebugClientStub{name, client, logreader.LogFileClient(name, client), stats.StatsClient(name, client), pprof.PProfClient(name, client)}
}
-// NewServerDebug creates a new server stub.
+type implDebugClientStub struct {
+ name string
+ client __ipc.Client
+
+ logreader.LogFileClientStub
+ stats.StatsClientStub
+ pprof.PProfClientStub
+}
+
+func (c implDebugClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implDebugClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implDebugClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// DebugServerMethods is the interface a server writer
+// implements for Debug.
//
-// It takes a regular server implementing the DebugService
-// interface, and returns a new server stub.
-func NewServerDebug(server DebugService) interface{} {
- stub := &ServerStubDebug{
- ServerStubLogFile: *logreader.NewServerLogFile(server).(*logreader.ServerStubLogFile),
- ServerStubStats: *stats.NewServerStats(server).(*stats.ServerStubStats),
- ServerStubPProf: *pprof.NewServerPProf(server).(*pprof.ServerStubPProf),
- service: server,
+// This interface exists only for the purpose of generating a valid Signature
+// for all the interfaces that are served by the debug server. It should be
+// removed when https://code.google.com/p/envyor/issues/detail?id=285 is
+// resolved.
+type DebugServerMethods interface {
+ // LogFile can be used to access log files remotely.
+ logreader.LogFileServerMethods
+ // The Stats interface is used to access stats for troubleshooting and
+ // monitoring purposes. The stats objects are discoverable via the Globbable
+ // interface and watchable via the GlobWatcher interface.
+ //
+ // The types of the object values are implementation specific, but should be
+ // primarily numeric in nature, e.g. counters, memory usage, latency metrics,
+ // etc.
+ stats.StatsServerMethods
+ pprof.PProfServerMethods
+}
+
+// DebugServerStubMethods is the server interface containing
+// Debug methods, as expected by ipc.Server. The difference between
+// this interface and DebugServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type DebugServerStubMethods interface {
+ // LogFile can be used to access log files remotely.
+ logreader.LogFileServerStubMethods
+ // The Stats interface is used to access stats for troubleshooting and
+ // monitoring purposes. The stats objects are discoverable via the Globbable
+ // interface and watchable via the GlobWatcher interface.
+ //
+ // The types of the object values are implementation specific, but should be
+ // primarily numeric in nature, e.g. counters, memory usage, latency metrics,
+ // etc.
+ stats.StatsServerStubMethods
+ pprof.PProfServerStubMethods
+}
+
+// DebugServerStub adds universal methods to DebugServerStubMethods.
+type DebugServerStub interface {
+ DebugServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// DebugServer returns a server stub for Debug.
+// It converts an implementation of DebugServerMethods into
+// an object that may be used by ipc.Server.
+func DebugServer(impl DebugServerMethods) DebugServerStub {
+ stub := implDebugServerStub{
+ impl: impl,
+ LogFileServerStub: logreader.LogFileServer(impl),
+ StatsServerStub: stats.StatsServer(impl),
+ PProfServerStub: pprof.PProfServer(impl),
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubDebug implements Debug.
-type clientStubDebug struct {
- logreader.LogFile_ExcludingUniversal
- stats.Stats_ExcludingUniversal
- pprof.PProf_ExcludingUniversal
+type implDebugServerStub struct {
+ impl DebugServerMethods
+ gs *__ipc.GlobState
- defaultClient _gen_ipc.Client
- name string
+ logreader.LogFileServerStub
+ stats.StatsServerStub
+ pprof.PProfServerStub
}
-func (__gen_c *clientStubDebug) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implDebugServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubDebug) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubDebug) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubDebug) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubDebug wraps a server that implements
-// DebugService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubDebug struct {
- logreader.ServerStubLogFile
- stats.ServerStubStats
- pprof.ServerStubPProf
-
- service DebugService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubDebug) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
- if resp, err := __gen_s.ServerStubLogFile.GetMethodTags(call, method); resp != nil || err != nil {
+func (s implDebugServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
+ if resp, err := s.LogFileServerStub.GetMethodTags(call, method); resp != nil || err != nil {
return resp, err
}
- if resp, err := __gen_s.ServerStubStats.GetMethodTags(call, method); resp != nil || err != nil {
+ if resp, err := s.StatsServerStub.GetMethodTags(call, method); resp != nil || err != nil {
return resp, err
}
- if resp, err := __gen_s.ServerStubPProf.GetMethodTags(call, method); resp != nil || err != nil {
+ if resp, err := s.PProfServerStub.GetMethodTags(call, method); resp != nil || err != nil {
return resp, err
}
return nil, nil
}
-func (__gen_s *ServerStubDebug) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
+func (s implDebugServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.TypeDefs = []_gen_vdlutil.Any{}
- var ss _gen_ipc.ServiceSignature
+ result.TypeDefs = []__vdlutil.Any{}
+ var ss __ipc.ServiceSignature
var firstAdded int
- ss, _ = __gen_s.ServerStubLogFile.Signature(call)
+ ss, _ = s.LogFileServerStub.Signature(call)
firstAdded = len(result.TypeDefs)
for k, v := range ss.Methods {
for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
- if v.InStream >= _gen_wiretype.TypeIDFirst {
- v.InStream += _gen_wiretype.TypeID(firstAdded)
+ if v.InStream >= __wiretype.TypeIDFirst {
+ v.InStream += __wiretype.TypeID(firstAdded)
}
- if v.OutStream >= _gen_wiretype.TypeIDFirst {
- v.OutStream += _gen_wiretype.TypeID(firstAdded)
+ if v.OutStream >= __wiretype.TypeIDFirst {
+ v.OutStream += __wiretype.TypeID(firstAdded)
}
result.Methods[k] = v
}
//TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
for _, d := range ss.TypeDefs {
switch wt := d.(type) {
- case _gen_wiretype.SliceType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.SliceType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.ArrayType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.ArrayType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.MapType:
- if wt.Key >= _gen_wiretype.TypeIDFirst {
- wt.Key += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.MapType:
+ if wt.Key >= __wiretype.TypeIDFirst {
+ wt.Key += __wiretype.TypeID(firstAdded)
}
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.StructType:
+ case __wiretype.StructType:
for i, fld := range wt.Fields {
- if fld.Type >= _gen_wiretype.TypeIDFirst {
- wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if fld.Type >= __wiretype.TypeIDFirst {
+ wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
}
}
d = wt
@@ -260,52 +255,52 @@
}
result.TypeDefs = append(result.TypeDefs, d)
}
- ss, _ = __gen_s.ServerStubStats.Signature(call)
+ ss, _ = s.StatsServerStub.Signature(call)
firstAdded = len(result.TypeDefs)
for k, v := range ss.Methods {
for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
- if v.InStream >= _gen_wiretype.TypeIDFirst {
- v.InStream += _gen_wiretype.TypeID(firstAdded)
+ if v.InStream >= __wiretype.TypeIDFirst {
+ v.InStream += __wiretype.TypeID(firstAdded)
}
- if v.OutStream >= _gen_wiretype.TypeIDFirst {
- v.OutStream += _gen_wiretype.TypeID(firstAdded)
+ if v.OutStream >= __wiretype.TypeIDFirst {
+ v.OutStream += __wiretype.TypeID(firstAdded)
}
result.Methods[k] = v
}
//TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
for _, d := range ss.TypeDefs {
switch wt := d.(type) {
- case _gen_wiretype.SliceType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.SliceType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.ArrayType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.ArrayType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.MapType:
- if wt.Key >= _gen_wiretype.TypeIDFirst {
- wt.Key += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.MapType:
+ if wt.Key >= __wiretype.TypeIDFirst {
+ wt.Key += __wiretype.TypeID(firstAdded)
}
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.StructType:
+ case __wiretype.StructType:
for i, fld := range wt.Fields {
- if fld.Type >= _gen_wiretype.TypeIDFirst {
- wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if fld.Type >= __wiretype.TypeIDFirst {
+ wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
}
}
d = wt
@@ -313,52 +308,52 @@
}
result.TypeDefs = append(result.TypeDefs, d)
}
- ss, _ = __gen_s.ServerStubPProf.Signature(call)
+ ss, _ = s.PProfServerStub.Signature(call)
firstAdded = len(result.TypeDefs)
for k, v := range ss.Methods {
for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
- if v.InStream >= _gen_wiretype.TypeIDFirst {
- v.InStream += _gen_wiretype.TypeID(firstAdded)
+ if v.InStream >= __wiretype.TypeIDFirst {
+ v.InStream += __wiretype.TypeID(firstAdded)
}
- if v.OutStream >= _gen_wiretype.TypeIDFirst {
- v.OutStream += _gen_wiretype.TypeID(firstAdded)
+ if v.OutStream >= __wiretype.TypeIDFirst {
+ v.OutStream += __wiretype.TypeID(firstAdded)
}
result.Methods[k] = v
}
//TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
for _, d := range ss.TypeDefs {
switch wt := d.(type) {
- case _gen_wiretype.SliceType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.SliceType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.ArrayType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.ArrayType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.MapType:
- if wt.Key >= _gen_wiretype.TypeIDFirst {
- wt.Key += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.MapType:
+ if wt.Key >= __wiretype.TypeIDFirst {
+ wt.Key += __wiretype.TypeID(firstAdded)
}
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.StructType:
+ case __wiretype.StructType:
for i, fld := range wt.Fields {
- if fld.Type >= _gen_wiretype.TypeIDFirst {
- wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if fld.Type >= __wiretype.TypeIDFirst {
+ wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
}
}
d = wt
@@ -369,25 +364,3 @@
return result, nil
}
-
-func (__gen_s *ServerStubDebug) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubDebug) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
diff --git a/services/mgmt/debug/server_test.go b/services/mgmt/debug/server_test.go
index baa824f..137181e 100644
--- a/services/mgmt/debug/server_test.go
+++ b/services/mgmt/debug/server_test.go
@@ -42,10 +42,7 @@
// Access a logs directory that exists.
{
- ld, err := mounttable.BindGlobbable(naming.JoinAddressName(endpoint, "//logs"))
- if err != nil {
- t.Errorf("BindGlobbable: %v", err)
- }
+ ld := mounttable.GlobbableClient(naming.JoinAddressName(endpoint, "//logs"))
stream, err := ld.Glob(runtime.NewContext(), "*")
if err != nil {
t.Errorf("Glob failed: %v", err)
@@ -68,10 +65,7 @@
// Access a logs directory that doesn't exist.
{
- ld, err := mounttable.BindGlobbable(naming.JoinAddressName(endpoint, "//logs/nowheretobefound"))
- if err != nil {
- t.Errorf("BindGlobbable: %v", err)
- }
+ ld := mounttable.GlobbableClient(naming.JoinAddressName(endpoint, "//logs/nowheretobefound"))
stream, err := ld.Glob(runtime.NewContext(), "*")
if err != nil {
t.Errorf("Glob failed: %v", err)
@@ -91,10 +85,7 @@
// Access a log file that exists.
{
- lf, err := logreader.BindLogFile(naming.JoinAddressName(endpoint, "//logs/test.INFO"))
- if err != nil {
- t.Errorf("BindLogFile: %v", err)
- }
+ lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "//logs/test.INFO"))
size, err := lf.Size(runtime.NewContext())
if err != nil {
t.Errorf("Size failed: %v", err)
@@ -106,10 +97,7 @@
// Access a log file that doesn't exist.
{
- lf, err := logreader.BindLogFile(naming.JoinAddressName(endpoint, "//logs/nosuchfile.INFO"))
- if err != nil {
- t.Errorf("BindLogFile: %v", err)
- }
+ lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "//logs/nosuchfile.INFO"))
_, err = lf.Size(runtime.NewContext())
if expected := verror.NoExist; !verror.Is(err, expected) {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
@@ -121,10 +109,7 @@
foo := libstats.NewInteger("testing/foo")
foo.Set(123)
- st, err := stats.BindStats(naming.JoinAddressName(endpoint, "//stats/testing/foo"))
- if err != nil {
- t.Errorf("BindStats: %v", err)
- }
+ st := stats.StatsClient(naming.JoinAddressName(endpoint, "//stats/testing/foo"))
v, err := st.Value(runtime.NewContext())
if err != nil {
t.Errorf("Value failed: %v", err)
@@ -136,10 +121,7 @@
// Access a stats object that doesn't exists.
{
- st, err := stats.BindStats(naming.JoinAddressName(endpoint, "//stats/testing/nobodyhome"))
- if err != nil {
- t.Errorf("BindStats: %v", err)
- }
+ st := stats.StatsClient(naming.JoinAddressName(endpoint, "//stats/testing/nobodyhome"))
_, err = st.Value(runtime.NewContext())
if expected := verror.NoExist; !verror.Is(err, expected) {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
diff --git a/services/mgmt/debug/signature.go b/services/mgmt/debug/signature.go
index 032bc88..99e99d6 100644
--- a/services/mgmt/debug/signature.go
+++ b/services/mgmt/debug/signature.go
@@ -17,7 +17,7 @@
// TODO(rthellend): This is a temporary hack until https://code.google.com/p/envyor/issues/detail?id=285 is resolved.
func (s signatureInvoker) Signature(ipc.ServerCall) (ipc.ServiceSignature, error) {
- debugStub := ServerStubDebug{}
+ debugStub := DebugServer(nil)
fullSig, _ := debugStub.Signature(nil)
var show []string
diff --git a/services/mgmt/lib/binary/impl.go b/services/mgmt/lib/binary/impl.go
index fc52c63..41af160 100644
--- a/services/mgmt/lib/binary/impl.go
+++ b/services/mgmt/lib/binary/impl.go
@@ -33,14 +33,9 @@
)
func Delete(name string) error {
- client, err := repository.BindBinary(name)
- if err != nil {
- vlog.Errorf("BindBinary(%v) failed: %v", name, err)
- return err
- }
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- if err := client.Delete(ctx); err != nil {
+ if err := repository.BinaryClient(name).Delete(ctx); err != nil {
vlog.Errorf("Delete() failed: %v", err)
return err
}
@@ -48,11 +43,7 @@
}
func download(ctx context.T, w io.WriteSeeker, von string) error {
- client, err := repository.BindBinary(von)
- if err != nil {
- vlog.Errorf("BindBinary(%v) failed: %v", von, err)
- return err
- }
+ client := repository.BinaryClient(von)
parts, err := client.Stat(ctx)
if err != nil {
vlog.Errorf("Stat() failed: %v", err)
@@ -175,11 +166,7 @@
}
func upload(ctx context.T, r io.ReadSeeker, von string) error {
- client, err := repository.BindBinary(von)
- if err != nil {
- vlog.Errorf("BindBinary(%v) failed: %v", von, err)
- return err
- }
+ client := repository.BinaryClient(von)
offset, whence := int64(0), 2
size, err := r.Seek(offset, whence)
if err != nil {
diff --git a/services/mgmt/logreader/impl/logdir_invoker_test.go b/services/mgmt/logreader/impl/logdir_invoker_test.go
index 0cba1db..f2bdf87 100644
--- a/services/mgmt/logreader/impl/logdir_invoker_test.go
+++ b/services/mgmt/logreader/impl/logdir_invoker_test.go
@@ -56,10 +56,7 @@
// Try to access a directory that doesn't exist.
{
- ld, err := mounttable.BindGlobbable(naming.JoinAddressName(endpoint, "//doesntexist"))
- if err != nil {
- t.Errorf("BindLogDirectory: %v", err)
- }
+ ld := mounttable.GlobbableClient(naming.JoinAddressName(endpoint, "//doesntexist"))
stream, err := ld.Glob(runtime.NewContext(), "*")
if err != nil {
t.Errorf("unexpected error, got %v, want: nil", err)
@@ -73,11 +70,7 @@
// Try to access a directory that does exist.
{
- ld, err := mounttable.BindGlobbable(naming.JoinAddressName(endpoint, "//"))
- if err != nil {
- t.Errorf("BindLogDirectory: %v", err)
- }
-
+ ld := mounttable.GlobbableClient(naming.JoinAddressName(endpoint, "//"))
stream, err := ld.Glob(runtime.NewContext(), "...")
if err != nil {
t.Errorf("Glob failed: %v", err)
@@ -156,10 +149,7 @@
// Try to access a sub-directory.
{
- ld, err := mounttable.BindGlobbable(naming.JoinAddressName(endpoint, "//subdir"))
- if err != nil {
- t.Errorf("BindLogDirectory: %v", err)
- }
+ ld := mounttable.GlobbableClient(naming.JoinAddressName(endpoint, "//subdir"))
stream, err := ld.Glob(runtime.NewContext(), "*")
if err != nil {
t.Errorf("Glob failed: %v", err)
@@ -188,10 +178,7 @@
// Try to access a file.
{
- ld, err := mounttable.BindGlobbable(naming.JoinAddressName(endpoint, "//foo.txt"))
- if err != nil {
- t.Errorf("BindLogDirectory: %v", err)
- }
+ ld := mounttable.GlobbableClient(naming.JoinAddressName(endpoint, "//foo.txt"))
stream, err := ld.Glob(runtime.NewContext(), "*")
if err != nil {
t.Errorf("Glob failed: %v", err)
diff --git a/services/mgmt/logreader/impl/logfile_invoker_test.go b/services/mgmt/logreader/impl/logfile_invoker_test.go
index 0cc7615..3f6a478 100644
--- a/services/mgmt/logreader/impl/logfile_invoker_test.go
+++ b/services/mgmt/logreader/impl/logfile_invoker_test.go
@@ -66,20 +66,14 @@
}
// Try to access a file that doesn't exist.
- lf, err := logreader.BindLogFile(naming.JoinAddressName(endpoint, "//doesntexist"))
- if err != nil {
- t.Errorf("BindLogFile: %v", err)
- }
+ lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "//doesntexist"))
_, err = lf.Size(runtime.NewContext())
if expected := verror.NoExist; !verror.Is(err, expected) {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
}
// Try to access a file that does exist.
- lf, err = logreader.BindLogFile(naming.JoinAddressName(endpoint, "//"+testFile))
- if err != nil {
- t.Errorf("BindLogFile: %v", err)
- }
+ lf = logreader.LogFileClient(naming.JoinAddressName(endpoint, "//"+testFile))
_, err = lf.Size(runtime.NewContext())
if err != nil {
t.Errorf("Size failed: %v", err)
@@ -154,10 +148,7 @@
"Fix it later",
}
- lf, err := logreader.BindLogFile(naming.JoinAddressName(endpoint, "//"+testFile))
- if err != nil {
- t.Errorf("BindLogFile: %v", err)
- }
+ lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "//"+testFile))
_, err = lf.Size(runtime.NewContext())
if err != nil {
t.Errorf("Size failed: %v", err)
diff --git a/services/mgmt/node/config.vdl.go b/services/mgmt/node/config.vdl.go
index 7b9dfbe..45377a8 100644
--- a/services/mgmt/node/config.vdl.go
+++ b/services/mgmt/node/config.vdl.go
@@ -4,108 +4,60 @@
package node
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// ConfigClientMethods is the client interface
+// containing Config methods.
+//
// Config is an RPC API to the config service.
-// Config is the interface the client binds and uses.
-// Config_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Config_ExcludingUniversal interface {
+type ConfigClientMethods interface {
// Set sets the value for key.
- Set(ctx _gen_context.T, key string, value string, opts ..._gen_ipc.CallOpt) (err error)
-}
-type Config interface {
- _gen_ipc.UniversalServiceMethods
- Config_ExcludingUniversal
+ Set(ctx __context.T, key string, value string, opts ...__ipc.CallOpt) error
}
-// ConfigService is the interface the server implements.
-type ConfigService interface {
-
- // Set sets the value for key.
- Set(context _gen_ipc.ServerContext, key string, value string) (err error)
+// ConfigClientStub adds universal methods to ConfigClientMethods.
+type ConfigClientStub interface {
+ ConfigClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindConfig returns the client stub implementing the Config
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindConfig(name string, opts ..._gen_ipc.BindOpt) (Config, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// ConfigClient returns a client stub for Config.
+func ConfigClient(name string, opts ...__ipc.BindOpt) ConfigClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubConfig{defaultClient: client, name: name}
-
- return stub, nil
+ return implConfigClientStub{name, client}
}
-// NewServerConfig creates a new server stub.
-//
-// It takes a regular server implementing the ConfigService
-// interface, and returns a new server stub.
-func NewServerConfig(server ConfigService) interface{} {
- stub := &ServerStubConfig{
- service: server,
- }
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
- return stub
+type implConfigClientStub struct {
+ name string
+ client __ipc.Client
}
-// clientStubConfig implements Config.
-type clientStubConfig struct {
- defaultClient _gen_ipc.Client
- name string
-}
-
-func (__gen_c *clientStubConfig) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
+func (c implConfigClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
}
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+ return __veyron2.RuntimeFromContext(ctx).Client()
}
-func (__gen_c *clientStubConfig) Set(ctx _gen_context.T, key string, value string, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Set", []interface{}{key, value}, opts...); err != nil {
+func (c implConfigClientStub) Set(ctx __context.T, i0 string, i1 string, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Set", []interface{}{i0, i1}, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
@@ -114,51 +66,88 @@
return
}
-func (__gen_c *clientStubConfig) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
+func (c implConfigClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubConfig) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
+func (c implConfigClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubConfig) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+// ConfigServerMethods is the interface a server writer
+// implements for Config.
+//
+// Config is an RPC API to the config service.
+type ConfigServerMethods interface {
+ // Set sets the value for key.
+ Set(ctx __ipc.ServerContext, key string, value string) error
}
-// ServerStubConfig wraps a server that implements
-// ConfigService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubConfig struct {
- service ConfigService
- gs *_gen_ipc.GlobState
+// ConfigServerStubMethods is the server interface containing
+// Config methods, as expected by ipc.Server. The difference between
+// this interface and ConfigServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type ConfigServerStubMethods interface {
+ // Set sets the value for key.
+ Set(call __ipc.ServerCall, key string, value string) error
}
-func (__gen_s *ServerStubConfig) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+// ConfigServerStub adds universal methods to ConfigServerStubMethods.
+type ConfigServerStub interface {
+ ConfigServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// ConfigServer returns a server stub for Config.
+// It converts an implementation of ConfigServerMethods into
+// an object that may be used by ipc.Server.
+func ConfigServer(impl ConfigServerMethods) ConfigServerStub {
+ stub := implConfigServerStub{
+ impl: impl,
+ }
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
+ }
+ return stub
+}
+
+type implConfigServerStub struct {
+ impl ConfigServerMethods
+ gs *__ipc.GlobState
+}
+
+func (s implConfigServerStub) Set(call __ipc.ServerCall, i0 string, i1 string) error {
+ return s.impl.Set(call, i0, i1)
+}
+
+func (s implConfigServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
+}
+
+func (s implConfigServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Set":
return []interface{}{}, nil
@@ -167,47 +156,21 @@
}
}
-func (__gen_s *ServerStubConfig) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Set"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implConfigServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Set"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "key", Type: 3},
{Name: "value", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubConfig) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubConfig) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubConfig) Set(call _gen_ipc.ServerCall, key string, value string) (err error) {
- err = __gen_s.service.Set(call, key, value)
- return
-}
diff --git a/services/mgmt/node/impl/app_invoker.go b/services/mgmt/node/impl/app_invoker.go
index 36556d2..6ff19f7 100644
--- a/services/mgmt/node/impl/app_invoker.go
+++ b/services/mgmt/node/impl/app_invoker.go
@@ -625,11 +625,7 @@
}
func stopAppRemotely(appVON string) error {
- appStub, err := appcycle.BindAppCycle(appVON)
- if err != nil {
- vlog.Errorf("BindAppCycle(%v) failed: %v", appVON, err)
- return errOperationFailed
- }
+ appStub := appcycle.AppCycleClient(appVON)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
stream, err := appStub.Stop(ctx)
@@ -906,7 +902,7 @@
})
}
-func (i *appInvoker) Glob(ctx ipc.ServerContext, pattern string, stream mounttable.GlobbableServiceGlobStream) error {
+func (i *appInvoker) Glob(ctx mounttable.GlobbableGlobContext, pattern string) error {
g, err := glob.Parse(pattern)
if err != nil {
return err
@@ -915,41 +911,36 @@
if n == nil {
return errInvalidSuffix
}
- i.globStep(ctx, "", g, n, stream)
+ i.globStep(ctx, "", g, n)
return nil
}
-func (i *appInvoker) globStep(ctx ipc.ServerContext, prefix string, g *glob.Glob, n *treeNode, stream mounttable.GlobbableServiceGlobStream) {
+func (i *appInvoker) globStep(ctx mounttable.GlobbableGlobContext, prefix string, g *glob.Glob, n *treeNode) {
if n.remote != "" {
- remoteGlob(ctx, n.remote, prefix, g.String(), stream)
+ remoteGlob(ctx, n.remote, prefix, g.String())
return
}
if g.Len() == 0 {
- stream.SendStream().Send(types.MountEntry{Name: prefix})
+ ctx.SendStream().Send(types.MountEntry{Name: prefix})
}
if g.Finished() {
return
}
for name, child := range n.children {
if ok, _, left := g.MatchInitialSegment(name); ok {
- i.globStep(ctx, naming.Join(prefix, name), left, child, stream)
+ i.globStep(ctx, naming.Join(prefix, name), left, child)
}
}
}
-func remoteGlob(ctx ipc.ServerContext, remote, prefix, pattern string, stream mounttable.GlobbableServiceGlobStream) {
- c, err := mounttable.BindGlobbable(remote)
- if err != nil {
- vlog.VI(1).Infof("BindGlobbable(%q): %v", remote, err)
- return
- }
- call, err := c.Glob(ctx, pattern)
+func remoteGlob(ctx mounttable.GlobbableGlobContext, remote, prefix, pattern string) {
+ call, err := mounttable.GlobbableClient(remote).Glob(ctx, pattern)
if err != nil {
vlog.VI(1).Infof("%q.Glob(%q): %v", remote, pattern, err)
return
}
it := call.RecvStream()
- sender := stream.SendStream()
+ sender := ctx.SendStream()
for it.Advance() {
me := it.Value()
me.Name = naming.Join(prefix, me.Name)
diff --git a/services/mgmt/node/impl/callback.go b/services/mgmt/node/impl/callback.go
index 7865bc6..02238c6 100644
--- a/services/mgmt/node/impl/callback.go
+++ b/services/mgmt/node/impl/callback.go
@@ -23,10 +23,7 @@
// Node manager was not started by self-update, return silently.
return
}
- nmClient, err := node.BindConfig(callbackName)
- if err != nil {
- vlog.Fatalf("BindNode(%v) failed: %v", callbackName, err)
- }
+ nmClient := node.ConfigClient(callbackName)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
if err := nmClient.Set(ctx, mgmt.ChildNameConfigKey, name); err != nil {
diff --git a/services/mgmt/node/impl/dispatcher.go b/services/mgmt/node/impl/dispatcher.go
index 31ad89d..2b72dcc 100644
--- a/services/mgmt/node/impl/dispatcher.go
+++ b/services/mgmt/node/impl/dispatcher.go
@@ -241,7 +241,7 @@
// prefix.
switch components[0] {
case nodeSuffix:
- receiver := node.NewServerNode(&nodeInvoker{
+ receiver := node.NodeServer(&nodeInvoker{
callback: d.internal.callback,
updating: d.internal.updating,
config: d.config,
@@ -278,17 +278,17 @@
var sigStub signatureStub
if kind == "pprof" {
label = security.DebugLabel
- sigStub = &pprof.ServerStubPProf{}
+ sigStub = pprof.PProfServer(nil)
} else {
label = security.DebugLabel | security.MonitoringLabel
- sigStub = &stats.ServerStubStats{}
+ sigStub = stats.StatsServer(nil)
}
suffix := naming.Join("__debug", naming.Join(components[4:]...))
remote := naming.JoinAddressName(info.AppCycleMgrName, suffix)
return &proxyInvoker{remote, label, sigStub}, d.auth, nil
}
}
- receiver := node.NewServerApplication(&appInvoker{
+ receiver := node.ApplicationServer(&appInvoker{
callback: d.internal.callback,
config: d.config,
suffix: components[1:],
@@ -302,7 +302,7 @@
if len(components) != 2 {
return nil, nil, errInvalidSuffix
}
- receiver := inode.NewServerConfig(&configInvoker{
+ receiver := inode.ConfigServer(&configInvoker{
callback: d.internal.callback,
suffix: components[1],
})
diff --git a/services/mgmt/node/impl/impl_test.go b/services/mgmt/node/impl/impl_test.go
index 47b7b86..8f44059 100644
--- a/services/mgmt/node/impl/impl_test.go
+++ b/services/mgmt/node/impl/impl_test.go
@@ -224,7 +224,7 @@
func ping() {
if call, err := rt.R().Client().StartCall(rt.R().NewContext(), "pingserver", "Ping", []interface{}{os.Getenv(suidhelper.SavedArgs)}); err != nil {
vlog.Fatalf("StartCall failed: %v", err)
- } else if err = call.Finish(); err != nil {
+ } else if err := call.Finish(); err != nil {
vlog.Fatalf("Finish failed: %v", err)
}
}
@@ -725,11 +725,8 @@
func tryInstall(rt veyron2.Runtime) error {
appsName := "nm//apps"
- stub, err := node.BindApplication(appsName, rt.Client())
- if err != nil {
- return fmt.Errorf("BindApplication(%v) failed: %v", appsName, err)
- }
- if _, err = stub.Install(rt.NewContext(), mockApplicationRepoName); err != nil {
+ stub := node.ApplicationClient(appsName, rt.Client())
+ if _, err := stub.Install(rt.NewContext(), mockApplicationRepoName); err != nil {
return fmt.Errorf("Install failed: %v", err)
}
return nil
@@ -763,21 +760,17 @@
defer os.RemoveAll(crDir)
*envelope = envelopeFromShell(sh, crEnv, appCmd, "google naps", "trapp")
- nodeStub, err := node.BindNode("nm//nm")
- if err != nil {
- t.Fatalf("BindNode failed: %v", err)
- }
-
+ nodeStub := node.NodeClient("nm//nm")
selfRT := rt.R()
otherRT := newRuntime(t)
defer otherRT.Cleanup()
// Nodemanager should have open ACLs before we claim it and so an Install from otherRT should succeed.
- if err = tryInstall(otherRT); err != nil {
+ if err := tryInstall(otherRT); err != nil {
t.Fatal(err)
}
// Claim the nodemanager with selfRT as <defaultblessing>/mydevice
- if err = nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "mydevice"}); err != nil {
+ if err := nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "mydevice"}); err != nil {
t.Fatal(err)
}
@@ -786,7 +779,7 @@
appID := installApp(t)
// otherRT should be unable to install though, since the ACLs have changed now.
- if err = tryInstall(otherRT); err == nil {
+ if err := tryInstall(otherRT); err == nil {
t.Fatalf("Install should have failed from otherRT")
}
@@ -852,10 +845,7 @@
defer os.RemoveAll(crDir)
*envelope = envelopeFromShell(sh, crEnv, appCmd, "google naps")
- nodeStub, err := node.BindNode("nm//nm")
- if err != nil {
- t.Fatalf("BindNode failed: %v", err)
- }
+ nodeStub := node.NodeClient("nm//nm")
acl, etag, err := nodeStub.GetACL(selfRT.NewContext())
if err != nil {
t.Fatalf("GetACL failed:%v", err)
@@ -865,7 +855,7 @@
}
// Claim the nodemanager as "root/self/mydevice"
- if err = nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "mydevice"}); err != nil {
+ if err := nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "mydevice"}); err != nil {
t.Fatal(err)
}
expectedACL := security.ACL{In: map[security.BlessingPattern]security.LabelSet{"root/self/mydevice": security.AllLabels}}
@@ -882,21 +872,21 @@
t.Fatalf("getACL expected:%v(%v), got:%v(%v)", expectedACL, expectedETAG, acl, etag)
}
// Install from otherRT should fail, since it does not match the ACL.
- if err = tryInstall(otherRT); err == nil {
+ if err := tryInstall(otherRT); err == nil {
t.Fatalf("Install should have failed with random identity")
}
newACL := security.ACL{In: map[security.BlessingPattern]security.LabelSet{"root/other": security.AllLabels}}
- if err = nodeStub.SetACL(selfRT.NewContext(), newACL, "invalid"); err == nil {
+ if err := nodeStub.SetACL(selfRT.NewContext(), newACL, "invalid"); err == nil {
t.Fatalf("SetACL should have failed with invalid etag")
}
- if err = nodeStub.SetACL(selfRT.NewContext(), newACL, etag); err != nil {
+ if err := nodeStub.SetACL(selfRT.NewContext(), newACL, etag); err != nil {
t.Fatal(err)
}
// Install should now fail with selfRT, which no longer matches the ACLs but succeed with otherRT, which does.
- if err = tryInstall(selfRT); err == nil {
+ if err := tryInstall(selfRT); err == nil {
t.Errorf("Install should have failed with selfRT since it should no longer match the ACL")
}
- if err = tryInstall(otherRT); err != nil {
+ if err := tryInstall(otherRT); err != nil {
t.Error(err)
}
}
@@ -1072,10 +1062,7 @@
}
for _, file := range files {
name := naming.Join("nm", file)
- c, err := logreader.BindLogFile(name)
- if err != nil {
- t.Fatalf("BindLogFile failed: %v", err)
- }
+ c := logreader.LogFileClient(name)
if _, err := c.Size(rt.R().NewContext()); err != nil {
t.Errorf("Size(%q) failed: %v", name, err)
}
@@ -1088,10 +1075,7 @@
}
for _, obj := range objects {
name := naming.Join("nm", obj)
- c, err := stats.BindStats(name)
- if err != nil {
- t.Fatalf("BindStats failed: %v", err)
- }
+ c := stats.StatsClient(name)
if _, err := c.Value(rt.R().NewContext()); err != nil {
t.Errorf("Value(%q) failed: %v", name, err)
}
@@ -1100,10 +1084,7 @@
// Call CmdLine() on the pprof object.
{
name := "nm/apps/google naps/" + installID + "/" + instance1ID + "/pprof"
- c, err := pprof.BindPProf(name)
- if err != nil {
- t.Fatalf("BindPProf failed: %v", err)
- }
+ c := pprof.PProfClient(name)
v, err := c.CmdLine(rt.R().NewContext())
if err != nil {
t.Errorf("CmdLine(%q) failed: %v", name, err)
@@ -1118,10 +1099,7 @@
}
func doGlob(t *testing.T, name, pattern string) []string {
- c, err := mounttable.BindGlobbable(name)
- if err != nil {
- t.Fatalf("BindGlobbable failed: %v", err)
- }
+ c := mounttable.GlobbableClient(name)
stream, err := c.Glob(rt.R().NewContext(), pattern)
if err != nil {
t.Errorf("Glob failed: %v", err)
@@ -1140,7 +1118,7 @@
return results
}
-func listAndVerifyAssociations(t *testing.T, stub node.Node, run veyron2.Runtime, expected []node.Association) {
+func listAndVerifyAssociations(t *testing.T, stub node.NodeClientMethods, run veyron2.Runtime, expected []node.Association) {
assocs, err := stub.ListAssociations(run.NewContext())
if err != nil {
t.Fatalf("ListAssociations failed %v", err)
@@ -1182,10 +1160,7 @@
pid := readPID(t, nms)
defer syscall.Kill(pid, syscall.SIGINT)
- nodeStub, err := node.BindNode("nm//nm")
- if err != nil {
- t.Fatalf("BindNode failed %v", err)
- }
+ nodeStub := node.NodeClient("nm//nm")
// Attempt to list associations on the node manager without having
// claimed it.
@@ -1194,14 +1169,14 @@
}
// self claims the node manager.
- if err = nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "alice"}); err != nil {
+ if err := nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "alice"}); err != nil {
t.Fatalf("Claim failed: %v", err)
}
vlog.VI(2).Info("Verify that associations start out empty.")
listAndVerifyAssociations(t, nodeStub, selfRT, []node.Association(nil))
- if err = nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/self", "root/other"}, "alice_system_account"); err != nil {
+ if err := nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/self", "root/other"}, "alice_system_account"); err != nil {
t.Fatalf("ListAssociations failed %v", err)
}
vlog.VI(2).Info("Added association should appear.")
@@ -1216,7 +1191,7 @@
},
})
- if err = nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/self", "root/other"}, "alice_other_account"); err != nil {
+ if err := nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/self", "root/other"}, "alice_other_account"); err != nil {
t.Fatalf("AssociateAccount failed %v", err)
}
vlog.VI(2).Info("Change the associations and the change should appear.")
@@ -1231,8 +1206,7 @@
},
})
- err = nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/other"}, "")
- if err != nil {
+ if err := nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/other"}, ""); err != nil {
t.Fatalf("AssociateAccount failed %v", err)
}
vlog.VI(2).Info("Verify that we can remove an association.")
@@ -1296,10 +1270,7 @@
pid := readPID(t, nms)
defer syscall.Kill(pid, syscall.SIGINT)
- nodeStub, err := node.BindNode("nm//nm")
- if err != nil {
- t.Fatalf("BindNode failed %v", err)
- }
+ nodeStub := node.NodeClient("nm//nm")
// Create the local server that the app uses to tell us which system name
// the node manager wished to run it as.
@@ -1320,7 +1291,7 @@
appID := installApp(t, selfRT)
// Claim the nodemanager with selfRT as root/self/alice
- if err = nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "alice"}); err != nil {
+ if err := nodeStub.Claim(selfRT.NewContext(), &granter{p: selfRT.Principal(), extension: "alice"}); err != nil {
t.Fatal(err)
}
@@ -1329,7 +1300,7 @@
startAppExpectError(t, appID, verror.NoAccess, selfRT)
// Create an association for selfRT
- if err = nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/self"}, testUserName); err != nil {
+ if err := nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/self"}, testUserName); err != nil {
t.Fatalf("AssociateAccount failed %v", err)
}
@@ -1341,7 +1312,7 @@
startAppExpectError(t, appID, verror.NoAccess, otherRT)
// Self will now let other also run apps.
- if err = nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/other"}, testUserName); err != nil {
+ if err := nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/other"}, testUserName); err != nil {
t.Fatalf("AssociateAccount failed %v", err)
}
// Add Start to the ACL list for root/other.
@@ -1350,7 +1321,7 @@
t.Fatalf("GetACL failed %v", err)
}
newACL.In["root/other/..."] = security.AllLabels
- if err = nodeStub.SetACL(selfRT.NewContext(), newACL, ""); err != nil {
+ if err := nodeStub.SetACL(selfRT.NewContext(), newACL, ""); err != nil {
t.Fatalf("SetACL failed %v", err)
}
@@ -1365,7 +1336,7 @@
suspendApp(t, appID, instance2ID, otherRT)
// Change the associated system name.
- if err = nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/other"}, anotherTestUserName); err != nil {
+ if err := nodeStub.AssociateAccount(selfRT.NewContext(), []string{"root/other"}, anotherTestUserName); err != nil {
t.Fatalf("AssociateAccount failed %v", err)
}
diff --git a/services/mgmt/node/impl/mock_repo_test.go b/services/mgmt/node/impl/mock_repo_test.go
index cc8241f..3901275 100644
--- a/services/mgmt/node/impl/mock_repo_test.go
+++ b/services/mgmt/node/impl/mock_repo_test.go
@@ -36,7 +36,7 @@
server, _ := newServer()
invoker := new(arInvoker)
name := mockApplicationRepoName
- if err := server.Serve(name, repository.NewServerApplication(invoker), nil); err != nil {
+ if err := server.Serve(name, repository.ApplicationServer(invoker), nil); err != nil {
vlog.Fatalf("Serve(%v) failed: %v", name, err)
}
return &invoker.envelope, func() {
@@ -68,7 +68,7 @@
func startBinaryRepository() func() {
server, _ := newServer()
name := mockBinaryRepoName
- if err := server.Serve(name, repository.NewServerBinary(new(brInvoker)), nil); err != nil {
+ if err := server.Serve(name, repository.BinaryServer(new(brInvoker)), nil); err != nil {
vlog.Fatalf("Serve(%q) failed: %v", name, err)
}
return func() {
@@ -92,7 +92,7 @@
var errOperationFailed = errors.New("operation failed")
-func (i *brInvoker) Download(_ ipc.ServerContext, _ int32, stream repository.BinaryServiceDownloadStream) error {
+func (i *brInvoker) Download(ctx repository.BinaryDownloadContext, _ int32) error {
vlog.VI(1).Infof("Download()")
file, err := os.Open(os.Args[0])
if err != nil {
@@ -102,7 +102,7 @@
defer file.Close()
bufferLength := 4096
buffer := make([]byte, bufferLength)
- sender := stream.SendStream()
+ sender := ctx.SendStream()
for {
n, err := file.Read(buffer)
switch err {
@@ -137,7 +137,7 @@
return []binary.PartInfo{part}, nil
}
-func (i *brInvoker) Upload(ipc.ServerContext, int32, repository.BinaryServiceUploadStream) error {
+func (i *brInvoker) Upload(repository.BinaryUploadContext, int32) error {
vlog.VI(1).Infof("Upload()")
return nil
}
diff --git a/services/mgmt/node/impl/node_invoker.go b/services/mgmt/node/impl/node_invoker.go
index f731623..0e50fdd 100644
--- a/services/mgmt/node/impl/node_invoker.go
+++ b/services/mgmt/node/impl/node_invoker.go
@@ -257,11 +257,7 @@
}
// Check that invoking Update() succeeds.
childName = naming.Join(childName, "nm")
- nmClient, err := node.BindNode(childName)
- if err != nil {
- vlog.Errorf("BindNode(%v) failed: %v", childName, err)
- return errOperationFailed
- }
+ nmClient := node.NodeClient(childName)
linkOld, pathOld, err := i.getCurrentFileInfo()
if err != nil {
return errOperationFailed
@@ -467,13 +463,13 @@
return i.disp.getACL()
}
-func (i *nodeInvoker) Glob(ctx ipc.ServerContext, pattern string, stream mounttable.GlobbableServiceGlobStream) error {
+func (i *nodeInvoker) Glob(ctx mounttable.GlobbableGlobContext, pattern string) error {
g, err := glob.Parse(pattern)
if err != nil {
return err
}
if g.Len() == 0 {
- return stream.SendStream().Send(types.MountEntry{Name: ""})
+ return ctx.SendStream().Send(types.MountEntry{Name: ""})
}
return nil
}
diff --git a/services/mgmt/node/impl/proxy_invoker_test.go b/services/mgmt/node/impl/proxy_invoker_test.go
index b2861f6..b5812c3 100644
--- a/services/mgmt/node/impl/proxy_invoker_test.go
+++ b/services/mgmt/node/impl/proxy_invoker_test.go
@@ -44,7 +44,7 @@
disp := &proxyDispatcher{
naming.JoinAddressName(ep1.String(), "__debug/stats"),
security.Label(security.AllLabels),
- &stats.ServerStubStats{},
+ stats.StatsServer(nil),
}
if err := server2.ServeDispatcher("", disp); err != nil {
t.Fatalf("server2.Serve: %v", err)
@@ -52,10 +52,7 @@
// Call Value()
name := naming.JoinAddressName(ep2.String(), "system/start-time-rfc1123")
- c, err := stats.BindStats(name)
- if err != nil {
- t.Fatalf("BindStats error: %v", err)
- }
+ c := stats.StatsClient(name)
if _, err := c.Value(r.NewContext()); err != nil {
t.Errorf("%q.Value() error: %v", name, err)
}
@@ -72,10 +69,7 @@
}
func doGlob(t *testing.T, name, pattern string) []string {
- c, err := mounttable.BindGlobbable(name)
- if err != nil {
- t.Fatalf("BindGlobbable failed: %v", err)
- }
+ c := mounttable.GlobbableClient(name)
stream, err := c.Glob(rt.R().NewContext(), pattern)
if err != nil {
t.Fatalf("Glob failed: %v", err)
diff --git a/services/mgmt/node/impl/util.go b/services/mgmt/node/impl/util.go
index e28c4ea..29ca3da 100644
--- a/services/mgmt/node/impl/util.go
+++ b/services/mgmt/node/impl/util.go
@@ -30,11 +30,7 @@
}
func fetchEnvelope(ctx context.T, origin string) (*application.Envelope, error) {
- stub, err := repository.BindApplication(origin)
- if err != nil {
- vlog.Errorf("BindRepository(%v) failed: %v", origin, err)
- return nil, errOperationFailed
- }
+ stub := repository.ApplicationClient(origin)
// TODO(jsimsa): Include logic that computes the set of supported
// profiles.
profiles := []string{"test"}
diff --git a/services/mgmt/node/impl/util_test.go b/services/mgmt/node/impl/util_test.go
index 1011dd9..00762a5 100644
--- a/services/mgmt/node/impl/util_test.go
+++ b/services/mgmt/node/impl/util_test.go
@@ -167,17 +167,13 @@
// The following set of functions are convenience wrappers around Update and
// Revert for node manager.
-func nodeStub(t *testing.T, name string) node.Node {
+func nodeStub(name string) node.NodeClientMethods {
nodeName := naming.Join(name, "nm")
- stub, err := node.BindNode(nodeName)
- if err != nil {
- t.Fatalf("%s: BindNode(%v) failed: %v", loc(1), nodeName, err)
- }
- return stub
+ return node.NodeClient(nodeName)
}
func updateNodeExpectError(t *testing.T, name string, errID verror.ID) {
- if err := nodeStub(t, name).Update(rt.R().NewContext()); !verror.Is(err, errID) {
+ if err := nodeStub(name).Update(rt.R().NewContext()); !verror.Is(err, errID) {
if errID == naming.ErrNoSuchName.ID && err.Error() == "no different version available" {
// TODO(bprosnitz) Remove this check when errUpdateNoOp is updated to verror2
return
@@ -187,13 +183,13 @@
}
func updateNode(t *testing.T, name string) {
- if err := nodeStub(t, name).Update(rt.R().NewContext()); err != nil {
+ if err := nodeStub(name).Update(rt.R().NewContext()); err != nil {
t.Fatalf("%s: Update(%v) failed: %v", loc(1), name, err)
}
}
func revertNodeExpectError(t *testing.T, name string, errID verror.ID) {
- if err := nodeStub(t, name).Revert(rt.R().NewContext()); !verror.Is(err, errID) {
+ if err := nodeStub(name).Revert(rt.R().NewContext()); !verror.Is(err, errID) {
if errID == naming.ErrNoSuchName.ID && err.Error() == "no different version available" {
// TODO(bprosnitz) Remove this check when errUpdateNoOp is updated to verror2
return
@@ -203,7 +199,7 @@
}
func revertNode(t *testing.T, name string) {
- if err := nodeStub(t, name).Revert(rt.R().NewContext()); err != nil {
+ if err := nodeStub(name).Revert(rt.R().NewContext()); err != nil {
t.Fatalf("%s: Revert(%v) failed: %v", loc(1), name, err)
}
}
@@ -219,18 +215,14 @@
}
}
-func appStub(t *testing.T, nameComponents ...string) node.Application {
+func appStub(nameComponents ...string) node.ApplicationClientMethods {
appsName := "nm//apps"
appName := naming.Join(append([]string{appsName}, nameComponents...)...)
- stub, err := node.BindApplication(appName)
- if err != nil {
- t.Fatalf("%s: BindApplication(%v) failed: %v", loc(1), appName, err)
- }
- return stub
+ return node.ApplicationClient(appName)
}
func installApp(t *testing.T, opt ...veyron2.Runtime) string {
- appID, err := appStub(t).Install(ort(opt).NewContext(), mockApplicationRepoName)
+ appID, err := appStub().Install(ort(opt).NewContext(), mockApplicationRepoName)
if err != nil {
t.Fatalf("%s: Install failed: %v", loc(1), err)
}
@@ -238,7 +230,7 @@
}
func startAppImpl(t *testing.T, appID string, opt []veyron2.Runtime) (string, error) {
- if instanceIDs, err := appStub(t, appID).Start(ort(opt).NewContext()); err != nil {
+ if instanceIDs, err := appStub(appID).Start(ort(opt).NewContext()); err != nil {
return "", err
} else {
if want, got := 1, len(instanceIDs); want != got {
@@ -263,37 +255,37 @@
}
func stopApp(t *testing.T, appID, instanceID string, opt ...veyron2.Runtime) {
- if err := appStub(t, appID, instanceID).Stop(ort(opt).NewContext(), 5); err != nil {
+ if err := appStub(appID, instanceID).Stop(ort(opt).NewContext(), 5); err != nil {
t.Fatalf("%s: Stop(%v/%v) failed: %v", loc(1), appID, instanceID, err)
}
}
func suspendApp(t *testing.T, appID, instanceID string, opt ...veyron2.Runtime) {
- if err := appStub(t, appID, instanceID).Suspend(ort(opt).NewContext()); err != nil {
+ if err := appStub(appID, instanceID).Suspend(ort(opt).NewContext()); err != nil {
t.Fatalf("%s: Suspend(%v/%v) failed: %v", loc(1), appID, instanceID, err)
}
}
func resumeApp(t *testing.T, appID, instanceID string, opt ...veyron2.Runtime) {
- if err := appStub(t, appID, instanceID).Resume(ort(opt).NewContext()); err != nil {
+ if err := appStub(appID, instanceID).Resume(ort(opt).NewContext()); err != nil {
t.Fatalf("%s: Resume(%v/%v) failed: %v", loc(1), appID, instanceID, err)
}
}
func resumeAppExpectError(t *testing.T, appID, instanceID string, expectedError verror.ID, opt ...veyron2.Runtime) {
- if err := appStub(t, appID, instanceID).Resume(ort(opt).NewContext()); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID, instanceID).Resume(ort(opt).NewContext()); err == nil || !verror.Is(err, expectedError) {
t.Fatalf("%s: Resume(%v/%v) expected to fail with %v, got %v instead", loc(1), appID, instanceID, expectedError, err)
}
}
func updateApp(t *testing.T, appID string, opt ...veyron2.Runtime) {
- if err := appStub(t, appID).Update(ort(opt).NewContext()); err != nil {
+ if err := appStub(appID).Update(ort(opt).NewContext()); err != nil {
t.Fatalf("%s: Update(%v) failed: %v", loc(1), appID, err)
}
}
func updateAppExpectError(t *testing.T, appID string, expectedError verror.ID) {
- if err := appStub(t, appID).Update(rt.R().NewContext()); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID).Update(rt.R().NewContext()); err == nil || !verror.Is(err, expectedError) {
if expectedError == naming.ErrNoSuchName.ID && err.Error() == "no different version available" {
// TODO(bprosnitz) Remove this check when errUpdateNoOp is updated to verror2
return
@@ -303,13 +295,13 @@
}
func revertApp(t *testing.T, appID string) {
- if err := appStub(t, appID).Revert(rt.R().NewContext()); err != nil {
+ if err := appStub(appID).Revert(rt.R().NewContext()); err != nil {
t.Fatalf("%s: Revert(%v) failed: %v", loc(1), appID, err)
}
}
func revertAppExpectError(t *testing.T, appID string, expectedError verror.ID) {
- if err := appStub(t, appID).Revert(rt.R().NewContext()); err == nil || !verror.Is(err, expectedError) {
+ if err := appStub(appID).Revert(rt.R().NewContext()); err == nil || !verror.Is(err, expectedError) {
if expectedError == naming.ErrNoSuchName.ID && err.Error() == "no different version available" {
// TODO(bprosnitz) Remove this check when errUpdateNoOp is updated to verror2
return
@@ -319,7 +311,7 @@
}
func uninstallApp(t *testing.T, appID string) {
- if err := appStub(t, appID).Uninstall(rt.R().NewContext()); err != nil {
+ if err := appStub(appID).Uninstall(rt.R().NewContext()); err != nil {
t.Fatalf("%s: Uninstall(%v) failed: %v", loc(1), appID, err)
}
}
diff --git a/services/mgmt/pprof/client/proxy.go b/services/mgmt/pprof/client/proxy.go
index 3562d47..7c98f77 100644
--- a/services/mgmt/pprof/client/proxy.go
+++ b/services/mgmt/pprof/client/proxy.go
@@ -65,11 +65,7 @@
return
}
}
- c, err := pprof.BindPProf(p.name)
- if err != nil {
- replyUnavailable(w, err)
- return
- }
+ c := pprof.PProfClient(p.name)
profiles, err := c.Profiles(p.rt.NewContext())
if err != nil {
replyUnavailable(w, err)
@@ -86,11 +82,7 @@
func (p *proxy) sendProfile(name string, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
debug, _ := strconv.Atoi(r.FormValue("debug"))
- c, err := pprof.BindPProf(p.name)
- if err != nil {
- replyUnavailable(w, err)
- return
- }
+ c := pprof.PProfClient(p.name)
prof, err := c.Profile(p.rt.NewContext(), name, int32(debug))
if err != nil {
replyUnavailable(w, err)
@@ -120,11 +112,7 @@
sec = 30
}
w.Header().Set("Content-Type", "application/octet-stream")
- c, err := pprof.BindPProf(p.name)
- if err != nil {
- replyUnavailable(w, err)
- return
- }
+ c := pprof.PProfClient(p.name)
prof, err := c.CPUProfile(p.rt.NewContext(), int32(sec))
if err != nil {
replyUnavailable(w, err)
@@ -149,11 +137,7 @@
// cmdLine replies with the command-line arguments of the process.
func (p *proxy) cmdLine(w http.ResponseWriter, r *http.Request) {
- c, err := pprof.BindPProf(p.name)
- if err != nil {
- replyUnavailable(w, err)
- return
- }
+ c := pprof.PProfClient(p.name)
cmdline, err := c.CmdLine(p.rt.NewContext())
if err != nil {
replyUnavailable(w, err)
@@ -190,11 +174,7 @@
break
}
}
- c, err := pprof.BindPProf(p.name)
- if err != nil {
- replyUnavailable(w, err)
- return
- }
+ c := pprof.PProfClient(p.name)
pcMap, err := c.Symbol(p.rt.NewContext(), pcList)
if err != nil {
replyUnavailable(w, err)
diff --git a/services/mgmt/profile/impl/dispatcher.go b/services/mgmt/profile/impl/dispatcher.go
index 075fcdc..9403b0d 100644
--- a/services/mgmt/profile/impl/dispatcher.go
+++ b/services/mgmt/profile/impl/dispatcher.go
@@ -30,6 +30,6 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.NewServerProfile(NewInvoker(d.store, d.storeRoot, suffix)))
+ invoker := ipc.ReflectInvoker(repository.ProfileServer(NewInvoker(d.store, d.storeRoot, suffix)))
return invoker, d.auth, nil
}
diff --git a/services/mgmt/profile/impl/impl_test.go b/services/mgmt/profile/impl/impl_test.go
index d869dc1..19a6d75 100644
--- a/services/mgmt/profile/impl/impl_test.go
+++ b/services/mgmt/profile/impl/impl_test.go
@@ -65,10 +65,7 @@
t.Logf("Profile repository at %v", endpoint)
// Create client stubs for talking to the server.
- stub, err := repository.BindProfile(naming.JoinAddressName(endpoint.String(), "//linux/base"))
- if err != nil {
- t.Fatalf("BindApplication() failed: %v", err)
- }
+ stub := repository.ProfileClient(naming.JoinAddressName(endpoint.String(), "//linux/base"))
// Put
if err := stub.Put(ctx, spec); err != nil {
diff --git a/services/mgmt/repository/repository.vdl.go b/services/mgmt/repository/repository.vdl.go
index 93dbd1a..7b82210 100644
--- a/services/mgmt/repository/repository.vdl.go
+++ b/services/mgmt/repository/repository.vdl.go
@@ -14,27 +14,26 @@
"veyron.io/veyron/veyron2/services/mgmt/repository"
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// ApplicationClientMethods is the client interface
+// containing Application methods.
+//
// Application describes an application repository internally. Besides
// the public Application interface, it allows to add and remove
// application envelopes.
-// Application is the interface the client binds and uses.
-// Application_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Application_ExcludingUniversal interface {
+type ApplicationClientMethods interface {
// Application provides access to application envelopes. An
// application envelope is identified by an application name and an
// application version, which are specified through the object name,
@@ -45,11 +44,11 @@
// returns an application envelope that can be used for downloading
// and executing the "search" application, version "v1", runnable
// on either the "base" or "media" profile.
- repository.Application_ExcludingUniversal
+ repository.ApplicationClientMethods
// Put adds the given tuple of application version (specified
// through the object name suffix) and application envelope to all
// of the given application profiles.
- Put(ctx _gen_context.T, Profiles []string, Envelope application.Envelope, opts ..._gen_ipc.CallOpt) (err error)
+ Put(ctx __context.T, Profiles []string, Envelope application.Envelope, opts ...__ipc.CallOpt) error
// Remove removes the application envelope for the given profile
// name and application version (specified through the object name
// suffix). If no version is specified as part of the suffix, the
@@ -57,180 +56,196 @@
//
// TODO(jsimsa): Add support for using "*" to specify all profiles
// when Matt implements Globing (or Ken implements querying).
- Remove(ctx _gen_context.T, Profile string, opts ..._gen_ipc.CallOpt) (err error)
-}
-type Application interface {
- _gen_ipc.UniversalServiceMethods
- Application_ExcludingUniversal
+ Remove(ctx __context.T, Profile string, opts ...__ipc.CallOpt) error
}
-// ApplicationService is the interface the server implements.
-type ApplicationService interface {
-
- // Application provides access to application envelopes. An
- // application envelope is identified by an application name and an
- // application version, which are specified through the object name,
- // and a profile name, which is specified using a method argument.
- //
- // Example:
- // /apps/search/v1.Match([]string{"base", "media"})
- // returns an application envelope that can be used for downloading
- // and executing the "search" application, version "v1", runnable
- // on either the "base" or "media" profile.
- repository.ApplicationService
- // Put adds the given tuple of application version (specified
- // through the object name suffix) and application envelope to all
- // of the given application profiles.
- Put(context _gen_ipc.ServerContext, Profiles []string, Envelope application.Envelope) (err error)
- // Remove removes the application envelope for the given profile
- // name and application version (specified through the object name
- // suffix). If no version is specified as part of the suffix, the
- // method removes all versions for the given profile.
- //
- // TODO(jsimsa): Add support for using "*" to specify all profiles
- // when Matt implements Globing (or Ken implements querying).
- Remove(context _gen_ipc.ServerContext, Profile string) (err error)
+// ApplicationClientStub adds universal methods to ApplicationClientMethods.
+type ApplicationClientStub interface {
+ ApplicationClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindApplication returns the client stub implementing the Application
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindApplication(name string, opts ..._gen_ipc.BindOpt) (Application, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// ApplicationClient returns a client stub for Application.
+func ApplicationClient(name string, opts ...__ipc.BindOpt) ApplicationClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubApplication{defaultClient: client, name: name}
- stub.Application_ExcludingUniversal, _ = repository.BindApplication(name, client)
-
- return stub, nil
+ return implApplicationClientStub{name, client, repository.ApplicationClient(name, client)}
}
-// NewServerApplication creates a new server stub.
+type implApplicationClientStub struct {
+ name string
+ client __ipc.Client
+
+ repository.ApplicationClientStub
+}
+
+func (c implApplicationClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implApplicationClientStub) Put(ctx __context.T, i0 []string, i1 application.Envelope, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Put", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implApplicationClientStub) Remove(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Remove", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implApplicationClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implApplicationClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// ApplicationServerMethods is the interface a server writer
+// implements for Application.
//
-// It takes a regular server implementing the ApplicationService
-// interface, and returns a new server stub.
-func NewServerApplication(server ApplicationService) interface{} {
- stub := &ServerStubApplication{
- ServerStubApplication: *repository.NewServerApplication(server).(*repository.ServerStubApplication),
- service: server,
+// Application describes an application repository internally. Besides
+// the public Application interface, it allows to add and remove
+// application envelopes.
+type ApplicationServerMethods interface {
+ // Application provides access to application envelopes. An
+ // application envelope is identified by an application name and an
+ // application version, which are specified through the object name,
+ // and a profile name, which is specified using a method argument.
+ //
+ // Example:
+ // /apps/search/v1.Match([]string{"base", "media"})
+ // returns an application envelope that can be used for downloading
+ // and executing the "search" application, version "v1", runnable
+ // on either the "base" or "media" profile.
+ repository.ApplicationServerMethods
+ // Put adds the given tuple of application version (specified
+ // through the object name suffix) and application envelope to all
+ // of the given application profiles.
+ Put(ctx __ipc.ServerContext, Profiles []string, Envelope application.Envelope) error
+ // Remove removes the application envelope for the given profile
+ // name and application version (specified through the object name
+ // suffix). If no version is specified as part of the suffix, the
+ // method removes all versions for the given profile.
+ //
+ // TODO(jsimsa): Add support for using "*" to specify all profiles
+ // when Matt implements Globing (or Ken implements querying).
+ Remove(ctx __ipc.ServerContext, Profile string) error
+}
+
+// ApplicationServerStubMethods is the server interface containing
+// Application methods, as expected by ipc.Server. The difference between
+// this interface and ApplicationServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type ApplicationServerStubMethods interface {
+ // Application provides access to application envelopes. An
+ // application envelope is identified by an application name and an
+ // application version, which are specified through the object name,
+ // and a profile name, which is specified using a method argument.
+ //
+ // Example:
+ // /apps/search/v1.Match([]string{"base", "media"})
+ // returns an application envelope that can be used for downloading
+ // and executing the "search" application, version "v1", runnable
+ // on either the "base" or "media" profile.
+ repository.ApplicationServerStubMethods
+ // Put adds the given tuple of application version (specified
+ // through the object name suffix) and application envelope to all
+ // of the given application profiles.
+ Put(call __ipc.ServerCall, Profiles []string, Envelope application.Envelope) error
+ // Remove removes the application envelope for the given profile
+ // name and application version (specified through the object name
+ // suffix). If no version is specified as part of the suffix, the
+ // method removes all versions for the given profile.
+ //
+ // TODO(jsimsa): Add support for using "*" to specify all profiles
+ // when Matt implements Globing (or Ken implements querying).
+ Remove(call __ipc.ServerCall, Profile string) error
+}
+
+// ApplicationServerStub adds universal methods to ApplicationServerStubMethods.
+type ApplicationServerStub interface {
+ ApplicationServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// ApplicationServer returns a server stub for Application.
+// It converts an implementation of ApplicationServerMethods into
+// an object that may be used by ipc.Server.
+func ApplicationServer(impl ApplicationServerMethods) ApplicationServerStub {
+ stub := implApplicationServerStub{
+ impl: impl,
+ ApplicationServerStub: repository.ApplicationServer(impl),
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubApplication implements Application.
-type clientStubApplication struct {
- repository.Application_ExcludingUniversal
+type implApplicationServerStub struct {
+ impl ApplicationServerMethods
+ gs *__ipc.GlobState
- defaultClient _gen_ipc.Client
- name string
+ repository.ApplicationServerStub
}
-func (__gen_c *clientStubApplication) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implApplicationServerStub) Put(call __ipc.ServerCall, i0 []string, i1 application.Envelope) error {
+ return s.impl.Put(call, i0, i1)
}
-func (__gen_c *clientStubApplication) Put(ctx _gen_context.T, Profiles []string, Envelope application.Envelope, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Put", []interface{}{Profiles, Envelope}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implApplicationServerStub) Remove(call __ipc.ServerCall, i0 string) error {
+ return s.impl.Remove(call, i0)
}
-func (__gen_c *clientStubApplication) Remove(ctx _gen_context.T, Profile string, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Remove", []interface{}{Profile}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implApplicationServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubApplication) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubApplication) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubApplication) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubApplication wraps a server that implements
-// ApplicationService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubApplication struct {
- repository.ServerStubApplication
-
- service ApplicationService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubApplication) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
- if resp, err := __gen_s.ServerStubApplication.GetMethodTags(call, method); resp != nil || err != nil {
+func (s implApplicationServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
+ if resp, err := s.ApplicationServerStub.GetMethodTags(call, method); resp != nil || err != nil {
return resp, err
}
switch method {
@@ -243,84 +258,85 @@
}
}
-func (__gen_s *ServerStubApplication) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Put"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implApplicationServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Put"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Profiles", Type: 61},
{Name: "Envelope", Type: 65},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 66},
},
}
- result.Methods["Remove"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Remove"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Profile", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 66},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x3, Name: "Title"},
- _gen_wiretype.FieldType{Type: 0x3d, Name: "Args"},
- _gen_wiretype.FieldType{Type: 0x3, Name: "Binary"},
- _gen_wiretype.FieldType{Type: 0x3d, Name: "Env"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x3, Name: "Title"},
+ __wiretype.FieldType{Type: 0x3d, Name: "Args"},
+ __wiretype.FieldType{Type: 0x3, Name: "Binary"},
+ __wiretype.FieldType{Type: 0x3d, Name: "Env"},
},
"veyron.io/veyron/veyron2/services/mgmt/application.Envelope", []string(nil)},
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
- var ss _gen_ipc.ServiceSignature
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ var ss __ipc.ServiceSignature
var firstAdded int
- ss, _ = __gen_s.ServerStubApplication.Signature(call)
+ ss, _ = s.ApplicationServerStub.Signature(call)
firstAdded = len(result.TypeDefs)
for k, v := range ss.Methods {
for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
- if v.InStream >= _gen_wiretype.TypeIDFirst {
- v.InStream += _gen_wiretype.TypeID(firstAdded)
+ if v.InStream >= __wiretype.TypeIDFirst {
+ v.InStream += __wiretype.TypeID(firstAdded)
}
- if v.OutStream >= _gen_wiretype.TypeIDFirst {
- v.OutStream += _gen_wiretype.TypeID(firstAdded)
+ if v.OutStream >= __wiretype.TypeIDFirst {
+ v.OutStream += __wiretype.TypeID(firstAdded)
}
result.Methods[k] = v
}
//TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
for _, d := range ss.TypeDefs {
switch wt := d.(type) {
- case _gen_wiretype.SliceType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.SliceType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.ArrayType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.ArrayType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.MapType:
- if wt.Key >= _gen_wiretype.TypeIDFirst {
- wt.Key += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.MapType:
+ if wt.Key >= __wiretype.TypeIDFirst {
+ wt.Key += __wiretype.TypeID(firstAdded)
}
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.StructType:
+ case __wiretype.StructType:
for i, fld := range wt.Fields {
- if fld.Type >= _gen_wiretype.TypeIDFirst {
- wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if fld.Type >= __wiretype.TypeIDFirst {
+ wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
}
}
d = wt
@@ -332,233 +348,211 @@
return result, nil
}
-func (__gen_s *ServerStubApplication) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubApplication) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubApplication) Put(call _gen_ipc.ServerCall, Profiles []string, Envelope application.Envelope) (err error) {
- err = __gen_s.service.Put(call, Profiles, Envelope)
- return
-}
-
-func (__gen_s *ServerStubApplication) Remove(call _gen_ipc.ServerCall, Profile string) (err error) {
- err = __gen_s.service.Remove(call, Profile)
- return
-}
-
+// ProfileClientMethods is the client interface
+// containing Profile methods.
+//
// Profile describes a profile internally. Besides the public Profile
// interface, it allows to add and remove profile specifications.
-// Profile is the interface the client binds and uses.
-// Profile_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Profile_ExcludingUniversal interface {
+type ProfileClientMethods interface {
// Profile abstracts a device's ability to run binaries, and hides
// specifics such as the operating system, hardware architecture, and
// the set of installed libraries. Profiles describe binaries and
// devices, and are used to match them.
- repository.Profile_ExcludingUniversal
+ repository.ProfileClientMethods
// Specification returns the profile specification for the profile
// identified through the object name suffix.
- Specification(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply profile.Specification, err error)
+ Specification(__context.T, ...__ipc.CallOpt) (profile.Specification, error)
// Put sets the profile specification for the profile identified
// through the object name suffix.
- Put(ctx _gen_context.T, Specification profile.Specification, opts ..._gen_ipc.CallOpt) (err error)
+ Put(ctx __context.T, Specification profile.Specification, opts ...__ipc.CallOpt) error
// Remove removes the profile specification for the profile
// identified through the object name suffix.
- Remove(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error)
-}
-type Profile interface {
- _gen_ipc.UniversalServiceMethods
- Profile_ExcludingUniversal
+ Remove(__context.T, ...__ipc.CallOpt) error
}
-// ProfileService is the interface the server implements.
-type ProfileService interface {
-
- // Profile abstracts a device's ability to run binaries, and hides
- // specifics such as the operating system, hardware architecture, and
- // the set of installed libraries. Profiles describe binaries and
- // devices, and are used to match them.
- repository.ProfileService
- // Specification returns the profile specification for the profile
- // identified through the object name suffix.
- Specification(context _gen_ipc.ServerContext) (reply profile.Specification, err error)
- // Put sets the profile specification for the profile identified
- // through the object name suffix.
- Put(context _gen_ipc.ServerContext, Specification profile.Specification) (err error)
- // Remove removes the profile specification for the profile
- // identified through the object name suffix.
- Remove(context _gen_ipc.ServerContext) (err error)
+// ProfileClientStub adds universal methods to ProfileClientMethods.
+type ProfileClientStub interface {
+ ProfileClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindProfile returns the client stub implementing the Profile
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindProfile(name string, opts ..._gen_ipc.BindOpt) (Profile, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// ProfileClient returns a client stub for Profile.
+func ProfileClient(name string, opts ...__ipc.BindOpt) ProfileClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubProfile{defaultClient: client, name: name}
- stub.Profile_ExcludingUniversal, _ = repository.BindProfile(name, client)
-
- return stub, nil
+ return implProfileClientStub{name, client, repository.ProfileClient(name, client)}
}
-// NewServerProfile creates a new server stub.
+type implProfileClientStub struct {
+ name string
+ client __ipc.Client
+
+ repository.ProfileClientStub
+}
+
+func (c implProfileClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implProfileClientStub) Specification(ctx __context.T, opts ...__ipc.CallOpt) (o0 profile.Specification, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Specification", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implProfileClientStub) Put(ctx __context.T, i0 profile.Specification, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Put", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implProfileClientStub) Remove(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Remove", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implProfileClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implProfileClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// ProfileServerMethods is the interface a server writer
+// implements for Profile.
//
-// It takes a regular server implementing the ProfileService
-// interface, and returns a new server stub.
-func NewServerProfile(server ProfileService) interface{} {
- stub := &ServerStubProfile{
- ServerStubProfile: *repository.NewServerProfile(server).(*repository.ServerStubProfile),
- service: server,
+// Profile describes a profile internally. Besides the public Profile
+// interface, it allows to add and remove profile specifications.
+type ProfileServerMethods interface {
+ // Profile abstracts a device's ability to run binaries, and hides
+ // specifics such as the operating system, hardware architecture, and
+ // the set of installed libraries. Profiles describe binaries and
+ // devices, and are used to match them.
+ repository.ProfileServerMethods
+ // Specification returns the profile specification for the profile
+ // identified through the object name suffix.
+ Specification(__ipc.ServerContext) (profile.Specification, error)
+ // Put sets the profile specification for the profile identified
+ // through the object name suffix.
+ Put(ctx __ipc.ServerContext, Specification profile.Specification) error
+ // Remove removes the profile specification for the profile
+ // identified through the object name suffix.
+ Remove(__ipc.ServerContext) error
+}
+
+// ProfileServerStubMethods is the server interface containing
+// Profile methods, as expected by ipc.Server. The difference between
+// this interface and ProfileServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type ProfileServerStubMethods interface {
+ // Profile abstracts a device's ability to run binaries, and hides
+ // specifics such as the operating system, hardware architecture, and
+ // the set of installed libraries. Profiles describe binaries and
+ // devices, and are used to match them.
+ repository.ProfileServerStubMethods
+ // Specification returns the profile specification for the profile
+ // identified through the object name suffix.
+ Specification(__ipc.ServerCall) (profile.Specification, error)
+ // Put sets the profile specification for the profile identified
+ // through the object name suffix.
+ Put(call __ipc.ServerCall, Specification profile.Specification) error
+ // Remove removes the profile specification for the profile
+ // identified through the object name suffix.
+ Remove(__ipc.ServerCall) error
+}
+
+// ProfileServerStub adds universal methods to ProfileServerStubMethods.
+type ProfileServerStub interface {
+ ProfileServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// ProfileServer returns a server stub for Profile.
+// It converts an implementation of ProfileServerMethods into
+// an object that may be used by ipc.Server.
+func ProfileServer(impl ProfileServerMethods) ProfileServerStub {
+ stub := implProfileServerStub{
+ impl: impl,
+ ProfileServerStub: repository.ProfileServer(impl),
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubProfile implements Profile.
-type clientStubProfile struct {
- repository.Profile_ExcludingUniversal
+type implProfileServerStub struct {
+ impl ProfileServerMethods
+ gs *__ipc.GlobState
- defaultClient _gen_ipc.Client
- name string
+ repository.ProfileServerStub
}
-func (__gen_c *clientStubProfile) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implProfileServerStub) Specification(call __ipc.ServerCall) (profile.Specification, error) {
+ return s.impl.Specification(call)
}
-func (__gen_c *clientStubProfile) Specification(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply profile.Specification, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Specification", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implProfileServerStub) Put(call __ipc.ServerCall, i0 profile.Specification) error {
+ return s.impl.Put(call, i0)
}
-func (__gen_c *clientStubProfile) Put(ctx _gen_context.T, Specification profile.Specification, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Put", []interface{}{Specification}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implProfileServerStub) Remove(call __ipc.ServerCall) error {
+ return s.impl.Remove(call)
}
-func (__gen_c *clientStubProfile) Remove(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Remove", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implProfileServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubProfile) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubProfile) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubProfile) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubProfile wraps a server that implements
-// ProfileService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubProfile struct {
- repository.ServerStubProfile
-
- service ProfileService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubProfile) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
- if resp, err := __gen_s.ServerStubProfile.GetMethodTags(call, method); resp != nil || err != nil {
+func (s implProfileServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
+ if resp, err := s.ProfileServerStub.GetMethodTags(call, method); resp != nil || err != nil {
return resp, err
}
switch method {
@@ -573,97 +567,98 @@
}
}
-func (__gen_s *ServerStubProfile) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Put"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implProfileServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Put"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Specification", Type: 70},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 71},
},
}
- result.Methods["Remove"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Remove"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 71},
},
}
- result.Methods["Specification"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Specification"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 70},
{Name: "", Type: 71},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/services/mgmt/build.Architecture", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/services/mgmt/build.Format", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x3, Name: "Name"},
- _gen_wiretype.FieldType{Type: 0x3, Name: "MajorVersion"},
- _gen_wiretype.FieldType{Type: 0x3, Name: "MinorVersion"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/services/mgmt/build.Architecture", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/services/mgmt/build.Format", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x3, Name: "Name"},
+ __wiretype.FieldType{Type: 0x3, Name: "MajorVersion"},
+ __wiretype.FieldType{Type: 0x3, Name: "MinorVersion"},
},
"veyron.io/veyron/veyron/services/mgmt/profile.Library", []string(nil)},
- _gen_wiretype.MapType{Key: 0x43, Elem: 0x2, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/services/mgmt/build.OperatingSystem", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x41, Name: "Arch"},
- _gen_wiretype.FieldType{Type: 0x3, Name: "Description"},
- _gen_wiretype.FieldType{Type: 0x42, Name: "Format"},
- _gen_wiretype.FieldType{Type: 0x44, Name: "Libraries"},
- _gen_wiretype.FieldType{Type: 0x3, Name: "Label"},
- _gen_wiretype.FieldType{Type: 0x45, Name: "OS"},
+ __wiretype.MapType{Key: 0x43, Elem: 0x2, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/services/mgmt/build.OperatingSystem", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x41, Name: "Arch"},
+ __wiretype.FieldType{Type: 0x3, Name: "Description"},
+ __wiretype.FieldType{Type: 0x42, Name: "Format"},
+ __wiretype.FieldType{Type: 0x44, Name: "Libraries"},
+ __wiretype.FieldType{Type: 0x3, Name: "Label"},
+ __wiretype.FieldType{Type: 0x45, Name: "OS"},
},
"veyron.io/veyron/veyron/services/mgmt/profile.Specification", []string(nil)},
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
- var ss _gen_ipc.ServiceSignature
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ var ss __ipc.ServiceSignature
var firstAdded int
- ss, _ = __gen_s.ServerStubProfile.Signature(call)
+ ss, _ = s.ProfileServerStub.Signature(call)
firstAdded = len(result.TypeDefs)
for k, v := range ss.Methods {
for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst {
- v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
+ v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
}
}
- if v.InStream >= _gen_wiretype.TypeIDFirst {
- v.InStream += _gen_wiretype.TypeID(firstAdded)
+ if v.InStream >= __wiretype.TypeIDFirst {
+ v.InStream += __wiretype.TypeID(firstAdded)
}
- if v.OutStream >= _gen_wiretype.TypeIDFirst {
- v.OutStream += _gen_wiretype.TypeID(firstAdded)
+ if v.OutStream >= __wiretype.TypeIDFirst {
+ v.OutStream += __wiretype.TypeID(firstAdded)
}
result.Methods[k] = v
}
//TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
for _, d := range ss.TypeDefs {
switch wt := d.(type) {
- case _gen_wiretype.SliceType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.SliceType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.ArrayType:
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.ArrayType:
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.MapType:
- if wt.Key >= _gen_wiretype.TypeIDFirst {
- wt.Key += _gen_wiretype.TypeID(firstAdded)
+ case __wiretype.MapType:
+ if wt.Key >= __wiretype.TypeIDFirst {
+ wt.Key += __wiretype.TypeID(firstAdded)
}
- if wt.Elem >= _gen_wiretype.TypeIDFirst {
- wt.Elem += _gen_wiretype.TypeID(firstAdded)
+ if wt.Elem >= __wiretype.TypeIDFirst {
+ wt.Elem += __wiretype.TypeID(firstAdded)
}
d = wt
- case _gen_wiretype.StructType:
+ case __wiretype.StructType:
for i, fld := range wt.Fields {
- if fld.Type >= _gen_wiretype.TypeIDFirst {
- wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded)
+ if fld.Type >= __wiretype.TypeIDFirst {
+ wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
}
}
d = wt
@@ -674,40 +669,3 @@
return result, nil
}
-
-func (__gen_s *ServerStubProfile) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubProfile) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubProfile) Specification(call _gen_ipc.ServerCall) (reply profile.Specification, err error) {
- reply, err = __gen_s.service.Specification(call)
- return
-}
-
-func (__gen_s *ServerStubProfile) Put(call _gen_ipc.ServerCall, Specification profile.Specification) (err error) {
- err = __gen_s.service.Put(call, Specification)
- return
-}
-
-func (__gen_s *ServerStubProfile) Remove(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.Remove(call)
- return
-}
diff --git a/services/mgmt/root/impl/dispatcher.go b/services/mgmt/root/impl/dispatcher.go
index 6cf5ee6..015f739 100644
--- a/services/mgmt/root/impl/dispatcher.go
+++ b/services/mgmt/root/impl/dispatcher.go
@@ -21,5 +21,5 @@
// DISPATCHER INTERFACE IMPLEMENTATION
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- return ipc.ReflectInvoker(root.NewServerRoot(d.state)), nil, nil
+ return ipc.ReflectInvoker(root.RootServer(d.state)), nil, nil
}
diff --git a/services/mgmt/root/root.vdl.go b/services/mgmt/root/root.vdl.go
index 452cff5..bf7a05e 100644
--- a/services/mgmt/root/root.vdl.go
+++ b/services/mgmt/root/root.vdl.go
@@ -6,111 +6,62 @@
package root
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// RootClientMethods is the client interface
+// containing Root methods.
+//
// Root is an interface to be implemented by a process with root level
// privileges.
-// Root is the interface the client binds and uses.
-// Root_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Root_ExcludingUniversal interface {
+type RootClientMethods interface {
// Reset waits for the given deadline (in milliseconds) and then
// restars the host node machine.
- Reset(ctx _gen_context.T, Deadline uint64, opts ..._gen_ipc.CallOpt) (err error)
-}
-type Root interface {
- _gen_ipc.UniversalServiceMethods
- Root_ExcludingUniversal
+ Reset(ctx __context.T, Deadline uint64, opts ...__ipc.CallOpt) error
}
-// RootService is the interface the server implements.
-type RootService interface {
-
- // Reset waits for the given deadline (in milliseconds) and then
- // restars the host node machine.
- Reset(context _gen_ipc.ServerContext, Deadline uint64) (err error)
+// RootClientStub adds universal methods to RootClientMethods.
+type RootClientStub interface {
+ RootClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindRoot returns the client stub implementing the Root
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindRoot(name string, opts ..._gen_ipc.BindOpt) (Root, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// RootClient returns a client stub for Root.
+func RootClient(name string, opts ...__ipc.BindOpt) RootClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubRoot{defaultClient: client, name: name}
-
- return stub, nil
+ return implRootClientStub{name, client}
}
-// NewServerRoot creates a new server stub.
-//
-// It takes a regular server implementing the RootService
-// interface, and returns a new server stub.
-func NewServerRoot(server RootService) interface{} {
- stub := &ServerStubRoot{
- service: server,
- }
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
- return stub
+type implRootClientStub struct {
+ name string
+ client __ipc.Client
}
-// clientStubRoot implements Root.
-type clientStubRoot struct {
- defaultClient _gen_ipc.Client
- name string
-}
-
-func (__gen_c *clientStubRoot) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
+func (c implRootClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
}
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+ return __veyron2.RuntimeFromContext(ctx).Client()
}
-func (__gen_c *clientStubRoot) Reset(ctx _gen_context.T, Deadline uint64, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Reset", []interface{}{Deadline}, opts...); err != nil {
+func (c implRootClientStub) Reset(ctx __context.T, i0 uint64, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Reset", []interface{}{i0}, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
@@ -119,51 +70,91 @@
return
}
-func (__gen_c *clientStubRoot) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
+func (c implRootClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubRoot) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
+func (c implRootClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubRoot) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+// RootServerMethods is the interface a server writer
+// implements for Root.
+//
+// Root is an interface to be implemented by a process with root level
+// privileges.
+type RootServerMethods interface {
+ // Reset waits for the given deadline (in milliseconds) and then
+ // restars the host node machine.
+ Reset(ctx __ipc.ServerContext, Deadline uint64) error
}
-// ServerStubRoot wraps a server that implements
-// RootService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubRoot struct {
- service RootService
- gs *_gen_ipc.GlobState
+// RootServerStubMethods is the server interface containing
+// Root methods, as expected by ipc.Server. The difference between
+// this interface and RootServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type RootServerStubMethods interface {
+ // Reset waits for the given deadline (in milliseconds) and then
+ // restars the host node machine.
+ Reset(call __ipc.ServerCall, Deadline uint64) error
}
-func (__gen_s *ServerStubRoot) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+// RootServerStub adds universal methods to RootServerStubMethods.
+type RootServerStub interface {
+ RootServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// RootServer returns a server stub for Root.
+// It converts an implementation of RootServerMethods into
+// an object that may be used by ipc.Server.
+func RootServer(impl RootServerMethods) RootServerStub {
+ stub := implRootServerStub{
+ impl: impl,
+ }
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
+ }
+ return stub
+}
+
+type implRootServerStub struct {
+ impl RootServerMethods
+ gs *__ipc.GlobState
+}
+
+func (s implRootServerStub) Reset(call __ipc.ServerCall, i0 uint64) error {
+ return s.impl.Reset(call, i0)
+}
+
+func (s implRootServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
+}
+
+func (s implRootServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Reset":
return []interface{}{}, nil
@@ -172,46 +163,20 @@
}
}
-func (__gen_s *ServerStubRoot) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Reset"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implRootServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Reset"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Deadline", Type: 53},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubRoot) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubRoot) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubRoot) Reset(call _gen_ipc.ServerCall, Deadline uint64) (err error) {
- err = __gen_s.service.Reset(call, Deadline)
- return
-}
diff --git a/services/mgmt/stats/impl/stats_invoker_test.go b/services/mgmt/stats/impl/stats_invoker_test.go
index e830fad..6a5b08d 100644
--- a/services/mgmt/stats/impl/stats_invoker_test.go
+++ b/services/mgmt/stats/impl/stats_invoker_test.go
@@ -64,10 +64,7 @@
histogram.Add(int64(i))
}
- c, err := stats.BindStats(naming.JoinAddressName(endpoint, ""))
- if err != nil {
- t.Errorf("BindStats: %v", err)
- }
+ c := stats.StatsClient(naming.JoinAddressName(endpoint, ""))
// Test Glob()
{
@@ -154,10 +151,7 @@
// Test Value()
{
- c, err := stats.BindStats(naming.JoinAddressName(endpoint, "//testing/foo/bar"))
- if err != nil {
- t.Errorf("BindStats: %v", err)
- }
+ c := stats.StatsClient(naming.JoinAddressName(endpoint, "//testing/foo/bar"))
value, err := c.Value(rt.R().NewContext())
if err != nil {
t.Errorf("unexpected error: %v", err)
@@ -169,10 +163,7 @@
// Test Value() with Histogram
{
- c, err := stats.BindStats(naming.JoinAddressName(endpoint, "//testing/hist/foo"))
- if err != nil {
- t.Errorf("BindStats: %v", err)
- }
+ c := stats.StatsClient(naming.JoinAddressName(endpoint, "//testing/hist/foo"))
value, err := c.Value(rt.R().NewContext())
if err != nil {
t.Errorf("unexpected error: %v", err)
diff --git a/services/mounttable/lib/collection_test_interface.vdl.go b/services/mounttable/lib/collection_test_interface.vdl.go
index 377eeb2..7095c00 100644
--- a/services/mounttable/lib/collection_test_interface.vdl.go
+++ b/services/mounttable/lib/collection_test_interface.vdl.go
@@ -4,119 +4,64 @@
package mounttable
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
-// Collection is the interface the client binds and uses.
-// Collection_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Collection_ExcludingUniversal interface {
+// CollectionClientMethods is the client interface
+// containing Collection methods.
+type CollectionClientMethods interface {
// Export sets the value for a name. Overwrite controls the behavior when
// an entry exists, if Overwrite is true, then the binding is replaced,
// otherwise the call fails with an error. The Val must be no larger than
// MaxSize bytes.
- Export(ctx _gen_context.T, Val string, Overwrite bool, opts ..._gen_ipc.CallOpt) (err error)
+ Export(ctx __context.T, Val string, Overwrite bool, opts ...__ipc.CallOpt) error
// Lookup retrieves the value associated with a name. Returns an error if
// there is no such binding.
- Lookup(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []byte, err error)
-}
-type Collection interface {
- _gen_ipc.UniversalServiceMethods
- Collection_ExcludingUniversal
+ Lookup(__context.T, ...__ipc.CallOpt) ([]byte, error)
}
-// CollectionService is the interface the server implements.
-type CollectionService interface {
-
- // Export sets the value for a name. Overwrite controls the behavior when
- // an entry exists, if Overwrite is true, then the binding is replaced,
- // otherwise the call fails with an error. The Val must be no larger than
- // MaxSize bytes.
- Export(context _gen_ipc.ServerContext, Val string, Overwrite bool) (err error)
- // Lookup retrieves the value associated with a name. Returns an error if
- // there is no such binding.
- Lookup(context _gen_ipc.ServerContext) (reply []byte, err error)
+// CollectionClientStub adds universal methods to CollectionClientMethods.
+type CollectionClientStub interface {
+ CollectionClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindCollection returns the client stub implementing the Collection
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindCollection(name string, opts ..._gen_ipc.BindOpt) (Collection, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// CollectionClient returns a client stub for Collection.
+func CollectionClient(name string, opts ...__ipc.BindOpt) CollectionClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubCollection{defaultClient: client, name: name}
-
- return stub, nil
+ return implCollectionClientStub{name, client}
}
-// NewServerCollection creates a new server stub.
-//
-// It takes a regular server implementing the CollectionService
-// interface, and returns a new server stub.
-func NewServerCollection(server CollectionService) interface{} {
- stub := &ServerStubCollection{
- service: server,
- }
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
- return stub
+type implCollectionClientStub struct {
+ name string
+ client __ipc.Client
}
-// clientStubCollection implements Collection.
-type clientStubCollection struct {
- defaultClient _gen_ipc.Client
- name string
-}
-
-func (__gen_c *clientStubCollection) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
+func (c implCollectionClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
}
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+ return __veyron2.RuntimeFromContext(ctx).Client()
}
-func (__gen_c *clientStubCollection) Export(ctx _gen_context.T, Val string, Overwrite bool, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Export", []interface{}{Val, Overwrite}, opts...); err != nil {
+func (c implCollectionClientStub) Export(ctx __context.T, i0 string, i1 bool, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Export", []interface{}{i0, i1}, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
@@ -125,62 +70,113 @@
return
}
-func (__gen_c *clientStubCollection) Lookup(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Lookup", nil, opts...); err != nil {
+func (c implCollectionClientStub) Lookup(ctx __context.T, opts ...__ipc.CallOpt) (o0 []byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Lookup", nil, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubCollection) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
+func (c implCollectionClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubCollection) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
+func (c implCollectionClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
return
}
- if ierr := call.Finish(&reply, &err); ierr != nil {
+ if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
-func (__gen_c *clientStubCollection) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+// CollectionServerMethods is the interface a server writer
+// implements for Collection.
+type CollectionServerMethods interface {
+ // Export sets the value for a name. Overwrite controls the behavior when
+ // an entry exists, if Overwrite is true, then the binding is replaced,
+ // otherwise the call fails with an error. The Val must be no larger than
+ // MaxSize bytes.
+ Export(ctx __ipc.ServerContext, Val string, Overwrite bool) error
+ // Lookup retrieves the value associated with a name. Returns an error if
+ // there is no such binding.
+ Lookup(__ipc.ServerContext) ([]byte, error)
}
-// ServerStubCollection wraps a server that implements
-// CollectionService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubCollection struct {
- service CollectionService
- gs *_gen_ipc.GlobState
+// CollectionServerStubMethods is the server interface containing
+// Collection methods, as expected by ipc.Server. The difference between
+// this interface and CollectionServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type CollectionServerStubMethods interface {
+ // Export sets the value for a name. Overwrite controls the behavior when
+ // an entry exists, if Overwrite is true, then the binding is replaced,
+ // otherwise the call fails with an error. The Val must be no larger than
+ // MaxSize bytes.
+ Export(call __ipc.ServerCall, Val string, Overwrite bool) error
+ // Lookup retrieves the value associated with a name. Returns an error if
+ // there is no such binding.
+ Lookup(__ipc.ServerCall) ([]byte, error)
}
-func (__gen_s *ServerStubCollection) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+// CollectionServerStub adds universal methods to CollectionServerStubMethods.
+type CollectionServerStub interface {
+ CollectionServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// CollectionServer returns a server stub for Collection.
+// It converts an implementation of CollectionServerMethods into
+// an object that may be used by ipc.Server.
+func CollectionServer(impl CollectionServerMethods) CollectionServerStub {
+ stub := implCollectionServerStub{
+ impl: impl,
+ }
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
+ }
+ return stub
+}
+
+type implCollectionServerStub struct {
+ impl CollectionServerMethods
+ gs *__ipc.GlobState
+}
+
+func (s implCollectionServerStub) Export(call __ipc.ServerCall, i0 string, i1 bool) error {
+ return s.impl.Export(call, i0, i1)
+}
+
+func (s implCollectionServerStub) Lookup(call __ipc.ServerCall) ([]byte, error) {
+ return s.impl.Lookup(call)
+}
+
+func (s implCollectionServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
+}
+
+func (s implCollectionServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Export":
return []interface{}{}, nil
@@ -191,59 +187,28 @@
}
}
-func (__gen_s *ServerStubCollection) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Export"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implCollectionServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Export"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Val", Type: 3},
{Name: "Overwrite", Type: 2},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.Methods["Lookup"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["Lookup"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 67},
{Name: "", Type: 65},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}}
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubCollection) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubCollection) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubCollection) Export(call _gen_ipc.ServerCall, Val string, Overwrite bool) (err error) {
- err = __gen_s.service.Export(call, Val, Overwrite)
- return
-}
-
-func (__gen_s *ServerStubCollection) Lookup(call _gen_ipc.ServerCall) (reply []byte, err error) {
- reply, err = __gen_s.service.Lookup(call)
- return
-}
diff --git a/services/mounttable/lib/collectionserver_test.go b/services/mounttable/lib/collectionserver_test.go
index 4f1c5ff..3822118 100644
--- a/services/mounttable/lib/collectionserver_test.go
+++ b/services/mounttable/lib/collectionserver_test.go
@@ -39,7 +39,7 @@
return nil
}
-// Export implements CollectionService.Export.
+// Export implements CollectionServerMethods.Export.
func (c *rpcContext) Export(ctx ipc.ServerCall, val []byte, overwrite bool) error {
c.Lock()
defer c.Unlock()
@@ -50,7 +50,7 @@
return verror.Make(naming.ErrNameExists, ctx, c.name)
}
-// Lookup implements CollectionService.Lookup.
+// Lookup implements CollectionServerMethods.Lookup.
func (c *rpcContext) Lookup(ctx ipc.ServerCall) ([]byte, error) {
c.Lock()
defer c.Unlock()
diff --git a/services/mounttable/lib/mounttable.go b/services/mounttable/lib/mounttable.go
index f13dd72..e01a03e 100644
--- a/services/mounttable/lib/mounttable.go
+++ b/services/mounttable/lib/mounttable.go
@@ -107,7 +107,7 @@
ms.elems = strings.Split(name, "/")
ms.cleanedElems = strings.Split(strings.TrimLeft(path.Clean(name), "/"), "/")
}
- return ipc.ReflectInvoker(mounttable.NewServerMountTable(ms)), ms, nil
+ return ipc.ReflectInvoker(mounttable.MountTableServer(ms)), ms, nil
}
// findNode returns the node for the name path represented by elems. If none exists and create is false, return nil.
@@ -365,7 +365,7 @@
name string
}
-func (mt *mountTable) globStep(n *node, name string, pattern *glob.Glob, context ipc.ServerContext, reply mounttable.GlobbableServiceGlobStream) {
+func (mt *mountTable) globStep(n *node, name string, pattern *glob.Glob, context mounttable.GlobbableGlobContext) {
vlog.VI(2).Infof("globStep(%s, %s)", name, pattern)
if mt.acls != nil {
@@ -378,7 +378,7 @@
}
}
- sender := reply.SendStream()
+ sender := context.SendStream()
// If this is a mount point, we're done.
if m := n.mount; m != nil {
// Garbage-collect if expired.
@@ -410,7 +410,7 @@
// Recurse through the children.
for k, c := range n.children {
if ok, _, suffix := pattern.MatchInitialSegment(k); ok {
- mt.globStep(c, naming.Join(name, k), suffix, context, reply)
+ mt.globStep(c, naming.Join(name, k), suffix, context)
}
}
}
@@ -418,7 +418,7 @@
// Glob finds matches in the namespace. If we reach a mount point before matching the
// whole pattern, return that mount point.
// pattern is a glob pattern as defined by the veyron/lib/glob package.
-func (ms *mountContext) Glob(context ipc.ServerContext, pattern string, reply mounttable.GlobbableServiceGlobStream) error {
+func (ms *mountContext) Glob(context mounttable.GlobbableGlobContext, pattern string) error {
vlog.VI(2).Infof("mt.Glob %v", ms.elems)
g, err := glob.Parse(pattern)
@@ -439,15 +439,15 @@
// name back to the client.
n := mt.findNode(ms.cleanedElems, false)
if n == nil {
- ms.linkToLeaf(reply)
+ ms.linkToLeaf(context)
return nil
}
- mt.globStep(n, "", g, context, reply)
+ mt.globStep(n, "", g, context)
return nil
}
-func (ms *mountContext) linkToLeaf(reply mounttable.GlobbableServiceGlobStream) {
+func (ms *mountContext) linkToLeaf(stream mounttable.GlobbableGlobServerStream) {
n, elems := ms.mt.walk(ms.mt.root, ms.cleanedElems)
if n == nil {
return
@@ -456,5 +456,5 @@
for i, s := range servers {
servers[i].Server = naming.Join(s.Server, slashSlashJoin(elems))
}
- reply.SendStream().Send(types.MountEntry{Name: "", Servers: servers})
+ stream.SendStream().Send(types.MountEntry{Name: "", Servers: servers})
}
diff --git a/services/mounttable/lib/neighborhood.go b/services/mounttable/lib/neighborhood.go
index 868ecfe..d29f8f1 100644
--- a/services/mounttable/lib/neighborhood.go
+++ b/services/mounttable/lib/neighborhood.go
@@ -135,7 +135,7 @@
elems: elems,
nh: nh,
}
- return ipc.ReflectInvoker(mounttable.NewServerMountTable(ns)), nh, nil
+ return ipc.ReflectInvoker(mounttable.MountTableServer(ns)), nh, nil
}
func (nh *neighborhood) Authorize(context security.Context) error {
@@ -257,7 +257,7 @@
}
// Glob implements Glob
-func (ns *neighborhoodService) Glob(ctx ipc.ServerContext, pattern string, reply mounttable.GlobbableServiceGlobStream) error {
+func (ns *neighborhoodService) Glob(ctx mounttable.GlobbableGlobContext, pattern string) error {
g, err := glob.Parse(pattern)
if err != nil {
return err
@@ -266,7 +266,7 @@
// return all neighbors that match the first element of the pattern.
nh := ns.nh
- sender := reply.SendStream()
+ sender := ctx.SendStream()
switch len(ns.elems) {
case 0:
for k, n := range nh.neighbors() {
diff --git a/services/security/discharger.vdl.go b/services/security/discharger.vdl.go
index b36f608..f7dd8b8 100644
--- a/services/security/discharger.vdl.go
+++ b/services/security/discharger.vdl.go
@@ -6,25 +6,24 @@
import (
"veyron.io/veyron/veyron2/security"
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
+const _ = __wiretype.TypeIDInvalid
+// DischargerClientMethods is the client interface
+// containing Discharger methods.
+//
// Discharger is the interface for obtaining discharges for ThirdPartyCaveats.
-// Discharger is the interface the client binds and uses.
-// Discharger_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type Discharger_ExcludingUniversal interface {
+type DischargerClientMethods interface {
// Discharge is called by a principal that holds a blessing with a third
// party caveat and seeks to get a discharge that proves the fulfillment of
// this caveat.
@@ -33,148 +32,145 @@
// respectively. (not enforced here because vdl does not know these types)
// TODO(ataly,ashankar): Figure out a VDL representation for ThirdPartyCaveat
// and Discharge and use those here?
- Discharge(ctx _gen_context.T, Caveat _gen_vdlutil.Any, Impetus security.DischargeImpetus, opts ..._gen_ipc.CallOpt) (reply _gen_vdlutil.Any, err error)
-}
-type Discharger interface {
- _gen_ipc.UniversalServiceMethods
- Discharger_ExcludingUniversal
+ Discharge(ctx __context.T, Caveat __vdlutil.Any, Impetus security.DischargeImpetus, opts ...__ipc.CallOpt) (Discharge __vdlutil.Any, err error)
}
-// DischargerService is the interface the server implements.
-type DischargerService interface {
-
- // Discharge is called by a principal that holds a blessing with a third
- // party caveat and seeks to get a discharge that proves the fulfillment of
- // this caveat.
- //
- // Caveat and Discharge are of type ThirdPartyCaveat and Discharge
- // respectively. (not enforced here because vdl does not know these types)
- // TODO(ataly,ashankar): Figure out a VDL representation for ThirdPartyCaveat
- // and Discharge and use those here?
- Discharge(context _gen_ipc.ServerContext, Caveat _gen_vdlutil.Any, Impetus security.DischargeImpetus) (reply _gen_vdlutil.Any, err error)
+// DischargerClientStub adds universal methods to DischargerClientMethods.
+type DischargerClientStub interface {
+ DischargerClientMethods
+ __ipc.UniversalServiceMethods
}
-// BindDischarger returns the client stub implementing the Discharger
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindDischarger(name string, opts ..._gen_ipc.BindOpt) (Discharger, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
+// DischargerClient returns a client stub for Discharger.
+func DischargerClient(name string, opts ...__ipc.BindOpt) DischargerClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
}
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
}
- stub := &clientStubDischarger{defaultClient: client, name: name}
-
- return stub, nil
+ return implDischargerClientStub{name, client}
}
-// NewServerDischarger creates a new server stub.
+type implDischargerClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implDischargerClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implDischargerClientStub) Discharge(ctx __context.T, i0 __vdlutil.Any, i1 security.DischargeImpetus, opts ...__ipc.CallOpt) (o0 __vdlutil.Any, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Discharge", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implDischargerClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implDischargerClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// DischargerServerMethods is the interface a server writer
+// implements for Discharger.
//
-// It takes a regular server implementing the DischargerService
-// interface, and returns a new server stub.
-func NewServerDischarger(server DischargerService) interface{} {
- stub := &ServerStubDischarger{
- service: server,
+// Discharger is the interface for obtaining discharges for ThirdPartyCaveats.
+type DischargerServerMethods interface {
+ // Discharge is called by a principal that holds a blessing with a third
+ // party caveat and seeks to get a discharge that proves the fulfillment of
+ // this caveat.
+ //
+ // Caveat and Discharge are of type ThirdPartyCaveat and Discharge
+ // respectively. (not enforced here because vdl does not know these types)
+ // TODO(ataly,ashankar): Figure out a VDL representation for ThirdPartyCaveat
+ // and Discharge and use those here?
+ Discharge(ctx __ipc.ServerContext, Caveat __vdlutil.Any, Impetus security.DischargeImpetus) (Discharge __vdlutil.Any, err error)
+}
+
+// DischargerServerStubMethods is the server interface containing
+// Discharger methods, as expected by ipc.Server. The difference between
+// this interface and DischargerServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type DischargerServerStubMethods interface {
+ // Discharge is called by a principal that holds a blessing with a third
+ // party caveat and seeks to get a discharge that proves the fulfillment of
+ // this caveat.
+ //
+ // Caveat and Discharge are of type ThirdPartyCaveat and Discharge
+ // respectively. (not enforced here because vdl does not know these types)
+ // TODO(ataly,ashankar): Figure out a VDL representation for ThirdPartyCaveat
+ // and Discharge and use those here?
+ Discharge(call __ipc.ServerCall, Caveat __vdlutil.Any, Impetus security.DischargeImpetus) (Discharge __vdlutil.Any, err error)
+}
+
+// DischargerServerStub adds universal methods to DischargerServerStubMethods.
+type DischargerServerStub interface {
+ DischargerServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// DischargerServer returns a server stub for Discharger.
+// It converts an implementation of DischargerServerMethods into
+// an object that may be used by ipc.Server.
+func DischargerServer(impl DischargerServerMethods) DischargerServerStub {
+ stub := implDischargerServerStub{
+ impl: impl,
}
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubDischarger implements Discharger.
-type clientStubDischarger struct {
- defaultClient _gen_ipc.Client
- name string
+type implDischargerServerStub struct {
+ impl DischargerServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubDischarger) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implDischargerServerStub) Discharge(call __ipc.ServerCall, i0 __vdlutil.Any, i1 security.DischargeImpetus) (__vdlutil.Any, error) {
+ return s.impl.Discharge(call, i0, i1)
}
-func (__gen_c *clientStubDischarger) Discharge(ctx _gen_context.T, Caveat _gen_vdlutil.Any, Impetus security.DischargeImpetus, opts ..._gen_ipc.CallOpt) (reply _gen_vdlutil.Any, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Discharge", []interface{}{Caveat, Impetus}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implDischargerServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubDischarger) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubDischarger) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubDischarger) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubDischarger wraps a server that implements
-// DischargerService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubDischarger struct {
- service DischargerService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubDischarger) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implDischargerServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Discharge":
return []interface{}{security.Label(2)}, nil
@@ -183,55 +179,29 @@
}
}
-func (__gen_s *ServerStubDischarger) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["Discharge"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implDischargerServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["Discharge"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "Caveat", Type: 65},
{Name: "Impetus", Type: 69},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "Discharge", Type: 65},
{Name: "err", Type: 70},
},
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.BlessingPattern", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x43, Name: "Server"},
- _gen_wiretype.FieldType{Type: 0x3, Name: "Method"},
- _gen_wiretype.FieldType{Type: 0x44, Name: "Arguments"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron.io/veyron/veyron2/security.BlessingPattern", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x43, Name: "Server"},
+ __wiretype.FieldType{Type: 0x3, Name: "Method"},
+ __wiretype.FieldType{Type: 0x44, Name: "Arguments"},
},
"veyron.io/veyron/veyron2/security.DischargeImpetus", []string(nil)},
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}
-
-func (__gen_s *ServerStubDischarger) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
- }
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
-}
-
-func (__gen_s *ServerStubDischarger) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
-}
-
-func (__gen_s *ServerStubDischarger) Discharge(call _gen_ipc.ServerCall, Caveat _gen_vdlutil.Any, Impetus security.DischargeImpetus) (reply _gen_vdlutil.Any, err error) {
- reply, err = __gen_s.service.Discharge(call, Caveat, Impetus)
- return
-}
diff --git a/services/security/discharger/discharger.go b/services/security/discharger/discharger.go
index f66bbdd..5dbb583 100644
--- a/services/security/discharger/discharger.go
+++ b/services/security/discharger/discharger.go
@@ -33,6 +33,6 @@
// NewDischarger returns a discharger service implementation that grants discharges using the MintDischarge
// on the principal receiving the RPC.
-func NewDischarger() services.DischargerService {
+func NewDischarger() services.DischargerServerMethods {
return dischargerd{}
}
diff --git a/tools/application/impl.go b/tools/application/impl.go
index 6b99e92..2d06ad5 100644
--- a/tools/application/impl.go
+++ b/tools/application/impl.go
@@ -19,7 +19,7 @@
"veyron.io/veyron/veyron2/services/mgmt/application"
)
-func getEnvelopeJSON(ctx context.T, app repository.Application, profiles string) ([]byte, error) {
+func getEnvelopeJSON(ctx context.T, app repository.ApplicationClientMethods, profiles string) ([]byte, error) {
env, err := app.Match(ctx, strings.Split(profiles, ","))
if err != nil {
return nil, err
@@ -31,7 +31,7 @@
return j, nil
}
-func putEnvelopeJSON(ctx context.T, app repository.Application, profiles string, j []byte) error {
+func putEnvelopeJSON(ctx context.T, app repository.ApplicationClientMethods, profiles string, j []byte) error {
var env application.Envelope
if err := json.Unmarshal(j, &env); err != nil {
return fmt.Errorf("Unmarshal(%v) failed: %v", string(j), err)
@@ -67,10 +67,7 @@
return cmd.UsageErrorf("match: incorrect number of arguments, expected %d, got %d", expected, got)
}
name, profiles := args[0], args[1]
- app, err := repository.BindApplication(name)
- if err != nil {
- return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
- }
+ app := repository.ApplicationClient(name)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
j, err := getEnvelopeJSON(ctx, app, profiles)
@@ -98,10 +95,7 @@
return cmd.UsageErrorf("put: incorrect number of arguments, expected %d, got %d", expected, got)
}
name, profiles, envelope := args[0], args[1], args[2]
- app, err := repository.BindApplication(name)
- if err != nil {
- return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
- }
+ app := repository.ApplicationClient(name)
j, err := ioutil.ReadFile(envelope)
if err != nil {
return fmt.Errorf("ReadFile(%v): %v", envelope, err)
@@ -131,13 +125,10 @@
return cmd.UsageErrorf("remove: incorrect number of arguments, expected %d, got %d", expected, got)
}
name, profile := args[0], args[1]
- app, err := repository.BindApplication(name)
- if err != nil {
- return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
- }
+ app := repository.ApplicationClient(name)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- if err = app.Remove(ctx, profile); err != nil {
+ if err := app.Remove(ctx, profile); err != nil {
return err
}
fmt.Fprintln(cmd.Stdout(), "Application envelope removed successfully.")
@@ -160,10 +151,7 @@
return cmd.UsageErrorf("edit: incorrect number of arguments, expected %d, got %d", expected, got)
}
name, profile := args[0], args[1]
- app, err := repository.BindApplication(name)
- if err != nil {
- return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
- }
+ app := repository.ApplicationClient(name)
f, err := ioutil.TempFile("", "application-edit-")
if err != nil {
return fmt.Errorf("TempFile() failed: %v", err)
diff --git a/tools/application/impl_test.go b/tools/application/impl_test.go
index bd323c9..b107a50 100644
--- a/tools/application/impl_test.go
+++ b/tools/application/impl_test.go
@@ -69,7 +69,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.NewServerApplication(&server{suffix: suffix}))
+ invoker := ipc.ReflectInvoker(repository.ApplicationServer(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/associate/doc.go b/tools/associate/doc.go
index 5be1076..6133bbe 100644
--- a/tools/associate/doc.go
+++ b/tools/associate/doc.go
@@ -27,7 +27,7 @@
Associate List
-Lists all account associations
+Lists all account associations
Usage:
associate list <nodemanager>.
diff --git a/tools/associate/impl.go b/tools/associate/impl.go
index a60f649..b8f580b 100644
--- a/tools/associate/impl.go
+++ b/tools/associate/impl.go
@@ -27,11 +27,7 @@
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- nodeStub, err := node.BindNode(args[0])
- if err != nil {
- return fmt.Errorf("BindNode(%s) failed: %v", args[0], err)
- }
- assocs, err := nodeStub.ListAssociations(ctx)
+ assocs, err := node.NodeClient(args[0]).ListAssociations(ctx)
if err != nil {
return fmt.Errorf("ListAssociations failed: %v", err)
}
@@ -60,11 +56,7 @@
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- nodeStub, err := node.BindNode(args[0])
- if err != nil {
- return fmt.Errorf("BindNode(%s) failed: %v", args[0], err)
- }
- return nodeStub.AssociateAccount(ctx, args[2:], args[1])
+ return node.NodeClient(args[0]).AssociateAccount(ctx, args[2:], args[1])
}
var cmdRemove = &cmdline.Command{
@@ -84,12 +76,7 @@
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- nodeStub, err := node.BindNode(args[0])
- if err != nil {
- return fmt.Errorf("BindNode(%s) failed: %v", args[0], err)
- }
-
- return nodeStub.AssociateAccount(ctx, args[1:], "")
+ return node.NodeClient(args[0]).AssociateAccount(ctx, args[1:], "")
}
func root() *cmdline.Command {
diff --git a/tools/associate/impl_test.go b/tools/associate/impl_test.go
index 54850d0..dbb2ecc 100644
--- a/tools/associate/impl_test.go
+++ b/tools/associate/impl_test.go
@@ -78,7 +78,7 @@
func (i *mockNodeInvoker) GetACL(ipc.ServerContext) (security.ACL, string, error) {
return security.ACL{}, "", nil
}
-func (i *mockNodeInvoker) Glob(ctx ipc.ServerContext, pattern string, stream mounttable.GlobbableServiceGlobStream) error {
+func (i *mockNodeInvoker) Glob(ctx mounttable.GlobbableGlobContext, pattern string) error {
return nil
}
@@ -92,7 +92,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(node.NewServerNode(&mockNodeInvoker{tape: d.tape, t: d.t}))
+ invoker := ipc.ReflectInvoker(node.NodeServer(&mockNodeInvoker{tape: d.tape, t: d.t}))
return invoker, nil, nil
}
diff --git a/tools/binary/impl_test.go b/tools/binary/impl_test.go
index d2379ec..0dbd6b0 100644
--- a/tools/binary/impl_test.go
+++ b/tools/binary/impl_test.go
@@ -40,9 +40,9 @@
return nil
}
-func (s *server) Download(_ ipc.ServerContext, _ int32, stream repository.BinaryServiceDownloadStream) error {
+func (s *server) Download(ctx repository.BinaryDownloadContext, _ int32) error {
vlog.Infof("Download() was called. suffix=%v", s.suffix)
- sender := stream.SendStream()
+ sender := ctx.SendStream()
sender.Send([]byte("Hello"))
sender.Send([]byte("World"))
return nil
@@ -62,9 +62,9 @@
return []binary.PartInfo{part}, nil
}
-func (s *server) Upload(_ ipc.ServerContext, _ int32, stream repository.BinaryServiceUploadStream) error {
+func (s *server) Upload(ctx repository.BinaryUploadContext, _ int32) error {
vlog.Infof("Upload() was called. suffix=%v", s.suffix)
- rStream := stream.RecvStream()
+ rStream := ctx.RecvStream()
for rStream.Advance() {
}
return nil
@@ -78,7 +78,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.NewServerBinary(&server{suffix: suffix}))
+ invoker := ipc.ReflectInvoker(repository.BinaryServer(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/build/impl.go b/tools/build/impl.go
index d047478..1d39669 100644
--- a/tools/build/impl.go
+++ b/tools/build/impl.go
@@ -142,11 +142,7 @@
go func() {
defer close(binaries)
rt.Init()
- client, err := vbuild.BindBuilder(name)
- if err != nil {
- errchan <- fmt.Errorf("BindBuilder(%v) failed: %v", name, err)
- return
- }
+ client := vbuild.BuilderClient(name)
stream, err := client.Build(ctx, vbuild.Architecture(flagArch), vbuild.OperatingSystem(flagOS))
if err != nil {
errchan <- fmt.Errorf("Build() failed: %v", err)
diff --git a/tools/build/impl_test.go b/tools/build/impl_test.go
index 54bab19..2778896 100644
--- a/tools/build/impl_test.go
+++ b/tools/build/impl_test.go
@@ -20,9 +20,9 @@
type mock struct{}
-func (mock) Build(_ ipc.ServerContext, arch build.Architecture, opsys build.OperatingSystem, stream build.BuilderServiceBuildStream) ([]byte, error) {
+func (mock) Build(ctx build.BuilderBuildContext, arch build.Architecture, opsys build.OperatingSystem) ([]byte, error) {
vlog.VI(2).Infof("Build(%v, %v) was called", arch, opsys)
- iterator := stream.RecvStream()
+ iterator := ctx.RecvStream()
for iterator.Advance() {
}
if err := iterator.Err(); err != nil {
@@ -49,7 +49,7 @@
t.Fatalf("Listen(%s) failed: %v", profiles.LocalListenSpec, err)
}
unpublished := ""
- if err := server.Serve(unpublished, build.NewServerBuilder(&mock{}), nil); err != nil {
+ if err := server.Serve(unpublished, build.BuilderServer(&mock{}), nil); err != nil {
t.Fatalf("Serve(%v) failed: %v", unpublished, err)
}
return server, endpoint
diff --git a/tools/debug/impl.go b/tools/debug/impl.go
index 3b4ba10..36faee4 100644
--- a/tools/debug/impl.go
+++ b/tools/debug/impl.go
@@ -143,10 +143,7 @@
return cmd.UsageErrorf("read: incorrect number of arguments, got %d, want %d", got, want)
}
name := args[0]
- lf, err := logreader.BindLogFile(name)
- if err != nil {
- return err
- }
+ lf := logreader.LogFileClient(name)
stream, err := lf.ReadLog(rt.R().NewContext(), startPos, int32(numEntries), follow)
if err != nil {
return err
@@ -189,10 +186,7 @@
return cmd.UsageErrorf("size: incorrect number of arguments, got %d, want %d", got, want)
}
name := args[0]
- lf, err := logreader.BindLogFile(name)
- if err != nil {
- return err
- }
+ lf := logreader.LogFileClient(name)
size, err := lf.Size(rt.R().NewContext())
if err != nil {
return err
@@ -250,14 +244,9 @@
func doValue(ctx context.T, name string, output chan<- string, errors chan<- error, wg *sync.WaitGroup) {
defer wg.Done()
- s, err := stats.BindStats(name)
- if err != nil {
- errors <- fmt.Errorf("%s: %v", name, err)
- return
- }
ctx, cancel := ctx.WithTimeout(time.Minute)
defer cancel()
- v, err := s.Value(ctx)
+ v, err := stats.StatsClient(name).Value(ctx)
if err != nil {
errors <- fmt.Errorf("%s: %v", name, err)
return
@@ -322,11 +311,7 @@
if len(root) != 0 {
name = naming.JoinAddressName(root, name)
}
- c, err := watch.BindGlobWatcher(name)
- if err != nil {
- errors <- fmt.Errorf("%s: %v", name, err)
- return
- }
+ c := watch.GlobWatcherClient(name)
for retry := false; ; retry = true {
if retry {
time.Sleep(10 * time.Second)
@@ -445,11 +430,7 @@
}
func showPProfProfiles(cmd *cmdline.Command, name string) error {
- pp, err := pprof.BindPProf(name)
- if err != nil {
- return err
- }
- v, err := pp.Profiles(rt.R().NewContext())
+ v, err := pprof.PProfClient(name).Profiles(rt.R().NewContext())
if err != nil {
return err
}
diff --git a/tools/mounttable/impl.go b/tools/mounttable/impl.go
index b37d5f6..1cb8aac 100644
--- a/tools/mounttable/impl.go
+++ b/tools/mounttable/impl.go
@@ -14,7 +14,7 @@
"veyron.io/veyron/veyron2/services/mounttable/types"
)
-func bindMT(ctx context.T, name string) (mounttable.MountTable, error) {
+func bindMT(ctx context.T, name string) (mounttable.MountTableClientMethods, error) {
e, err := rt.R().Namespace().ResolveToMountTableX(ctx, name)
if err != nil {
return nil, err
@@ -27,7 +27,7 @@
servers = append(servers, naming.JoinAddressName(s.Server, e.Name))
}
fmt.Println(servers)
- return mounttable.BindMountTable(servers[0])
+ return mounttable.MountTableClient(servers[0]), nil
}
var cmdGlob = &cmdline.Command{
diff --git a/tools/mounttable/impl_test.go b/tools/mounttable/impl_test.go
index fdfc5d1..bf0a94f 100644
--- a/tools/mounttable/impl_test.go
+++ b/tools/mounttable/impl_test.go
@@ -21,9 +21,9 @@
suffix string
}
-func (s *server) Glob(_ ipc.ServerContext, pattern string, stream mounttable.GlobbableServiceGlobStream) error {
+func (s *server) Glob(ctx mounttable.GlobbableGlobContext, pattern string) error {
vlog.VI(2).Infof("Glob() was called. suffix=%v pattern=%q", s.suffix, pattern)
- sender := stream.SendStream()
+ sender := ctx.SendStream()
sender.Send(types.MountEntry{"name1", []types.MountedServer{{"server1", 123}}, false})
sender.Send(types.MountEntry{"name2", []types.MountedServer{{"server2", 456}, {"server3", 789}}, false})
return nil
@@ -57,7 +57,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(mounttable.NewServerMountTable(&server{suffix: suffix}))
+ invoker := ipc.ReflectInvoker(mounttable.MountTableServer(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/principal/main.go b/tools/principal/main.go
index fdf3bef..f865365 100644
--- a/tools/principal/main.go
+++ b/tools/principal/main.go
@@ -418,10 +418,7 @@
defer cancel()
var reply security.WireBlessings
- blesser, err := identity.BindMacaroonBlesser(service)
- if err == nil {
- reply, err = blesser.Bless(ctx, macaroon)
- }
+ reply, err = identity.MacaroonBlesserClient(service).Bless(ctx, macaroon)
if err != nil {
return fmt.Errorf("failed to get blessing from %q: %v", service, err)
}
diff --git a/tools/profile/impl.go b/tools/profile/impl.go
index 5ed96b1..2216a60 100644
--- a/tools/profile/impl.go
+++ b/tools/profile/impl.go
@@ -26,10 +26,7 @@
return cmd.UsageErrorf("label: incorrect number of arguments, expected %d, got %d", expected, got)
}
name := args[0]
- p, err := repository.BindProfile(name)
- if err != nil {
- return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
- }
+ p := repository.ProfileClient(name)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
label, err := p.Label(ctx)
@@ -54,10 +51,7 @@
return cmd.UsageErrorf("description: incorrect number of arguments, expected %d, got %d", expected, got)
}
name := args[0]
- p, err := repository.BindProfile(name)
- if err != nil {
- return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
- }
+ p := repository.ProfileClient(name)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
desc, err := p.Description(ctx)
@@ -82,10 +76,7 @@
return cmd.UsageErrorf("spec: incorrect number of arguments, expected %d, got %d", expected, got)
}
name := args[0]
- p, err := repository.BindProfile(name)
- if err != nil {
- return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
- }
+ p := repository.ProfileClient(name)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
spec, err := p.Specification(ctx)
@@ -110,10 +101,7 @@
return cmd.UsageErrorf("put: incorrect number of arguments, expected %d, got %d", expected, got)
}
name := args[0]
- p, err := repository.BindProfile(name)
- if err != nil {
- return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
- }
+ p := repository.ProfileClient(name)
// TODO(rthellend): Read an actual specification from a file.
spec := profile.Specification{
@@ -147,13 +135,10 @@
return cmd.UsageErrorf("remove: incorrect number of arguments, expected %d, got %d", expected, got)
}
name := args[0]
- p, err := repository.BindProfile(name)
- if err != nil {
- return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
- }
+ p := repository.ProfileClient(name)
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- if err = p.Remove(ctx); err != nil {
+ if err := p.Remove(ctx); err != nil {
return err
}
fmt.Fprintln(cmd.Stdout(), "Profile removed successfully.")
diff --git a/tools/profile/impl_test.go b/tools/profile/impl_test.go
index dd8a329..fde8b26 100644
--- a/tools/profile/impl_test.go
+++ b/tools/profile/impl_test.go
@@ -80,7 +80,7 @@
}
func (d *dispatcher) Lookup(suffix, method string) (interface{}, security.Authorizer, error) {
- invoker := ipc.ReflectInvoker(repository.NewServerProfile(&server{suffix: suffix}))
+ invoker := ipc.ReflectInvoker(repository.ProfileServer(&server{suffix: suffix}))
return invoker, nil, nil
}
diff --git a/tools/vrpc/impl_test.go b/tools/vrpc/impl_test.go
index bbff9a4..29954dd 100644
--- a/tools/vrpc/impl_test.go
+++ b/tools/vrpc/impl_test.go
@@ -116,9 +116,9 @@
return i1, i2, nil
}
-func (*server) StreamingOutput(call ipc.ServerContext, nStream int32, item bool, reply test_base.TypeTesterServiceStreamingOutputStream) error {
+func (*server) StreamingOutput(ctx test_base.TypeTesterStreamingOutputContext, nStream int32, item bool) error {
vlog.VI(2).Info("StreamingOutput(%v,%v) was called.", nStream, item)
- sender := reply.SendStream()
+ sender := ctx.SendStream()
for i := int32(0); i < nStream; i++ {
sender.Send(item)
}
@@ -126,7 +126,7 @@
}
func startServer(t *testing.T, r veyron2.Runtime) (ipc.Server, naming.Endpoint, error) {
- obj := test_base.NewServerTypeTester(&server{})
+ obj := test_base.TypeTesterServer(&server{})
server, err := r.NewServer()
if err != nil {
t.Errorf("NewServer failed: %v", err)
diff --git a/tools/vrpc/test_base/test_base.vdl.go b/tools/vrpc/test_base/test_base.vdl.go
index ef4e9cf..9304457 100644
--- a/tools/vrpc/test_base/test_base.vdl.go
+++ b/tools/vrpc/test_base/test_base.vdl.go
@@ -4,156 +4,382 @@
package test_base
import (
- // The non-user imports are prefixed with "_gen_" to prevent collisions.
- _gen_io "io"
- _gen_veyron2 "veyron.io/veyron/veyron2"
- _gen_context "veyron.io/veyron/veyron2/context"
- _gen_ipc "veyron.io/veyron/veyron2/ipc"
- _gen_naming "veyron.io/veyron/veyron2/naming"
- _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
- _gen_wiretype "veyron.io/veyron/veyron2/wiretype"
+ // The non-user imports are prefixed with "__" to prevent collisions.
+ __io "io"
+ __veyron2 "veyron.io/veyron/veyron2"
+ __context "veyron.io/veyron/veyron2/context"
+ __ipc "veyron.io/veyron/veyron2/ipc"
+ __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
+ __wiretype "veyron.io/veyron/veyron2/wiretype"
)
+// TODO(toddw): Remove this line once the new signature support is done.
+// It corrects a bug where __wiretype is unused in VDL pacakges where only
+// bootstrap types are used on interfaces.
+const _ = __wiretype.TypeIDInvalid
+
type Struct struct {
X int32
Y int32
}
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where _gen_wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = _gen_wiretype.TypeIDInvalid
-
-// TypeTester is the interface the client binds and uses.
-// TypeTester_ExcludingUniversal is the interface without internal framework-added methods
-// to enable embedding without method collisions. Not to be used directly by clients.
-type TypeTester_ExcludingUniversal interface {
+// TypeTesterClientMethods is the client interface
+// containing TypeTester methods.
+type TypeTesterClientMethods interface {
// Methods to test support for generic types.
- EchoBool(ctx _gen_context.T, I1 bool, opts ..._gen_ipc.CallOpt) (reply bool, err error)
- EchoFloat32(ctx _gen_context.T, I1 float32, opts ..._gen_ipc.CallOpt) (reply float32, err error)
- EchoFloat64(ctx _gen_context.T, I1 float64, opts ..._gen_ipc.CallOpt) (reply float64, err error)
- EchoInt32(ctx _gen_context.T, I1 int32, opts ..._gen_ipc.CallOpt) (reply int32, err error)
- EchoInt64(ctx _gen_context.T, I1 int64, opts ..._gen_ipc.CallOpt) (reply int64, err error)
- EchoString(ctx _gen_context.T, I1 string, opts ..._gen_ipc.CallOpt) (reply string, err error)
- EchoByte(ctx _gen_context.T, I1 byte, opts ..._gen_ipc.CallOpt) (reply byte, err error)
- EchoUInt32(ctx _gen_context.T, I1 uint32, opts ..._gen_ipc.CallOpt) (reply uint32, err error)
- EchoUInt64(ctx _gen_context.T, I1 uint64, opts ..._gen_ipc.CallOpt) (reply uint64, err error)
+ EchoBool(ctx __context.T, I1 bool, opts ...__ipc.CallOpt) (O1 bool, err error)
+ EchoFloat32(ctx __context.T, I1 float32, opts ...__ipc.CallOpt) (O1 float32, err error)
+ EchoFloat64(ctx __context.T, I1 float64, opts ...__ipc.CallOpt) (O1 float64, err error)
+ EchoInt32(ctx __context.T, I1 int32, opts ...__ipc.CallOpt) (O1 int32, err error)
+ EchoInt64(ctx __context.T, I1 int64, opts ...__ipc.CallOpt) (O1 int64, err error)
+ EchoString(ctx __context.T, I1 string, opts ...__ipc.CallOpt) (O1 string, err error)
+ EchoByte(ctx __context.T, I1 byte, opts ...__ipc.CallOpt) (O1 byte, err error)
+ EchoUInt32(ctx __context.T, I1 uint32, opts ...__ipc.CallOpt) (O1 uint32, err error)
+ EchoUInt64(ctx __context.T, I1 uint64, opts ...__ipc.CallOpt) (O1 uint64, err error)
// Methods to test support for composite types.
- InputArray(ctx _gen_context.T, I1 [2]byte, opts ..._gen_ipc.CallOpt) (err error)
- InputMap(ctx _gen_context.T, I1 map[byte]byte, opts ..._gen_ipc.CallOpt) (err error)
- InputSlice(ctx _gen_context.T, I1 []byte, opts ..._gen_ipc.CallOpt) (err error)
- InputStruct(ctx _gen_context.T, I1 Struct, opts ..._gen_ipc.CallOpt) (err error)
- OutputArray(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply [2]byte, err error)
- OutputMap(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply map[byte]byte, err error)
- OutputSlice(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []byte, err error)
- OutputStruct(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply Struct, err error)
+ InputArray(ctx __context.T, I1 [2]byte, opts ...__ipc.CallOpt) error
+ InputMap(ctx __context.T, I1 map[byte]byte, opts ...__ipc.CallOpt) error
+ InputSlice(ctx __context.T, I1 []byte, opts ...__ipc.CallOpt) error
+ InputStruct(ctx __context.T, I1 Struct, opts ...__ipc.CallOpt) error
+ OutputArray(__context.T, ...__ipc.CallOpt) (O1 [2]byte, err error)
+ OutputMap(__context.T, ...__ipc.CallOpt) (O1 map[byte]byte, err error)
+ OutputSlice(__context.T, ...__ipc.CallOpt) (O1 []byte, err error)
+ OutputStruct(__context.T, ...__ipc.CallOpt) (O1 Struct, err error)
// Methods to test support for different number of arguments.
- NoArguments(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error)
- MultipleArguments(ctx _gen_context.T, I1 int32, I2 int32, opts ..._gen_ipc.CallOpt) (O1 int32, O2 int32, err error)
+ NoArguments(__context.T, ...__ipc.CallOpt) error
+ MultipleArguments(ctx __context.T, I1 int32, I2 int32, opts ...__ipc.CallOpt) (O1 int32, O2 int32, err error)
// Methods to test support for streaming.
- StreamingOutput(ctx _gen_context.T, NumStreamItems int32, StreamItem bool, opts ..._gen_ipc.CallOpt) (reply TypeTesterStreamingOutputCall, err error)
-}
-type TypeTester interface {
- _gen_ipc.UniversalServiceMethods
- TypeTester_ExcludingUniversal
+ StreamingOutput(ctx __context.T, NumStreamItems int32, StreamItem bool, opts ...__ipc.CallOpt) (TypeTesterStreamingOutputCall, error)
}
-// TypeTesterService is the interface the server implements.
-type TypeTesterService interface {
-
- // Methods to test support for generic types.
- EchoBool(context _gen_ipc.ServerContext, I1 bool) (reply bool, err error)
- EchoFloat32(context _gen_ipc.ServerContext, I1 float32) (reply float32, err error)
- EchoFloat64(context _gen_ipc.ServerContext, I1 float64) (reply float64, err error)
- EchoInt32(context _gen_ipc.ServerContext, I1 int32) (reply int32, err error)
- EchoInt64(context _gen_ipc.ServerContext, I1 int64) (reply int64, err error)
- EchoString(context _gen_ipc.ServerContext, I1 string) (reply string, err error)
- EchoByte(context _gen_ipc.ServerContext, I1 byte) (reply byte, err error)
- EchoUInt32(context _gen_ipc.ServerContext, I1 uint32) (reply uint32, err error)
- EchoUInt64(context _gen_ipc.ServerContext, I1 uint64) (reply uint64, err error)
- // Methods to test support for composite types.
- InputArray(context _gen_ipc.ServerContext, I1 [2]byte) (err error)
- InputMap(context _gen_ipc.ServerContext, I1 map[byte]byte) (err error)
- InputSlice(context _gen_ipc.ServerContext, I1 []byte) (err error)
- InputStruct(context _gen_ipc.ServerContext, I1 Struct) (err error)
- OutputArray(context _gen_ipc.ServerContext) (reply [2]byte, err error)
- OutputMap(context _gen_ipc.ServerContext) (reply map[byte]byte, err error)
- OutputSlice(context _gen_ipc.ServerContext) (reply []byte, err error)
- OutputStruct(context _gen_ipc.ServerContext) (reply Struct, err error)
- // Methods to test support for different number of arguments.
- NoArguments(context _gen_ipc.ServerContext) (err error)
- MultipleArguments(context _gen_ipc.ServerContext, I1 int32, I2 int32) (O1 int32, O2 int32, err error)
- // Methods to test support for streaming.
- StreamingOutput(context _gen_ipc.ServerContext, NumStreamItems int32, StreamItem bool, stream TypeTesterServiceStreamingOutputStream) (err error)
+// TypeTesterClientStub adds universal methods to TypeTesterClientMethods.
+type TypeTesterClientStub interface {
+ TypeTesterClientMethods
+ __ipc.UniversalServiceMethods
}
-// TypeTesterStreamingOutputCall is the interface for call object of the method
-// StreamingOutput in the service interface TypeTester.
-type TypeTesterStreamingOutputCall interface {
- // RecvStream returns the recv portion of the stream
+// TypeTesterClient returns a client stub for TypeTester.
+func TypeTesterClient(name string, opts ...__ipc.BindOpt) TypeTesterClientStub {
+ var client __ipc.Client
+ for _, opt := range opts {
+ if clientOpt, ok := opt.(__ipc.Client); ok {
+ client = clientOpt
+ }
+ }
+ return implTypeTesterClientStub{name, client}
+}
+
+type implTypeTesterClientStub struct {
+ name string
+ client __ipc.Client
+}
+
+func (c implTypeTesterClientStub) c(ctx __context.T) __ipc.Client {
+ if c.client != nil {
+ return c.client
+ }
+ return __veyron2.RuntimeFromContext(ctx).Client()
+}
+
+func (c implTypeTesterClientStub) EchoBool(ctx __context.T, i0 bool, opts ...__ipc.CallOpt) (o0 bool, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoBool", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoFloat32(ctx __context.T, i0 float32, opts ...__ipc.CallOpt) (o0 float32, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoFloat32", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoFloat64(ctx __context.T, i0 float64, opts ...__ipc.CallOpt) (o0 float64, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoFloat64", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoInt32(ctx __context.T, i0 int32, opts ...__ipc.CallOpt) (o0 int32, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoInt32", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoInt64(ctx __context.T, i0 int64, opts ...__ipc.CallOpt) (o0 int64, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoInt64", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoString(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (o0 string, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoString", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoByte(ctx __context.T, i0 byte, opts ...__ipc.CallOpt) (o0 byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoByte", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoUInt32(ctx __context.T, i0 uint32, opts ...__ipc.CallOpt) (o0 uint32, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoUInt32", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) EchoUInt64(ctx __context.T, i0 uint64, opts ...__ipc.CallOpt) (o0 uint64, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "EchoUInt64", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) InputArray(ctx __context.T, i0 [2]byte, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "InputArray", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) InputMap(ctx __context.T, i0 map[byte]byte, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "InputMap", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) InputSlice(ctx __context.T, i0 []byte, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "InputSlice", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) InputStruct(ctx __context.T, i0 Struct, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "InputStruct", []interface{}{i0}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) OutputArray(ctx __context.T, opts ...__ipc.CallOpt) (o0 [2]byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "OutputArray", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) OutputMap(ctx __context.T, opts ...__ipc.CallOpt) (o0 map[byte]byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "OutputMap", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) OutputSlice(ctx __context.T, opts ...__ipc.CallOpt) (o0 []byte, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "OutputSlice", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) OutputStruct(ctx __context.T, opts ...__ipc.CallOpt) (o0 Struct, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "OutputStruct", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) NoArguments(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "NoArguments", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) MultipleArguments(ctx __context.T, i0 int32, i1 int32, opts ...__ipc.CallOpt) (o0 int32, o1 int32, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "MultipleArguments", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &o1, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) StreamingOutput(ctx __context.T, i0 int32, i1 bool, opts ...__ipc.CallOpt) (ocall TypeTesterStreamingOutputCall, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "StreamingOutput", []interface{}{i0, i1}, opts...); err != nil {
+ return
+ }
+ ocall = &implTypeTesterStreamingOutputCall{call, implTypeTesterStreamingOutputClientRecv{call: call}}
+ return
+}
+
+func (c implTypeTesterClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+func (c implTypeTesterClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
+ var call __ipc.Call
+ if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
+ return
+ }
+ if ierr := call.Finish(&o0, &err); ierr != nil {
+ err = ierr
+ }
+ return
+}
+
+// TypeTesterStreamingOutputClientStream is the client stream for TypeTester.StreamingOutput.
+type TypeTesterStreamingOutputClientStream interface {
+ // RecvStream returns the receiver side of the client stream.
RecvStream() interface {
- // Advance stages an element so the client can retrieve it
- // with Value. Advance returns true iff there is an
- // element to retrieve. The client must call Advance before
- // calling Value. Advance may block if an element is not
- // immediately available.
+ // Advance stages an item so that it may be retrieved via Value. Returns
+ // true iff there is an item to retrieve. Advance must be called before
+ // Value is called. May block if an item is not available.
Advance() bool
-
- // Value returns the element that was staged by Advance.
- // Value may panic if Advance returned false or was not
- // called at all. Value does not block.
+ // Value returns the item that was staged by Advance. May panic if Advance
+ // returned false or was not called. Never blocks.
Value() bool
-
- // Err returns a non-nil error iff the stream encountered
- // any errors. Err does not block.
+ // Err returns any error encountered by Advance. Never blocks.
Err() error
}
+}
- // Finish blocks until the server is done and returns the positional
- // return values for call.
+// TypeTesterStreamingOutputCall represents the call returned from TypeTester.StreamingOutput.
+type TypeTesterStreamingOutputCall interface {
+ TypeTesterStreamingOutputClientStream
+ // Finish blocks until the server is done, and returns the positional return
+ // values for call.
//
- // If Cancel has been called, Finish will return immediately; the output of
- // Finish could either be an error signalling cancelation, or the correct
- // positional return values from the server depending on the timing of the
- // call.
+ // Finish returns immediately if Cancel has been called; depending on the
+ // timing the output could either be an error signaling cancelation, or the
+ // valid positional return values from the server.
//
// Calling Finish is mandatory for releasing stream resources, unless Cancel
- // has been called or any of the other methods return an error.
- // Finish should be called at most once.
- Finish() (err error)
-
- // Cancel cancels the RPC, notifying the server to stop processing. It
- // is safe to call Cancel concurrently with any of the other stream methods.
+ // has been called or any of the other methods return an error. Finish should
+ // be called at most once.
+ Finish() error
+ // Cancel cancels the RPC, notifying the server to stop processing. It is
+ // safe to call Cancel concurrently with any of the other stream methods.
// Calling Cancel after Finish has returned is a no-op.
Cancel()
}
-type implTypeTesterStreamingOutputStreamIterator struct {
- clientCall _gen_ipc.Call
- val bool
- err error
+type implTypeTesterStreamingOutputClientRecv struct {
+ call __ipc.Call
+ val bool
+ err error
}
-func (c *implTypeTesterStreamingOutputStreamIterator) Advance() bool {
- c.err = c.clientCall.Recv(&c.val)
+func (c *implTypeTesterStreamingOutputClientRecv) Advance() bool {
+ c.err = c.call.Recv(&c.val)
return c.err == nil
}
-
-func (c *implTypeTesterStreamingOutputStreamIterator) Value() bool {
+func (c *implTypeTesterStreamingOutputClientRecv) Value() bool {
return c.val
}
-
-func (c *implTypeTesterStreamingOutputStreamIterator) Err() error {
- if c.err == _gen_io.EOF {
+func (c *implTypeTesterStreamingOutputClientRecv) Err() error {
+ if c.err == __io.EOF {
return nil
}
return c.err
}
-// Implementation of the TypeTesterStreamingOutputCall interface that is not exported.
type implTypeTesterStreamingOutputCall struct {
- clientCall _gen_ipc.Call
- readStream implTypeTesterStreamingOutputStreamIterator
+ call __ipc.Call
+ recv implTypeTesterStreamingOutputClientRecv
}
func (c *implTypeTesterStreamingOutputCall) RecvStream() interface {
@@ -161,380 +387,197 @@
Value() bool
Err() error
} {
- return &c.readStream
+ return &c.recv
}
-
func (c *implTypeTesterStreamingOutputCall) Finish() (err error) {
- if ierr := c.clientCall.Finish(&err); ierr != nil {
+ if ierr := c.call.Finish(&err); ierr != nil {
err = ierr
}
return
}
-
func (c *implTypeTesterStreamingOutputCall) Cancel() {
- c.clientCall.Cancel()
+ c.call.Cancel()
}
-type implTypeTesterServiceStreamingOutputStreamSender struct {
- serverCall _gen_ipc.ServerCall
+// TypeTesterServerMethods is the interface a server writer
+// implements for TypeTester.
+type TypeTesterServerMethods interface {
+ // Methods to test support for generic types.
+ EchoBool(ctx __ipc.ServerContext, I1 bool) (O1 bool, E error)
+ EchoFloat32(ctx __ipc.ServerContext, I1 float32) (O1 float32, E error)
+ EchoFloat64(ctx __ipc.ServerContext, I1 float64) (O1 float64, E error)
+ EchoInt32(ctx __ipc.ServerContext, I1 int32) (O1 int32, E error)
+ EchoInt64(ctx __ipc.ServerContext, I1 int64) (O1 int64, E error)
+ EchoString(ctx __ipc.ServerContext, I1 string) (O1 string, E error)
+ EchoByte(ctx __ipc.ServerContext, I1 byte) (O1 byte, E error)
+ EchoUInt32(ctx __ipc.ServerContext, I1 uint32) (O1 uint32, E error)
+ EchoUInt64(ctx __ipc.ServerContext, I1 uint64) (O1 uint64, E error)
+ // Methods to test support for composite types.
+ InputArray(ctx __ipc.ServerContext, I1 [2]byte) (E error)
+ InputMap(ctx __ipc.ServerContext, I1 map[byte]byte) (E error)
+ InputSlice(ctx __ipc.ServerContext, I1 []byte) (E error)
+ InputStruct(ctx __ipc.ServerContext, I1 Struct) (E error)
+ OutputArray(__ipc.ServerContext) (O1 [2]byte, E error)
+ OutputMap(__ipc.ServerContext) (O1 map[byte]byte, E error)
+ OutputSlice(__ipc.ServerContext) (O1 []byte, E error)
+ OutputStruct(__ipc.ServerContext) (O1 Struct, E error)
+ // Methods to test support for different number of arguments.
+ NoArguments(__ipc.ServerContext) error
+ MultipleArguments(ctx __ipc.ServerContext, I1 int32, I2 int32) (O1 int32, O2 int32, E error)
+ // Methods to test support for streaming.
+ StreamingOutput(ctx TypeTesterStreamingOutputContext, NumStreamItems int32, StreamItem bool) error
}
-func (s *implTypeTesterServiceStreamingOutputStreamSender) Send(item bool) error {
- return s.serverCall.Send(item)
+// TypeTesterServerStubMethods is the server interface containing
+// TypeTester methods, as expected by ipc.Server. The difference between
+// this interface and TypeTesterServerMethods is that the first context
+// argument for each method is always ipc.ServerCall here, while it is either
+// ipc.ServerContext or a typed streaming context there.
+type TypeTesterServerStubMethods interface {
+ // Methods to test support for generic types.
+ EchoBool(call __ipc.ServerCall, I1 bool) (O1 bool, E error)
+ EchoFloat32(call __ipc.ServerCall, I1 float32) (O1 float32, E error)
+ EchoFloat64(call __ipc.ServerCall, I1 float64) (O1 float64, E error)
+ EchoInt32(call __ipc.ServerCall, I1 int32) (O1 int32, E error)
+ EchoInt64(call __ipc.ServerCall, I1 int64) (O1 int64, E error)
+ EchoString(call __ipc.ServerCall, I1 string) (O1 string, E error)
+ EchoByte(call __ipc.ServerCall, I1 byte) (O1 byte, E error)
+ EchoUInt32(call __ipc.ServerCall, I1 uint32) (O1 uint32, E error)
+ EchoUInt64(call __ipc.ServerCall, I1 uint64) (O1 uint64, E error)
+ // Methods to test support for composite types.
+ InputArray(call __ipc.ServerCall, I1 [2]byte) (E error)
+ InputMap(call __ipc.ServerCall, I1 map[byte]byte) (E error)
+ InputSlice(call __ipc.ServerCall, I1 []byte) (E error)
+ InputStruct(call __ipc.ServerCall, I1 Struct) (E error)
+ OutputArray(__ipc.ServerCall) (O1 [2]byte, E error)
+ OutputMap(__ipc.ServerCall) (O1 map[byte]byte, E error)
+ OutputSlice(__ipc.ServerCall) (O1 []byte, E error)
+ OutputStruct(__ipc.ServerCall) (O1 Struct, E error)
+ // Methods to test support for different number of arguments.
+ NoArguments(__ipc.ServerCall) error
+ MultipleArguments(call __ipc.ServerCall, I1 int32, I2 int32) (O1 int32, O2 int32, E error)
+ // Methods to test support for streaming.
+ StreamingOutput(call __ipc.ServerCall, NumStreamItems int32, StreamItem bool) error
}
-// TypeTesterServiceStreamingOutputStream is the interface for streaming responses of the method
-// StreamingOutput in the service interface TypeTester.
-type TypeTesterServiceStreamingOutputStream interface {
- // SendStream returns the send portion of the stream.
- SendStream() interface {
- // Send places the item onto the output stream, blocking if there is no buffer
- // space available. If the client has canceled, an error is returned.
- Send(item bool) error
+// TypeTesterServerStub adds universal methods to TypeTesterServerStubMethods.
+type TypeTesterServerStub interface {
+ TypeTesterServerStubMethods
+ // GetMethodTags will be replaced with DescribeInterfaces.
+ GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
+ // Signature will be replaced with DescribeInterfaces.
+ Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
+}
+
+// TypeTesterServer returns a server stub for TypeTester.
+// It converts an implementation of TypeTesterServerMethods into
+// an object that may be used by ipc.Server.
+func TypeTesterServer(impl TypeTesterServerMethods) TypeTesterServerStub {
+ stub := implTypeTesterServerStub{
+ impl: impl,
}
-}
-
-// Implementation of the TypeTesterServiceStreamingOutputStream interface that is not exported.
-type implTypeTesterServiceStreamingOutputStream struct {
- writer implTypeTesterServiceStreamingOutputStreamSender
-}
-
-func (s *implTypeTesterServiceStreamingOutputStream) SendStream() interface {
- // Send places the item onto the output stream, blocking if there is no buffer
- // space available. If the client has canceled, an error is returned.
- Send(item bool) error
-} {
- return &s.writer
-}
-
-// BindTypeTester returns the client stub implementing the TypeTester
-// interface.
-//
-// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
-// global Runtime is used.
-func BindTypeTester(name string, opts ..._gen_ipc.BindOpt) (TypeTester, error) {
- var client _gen_ipc.Client
- switch len(opts) {
- case 0:
- // Do nothing.
- case 1:
- if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok {
- client = clientOpt
- } else {
- return nil, _gen_vdlutil.ErrUnrecognizedOption
- }
- default:
- return nil, _gen_vdlutil.ErrTooManyOptionsToBind
+ // Initialize GlobState; always check the stub itself first, to handle the
+ // case where the user has the Glob method defined in their VDL source.
+ if gs := __ipc.NewGlobState(stub); gs != nil {
+ stub.gs = gs
+ } else if gs := __ipc.NewGlobState(impl); gs != nil {
+ stub.gs = gs
}
- stub := &clientStubTypeTester{defaultClient: client, name: name}
-
- return stub, nil
-}
-
-// NewServerTypeTester creates a new server stub.
-//
-// It takes a regular server implementing the TypeTesterService
-// interface, and returns a new server stub.
-func NewServerTypeTester(server TypeTesterService) interface{} {
- stub := &ServerStubTypeTester{
- service: server,
- }
- var gs _gen_ipc.GlobState
- var self interface{} = stub
- // VAllGlobber is implemented by the server object, which is wrapped in
- // a VDL generated server stub.
- if x, ok := self.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VAllGlobber is implemented by the server object without using a VDL
- // generated stub.
- if x, ok := server.(_gen_ipc.VAllGlobber); ok {
- gs.VAllGlobber = x
- }
- // VChildrenGlobber is implemented in the server object.
- if x, ok := server.(_gen_ipc.VChildrenGlobber); ok {
- gs.VChildrenGlobber = x
- }
- stub.gs = &gs
return stub
}
-// clientStubTypeTester implements TypeTester.
-type clientStubTypeTester struct {
- defaultClient _gen_ipc.Client
- name string
+type implTypeTesterServerStub struct {
+ impl TypeTesterServerMethods
+ gs *__ipc.GlobState
}
-func (__gen_c *clientStubTypeTester) client(ctx _gen_context.T) _gen_ipc.Client {
- if __gen_c.defaultClient != nil {
- return __gen_c.defaultClient
- }
- return _gen_veyron2.RuntimeFromContext(ctx).Client()
+func (s implTypeTesterServerStub) EchoBool(call __ipc.ServerCall, i0 bool) (bool, error) {
+ return s.impl.EchoBool(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoBool(ctx _gen_context.T, I1 bool, opts ..._gen_ipc.CallOpt) (reply bool, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoBool", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoFloat32(call __ipc.ServerCall, i0 float32) (float32, error) {
+ return s.impl.EchoFloat32(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoFloat32(ctx _gen_context.T, I1 float32, opts ..._gen_ipc.CallOpt) (reply float32, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoFloat32", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoFloat64(call __ipc.ServerCall, i0 float64) (float64, error) {
+ return s.impl.EchoFloat64(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoFloat64(ctx _gen_context.T, I1 float64, opts ..._gen_ipc.CallOpt) (reply float64, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoFloat64", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoInt32(call __ipc.ServerCall, i0 int32) (int32, error) {
+ return s.impl.EchoInt32(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoInt32(ctx _gen_context.T, I1 int32, opts ..._gen_ipc.CallOpt) (reply int32, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoInt32", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoInt64(call __ipc.ServerCall, i0 int64) (int64, error) {
+ return s.impl.EchoInt64(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoInt64(ctx _gen_context.T, I1 int64, opts ..._gen_ipc.CallOpt) (reply int64, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoInt64", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoString(call __ipc.ServerCall, i0 string) (string, error) {
+ return s.impl.EchoString(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoString(ctx _gen_context.T, I1 string, opts ..._gen_ipc.CallOpt) (reply string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoString", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoByte(call __ipc.ServerCall, i0 byte) (byte, error) {
+ return s.impl.EchoByte(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoByte(ctx _gen_context.T, I1 byte, opts ..._gen_ipc.CallOpt) (reply byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoByte", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoUInt32(call __ipc.ServerCall, i0 uint32) (uint32, error) {
+ return s.impl.EchoUInt32(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoUInt32(ctx _gen_context.T, I1 uint32, opts ..._gen_ipc.CallOpt) (reply uint32, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoUInt32", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) EchoUInt64(call __ipc.ServerCall, i0 uint64) (uint64, error) {
+ return s.impl.EchoUInt64(call, i0)
}
-func (__gen_c *clientStubTypeTester) EchoUInt64(ctx _gen_context.T, I1 uint64, opts ..._gen_ipc.CallOpt) (reply uint64, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "EchoUInt64", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) InputArray(call __ipc.ServerCall, i0 [2]byte) error {
+ return s.impl.InputArray(call, i0)
}
-func (__gen_c *clientStubTypeTester) InputArray(ctx _gen_context.T, I1 [2]byte, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "InputArray", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) InputMap(call __ipc.ServerCall, i0 map[byte]byte) error {
+ return s.impl.InputMap(call, i0)
}
-func (__gen_c *clientStubTypeTester) InputMap(ctx _gen_context.T, I1 map[byte]byte, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "InputMap", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) InputSlice(call __ipc.ServerCall, i0 []byte) error {
+ return s.impl.InputSlice(call, i0)
}
-func (__gen_c *clientStubTypeTester) InputSlice(ctx _gen_context.T, I1 []byte, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "InputSlice", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) InputStruct(call __ipc.ServerCall, i0 Struct) error {
+ return s.impl.InputStruct(call, i0)
}
-func (__gen_c *clientStubTypeTester) InputStruct(ctx _gen_context.T, I1 Struct, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "InputStruct", []interface{}{I1}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) OutputArray(call __ipc.ServerCall) ([2]byte, error) {
+ return s.impl.OutputArray(call)
}
-func (__gen_c *clientStubTypeTester) OutputArray(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply [2]byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "OutputArray", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) OutputMap(call __ipc.ServerCall) (map[byte]byte, error) {
+ return s.impl.OutputMap(call)
}
-func (__gen_c *clientStubTypeTester) OutputMap(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply map[byte]byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "OutputMap", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) OutputSlice(call __ipc.ServerCall) ([]byte, error) {
+ return s.impl.OutputSlice(call)
}
-func (__gen_c *clientStubTypeTester) OutputSlice(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []byte, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "OutputSlice", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) OutputStruct(call __ipc.ServerCall) (Struct, error) {
+ return s.impl.OutputStruct(call)
}
-func (__gen_c *clientStubTypeTester) OutputStruct(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply Struct, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "OutputStruct", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) NoArguments(call __ipc.ServerCall) error {
+ return s.impl.NoArguments(call)
}
-func (__gen_c *clientStubTypeTester) NoArguments(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "NoArguments", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) MultipleArguments(call __ipc.ServerCall, i0 int32, i1 int32) (int32, int32, error) {
+ return s.impl.MultipleArguments(call, i0, i1)
}
-func (__gen_c *clientStubTypeTester) MultipleArguments(ctx _gen_context.T, I1 int32, I2 int32, opts ..._gen_ipc.CallOpt) (O1 int32, O2 int32, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "MultipleArguments", []interface{}{I1, I2}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&O1, &O2, &err); ierr != nil {
- err = ierr
- }
- return
+func (s implTypeTesterServerStub) StreamingOutput(call __ipc.ServerCall, i0 int32, i1 bool) error {
+ ctx := &implTypeTesterStreamingOutputContext{call, implTypeTesterStreamingOutputServerSend{call}}
+ return s.impl.StreamingOutput(ctx, i0, i1)
}
-func (__gen_c *clientStubTypeTester) StreamingOutput(ctx _gen_context.T, NumStreamItems int32, StreamItem bool, opts ..._gen_ipc.CallOpt) (reply TypeTesterStreamingOutputCall, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "StreamingOutput", []interface{}{NumStreamItems, StreamItem}, opts...); err != nil {
- return
- }
- reply = &implTypeTesterStreamingOutputCall{clientCall: call, readStream: implTypeTesterStreamingOutputStreamIterator{clientCall: call}}
- return
+func (s implTypeTesterServerStub) VGlob() *__ipc.GlobState {
+ return s.gs
}
-func (__gen_c *clientStubTypeTester) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubTypeTester) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-func (__gen_c *clientStubTypeTester) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) {
- var call _gen_ipc.Call
- if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&reply, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
-// ServerStubTypeTester wraps a server that implements
-// TypeTesterService and provides an object that satisfies
-// the requirements of veyron2/ipc.ReflectInvoker.
-type ServerStubTypeTester struct {
- service TypeTesterService
- gs *_gen_ipc.GlobState
-}
-
-func (__gen_s *ServerStubTypeTester) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) {
- // TODO(bprosnitz) GetMethodTags() will be replaces with Signature().
- // Note: This exhibits some weird behavior like returning a nil error if the method isn't found.
- // This will change when it is replaced with Signature().
+func (s implTypeTesterServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
+ // TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "EchoBool":
return []interface{}{}, nil
@@ -581,183 +624,184 @@
}
}
-func (__gen_s *ServerStubTypeTester) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
- result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
- result.Methods["EchoBool"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+func (s implTypeTesterServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
+ // TODO(toddw) Replace with new DescribeInterfaces implementation.
+ result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
+ result.Methods["EchoBool"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 2},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 2},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoByte"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoByte"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 66},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 66},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoFloat32"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoFloat32"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 25},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 25},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoFloat64"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoFloat64"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 26},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 26},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoInt32"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoInt32"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 36},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 36},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoInt64"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoInt64"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 37},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 37},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoString"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoString"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 3},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 3},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoUInt32"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoUInt32"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 52},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 52},
{Name: "E", Type: 65},
},
}
- result.Methods["EchoUInt64"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["EchoUInt64"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 53},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 53},
{Name: "E", Type: 65},
},
}
- result.Methods["InputArray"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["InputArray"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 67},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "E", Type: 65},
},
}
- result.Methods["InputMap"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["InputMap"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 68},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "E", Type: 65},
},
}
- result.Methods["InputSlice"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["InputSlice"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 69},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "E", Type: 65},
},
}
- result.Methods["InputStruct"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["InputStruct"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 70},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "E", Type: 65},
},
}
- result.Methods["MultipleArguments"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["MultipleArguments"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "I1", Type: 36},
{Name: "I2", Type: 36},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 36},
{Name: "O2", Type: 36},
{Name: "E", Type: 65},
},
}
- result.Methods["NoArguments"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["NoArguments"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
- result.Methods["OutputArray"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["OutputArray"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 67},
{Name: "E", Type: 65},
},
}
- result.Methods["OutputMap"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["OutputMap"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 68},
{Name: "E", Type: 65},
},
}
- result.Methods["OutputSlice"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["OutputSlice"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 69},
{Name: "E", Type: 65},
},
}
- result.Methods["OutputStruct"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{},
- OutArgs: []_gen_ipc.MethodArgument{
+ result.Methods["OutputStruct"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{},
+ OutArgs: []__ipc.MethodArgument{
{Name: "O1", Type: 70},
{Name: "E", Type: 65},
},
}
- result.Methods["StreamingOutput"] = _gen_ipc.MethodSignature{
- InArgs: []_gen_ipc.MethodArgument{
+ result.Methods["StreamingOutput"] = __ipc.MethodSignature{
+ InArgs: []__ipc.MethodArgument{
{Name: "NumStreamItems", Type: 36},
{Name: "StreamItem", Type: 2},
},
- OutArgs: []_gen_ipc.MethodArgument{
+ OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
OutStream: 2,
}
- result.TypeDefs = []_gen_vdlutil.Any{
- _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.ArrayType{Elem: 0x42, Len: 0x2, Name: "", Tags: []string(nil)}, _gen_wiretype.MapType{Key: 0x42, Elem: 0x42, Name: "", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
- []_gen_wiretype.FieldType{
- _gen_wiretype.FieldType{Type: 0x24, Name: "X"},
- _gen_wiretype.FieldType{Type: 0x24, Name: "Y"},
+ result.TypeDefs = []__vdlutil.Any{
+ __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.ArrayType{Elem: 0x42, Len: 0x2, Name: "", Tags: []string(nil)}, __wiretype.MapType{Key: 0x42, Elem: 0x42, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}, __wiretype.StructType{
+ []__wiretype.FieldType{
+ __wiretype.FieldType{Type: 0x24, Name: "X"},
+ __wiretype.FieldType{Type: 0x24, Name: "Y"},
},
"veyron.io/veyron/veyron/tools/vrpc/test_base.Struct", []string(nil)},
}
@@ -765,125 +809,38 @@
return result, nil
}
-func (__gen_s *ServerStubTypeTester) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
- if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok {
- return unresolver.UnresolveStep(call)
+// TypeTesterStreamingOutputServerStream is the server stream for TypeTester.StreamingOutput.
+type TypeTesterStreamingOutputServerStream interface {
+ // SendStream returns the send side of the server stream.
+ SendStream() interface {
+ // Send places the item onto the output stream. Returns errors encountered
+ // while sending. Blocks if there is no buffer space; will unblock when
+ // buffer space is available.
+ Send(item bool) error
}
- if call.Server() == nil {
- return
- }
- var published []string
- if published, err = call.Server().Published(); err != nil || published == nil {
- return
- }
- reply = make([]string, len(published))
- for i, p := range published {
- reply[i] = _gen_naming.Join(p, call.Name())
- }
- return
}
-func (__gen_s *ServerStubTypeTester) VGlob() *_gen_ipc.GlobState {
- return __gen_s.gs
+// TypeTesterStreamingOutputContext represents the context passed to TypeTester.StreamingOutput.
+type TypeTesterStreamingOutputContext interface {
+ __ipc.ServerContext
+ TypeTesterStreamingOutputServerStream
}
-func (__gen_s *ServerStubTypeTester) EchoBool(call _gen_ipc.ServerCall, I1 bool) (reply bool, err error) {
- reply, err = __gen_s.service.EchoBool(call, I1)
- return
+type implTypeTesterStreamingOutputServerSend struct {
+ call __ipc.ServerCall
}
-func (__gen_s *ServerStubTypeTester) EchoFloat32(call _gen_ipc.ServerCall, I1 float32) (reply float32, err error) {
- reply, err = __gen_s.service.EchoFloat32(call, I1)
- return
+func (s *implTypeTesterStreamingOutputServerSend) Send(item bool) error {
+ return s.call.Send(item)
}
-func (__gen_s *ServerStubTypeTester) EchoFloat64(call _gen_ipc.ServerCall, I1 float64) (reply float64, err error) {
- reply, err = __gen_s.service.EchoFloat64(call, I1)
- return
+type implTypeTesterStreamingOutputContext struct {
+ __ipc.ServerContext
+ send implTypeTesterStreamingOutputServerSend
}
-func (__gen_s *ServerStubTypeTester) EchoInt32(call _gen_ipc.ServerCall, I1 int32) (reply int32, err error) {
- reply, err = __gen_s.service.EchoInt32(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) EchoInt64(call _gen_ipc.ServerCall, I1 int64) (reply int64, err error) {
- reply, err = __gen_s.service.EchoInt64(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) EchoString(call _gen_ipc.ServerCall, I1 string) (reply string, err error) {
- reply, err = __gen_s.service.EchoString(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) EchoByte(call _gen_ipc.ServerCall, I1 byte) (reply byte, err error) {
- reply, err = __gen_s.service.EchoByte(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) EchoUInt32(call _gen_ipc.ServerCall, I1 uint32) (reply uint32, err error) {
- reply, err = __gen_s.service.EchoUInt32(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) EchoUInt64(call _gen_ipc.ServerCall, I1 uint64) (reply uint64, err error) {
- reply, err = __gen_s.service.EchoUInt64(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) InputArray(call _gen_ipc.ServerCall, I1 [2]byte) (err error) {
- err = __gen_s.service.InputArray(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) InputMap(call _gen_ipc.ServerCall, I1 map[byte]byte) (err error) {
- err = __gen_s.service.InputMap(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) InputSlice(call _gen_ipc.ServerCall, I1 []byte) (err error) {
- err = __gen_s.service.InputSlice(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) InputStruct(call _gen_ipc.ServerCall, I1 Struct) (err error) {
- err = __gen_s.service.InputStruct(call, I1)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) OutputArray(call _gen_ipc.ServerCall) (reply [2]byte, err error) {
- reply, err = __gen_s.service.OutputArray(call)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) OutputMap(call _gen_ipc.ServerCall) (reply map[byte]byte, err error) {
- reply, err = __gen_s.service.OutputMap(call)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) OutputSlice(call _gen_ipc.ServerCall) (reply []byte, err error) {
- reply, err = __gen_s.service.OutputSlice(call)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) OutputStruct(call _gen_ipc.ServerCall) (reply Struct, err error) {
- reply, err = __gen_s.service.OutputStruct(call)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) NoArguments(call _gen_ipc.ServerCall) (err error) {
- err = __gen_s.service.NoArguments(call)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) MultipleArguments(call _gen_ipc.ServerCall, I1 int32, I2 int32) (O1 int32, O2 int32, err error) {
- O1, O2, err = __gen_s.service.MultipleArguments(call, I1, I2)
- return
-}
-
-func (__gen_s *ServerStubTypeTester) StreamingOutput(call _gen_ipc.ServerCall, NumStreamItems int32, StreamItem bool) (err error) {
- stream := &implTypeTesterServiceStreamingOutputStream{writer: implTypeTesterServiceStreamingOutputStreamSender{serverCall: call}}
- err = __gen_s.service.StreamingOutput(call, NumStreamItems, StreamItem, stream)
- return
+func (s *implTypeTesterStreamingOutputContext) SendStream() interface {
+ Send(item bool) error
+} {
+ return &s.send
}