veyron2/vdl: New API for generated Go interfaces.
The main change is for generated streaming methods on the server side. Here's
how they used to look:
Count(ctx ipc.ServerContext, start int32, stream ArithServiceCountStream) error
Here's the new way:
Count(ctx ArithCountContext, start int32) error
Instead of passing in a context and stream separately, we're now
passing them together. This keeps the client and server
interfaces more uniform, which helps simplify the generator
logic, and may be useful for the new Signature implementation.
There's also lots of renaming. In the new scheme, if the user
creates a VDL interface Arith, all generated funcs and interfaces
start with Arith. This means we'll support unexported VDL
interfaces "for free", and also improves generated godoc by
grouping things together.
Here's a renaming cheatsheet; given a VDL interface Foo with one
streaming and one non-streaming method:
type Foo interface {
XXX()
YYY() stream<a, b>
}
type Foo_ExcludingUniversal -> FooClientMethods
type Foo -> FooClientStub
func BindFoo() -> FooClient()
type FooService -> FooServerMethods
type ServerStubFoo -> FooServerStub
func NewServerFoo() -> FooServer()
type FooYYYCall -> FooYYYCall
-> FooYYYClientStream
type FooServiceYYYStream -> FooYYYServerStream
-> FooYYYContext
Change-Id: I48e9dd2ab676da50f9c989368ed849e2d0e95256
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)