blob: 5b969bd854993a917da3b8ed02e3b3f688850187 [file] [log] [blame]
Ryan Brownfed691e2014-09-15 13:09:40 -07001// This file was auto-generated by the veyron vdl tool.
2// Source: wire.vdl
3
4package main
5
6import (
Todd Wang702385a2014-11-07 01:54:08 -08007 // The non-user imports are prefixed with "__" to prevent collisions.
8 __veyron2 "veyron.io/veyron/veyron2"
9 __context "veyron.io/veyron/veyron2/context"
10 __ipc "veyron.io/veyron/veyron2/ipc"
11 __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
12 __wiretype "veyron.io/veyron/veyron2/wiretype"
Ryan Brownfed691e2014-09-15 13:09:40 -070013)
14
Jing Jin896d7762014-11-03 11:18:52 -080015// TODO(toddw): Remove this line once the new signature support is done.
Todd Wang702385a2014-11-07 01:54:08 -080016// It corrects a bug where __wiretype is unused in VDL pacakges where only
Jing Jin896d7762014-11-03 11:18:52 -080017// bootstrap types are used on interfaces.
Todd Wang702385a2014-11-07 01:54:08 -080018const _ = __wiretype.TypeIDInvalid
Ken Ashcrafte027b5c2014-09-16 14:20:20 -070019
Todd Wang702385a2014-11-07 01:54:08 -080020// PingPongClientMethods is the client interface
21// containing PingPong methods.
22//
Ryan Brownf6b92272014-09-16 13:24:28 -070023// Simple service used in the agent tests.
Todd Wang702385a2014-11-07 01:54:08 -080024type PingPongClientMethods interface {
25 Ping(ctx __context.T, message string, opts ...__ipc.CallOpt) (string, error)
Ryan Brownfed691e2014-09-15 13:09:40 -070026}
27
Todd Wang702385a2014-11-07 01:54:08 -080028// PingPongClientStub adds universal methods to PingPongClientMethods.
29type PingPongClientStub interface {
30 PingPongClientMethods
31 __ipc.UniversalServiceMethods
Ryan Brownfed691e2014-09-15 13:09:40 -070032}
33
Todd Wang702385a2014-11-07 01:54:08 -080034// PingPongClient returns a client stub for PingPong.
35func PingPongClient(name string, opts ...__ipc.BindOpt) PingPongClientStub {
36 var client __ipc.Client
37 for _, opt := range opts {
38 if clientOpt, ok := opt.(__ipc.Client); ok {
Ken Ashcrafte027b5c2014-09-16 14:20:20 -070039 client = clientOpt
Ryan Brownfed691e2014-09-15 13:09:40 -070040 }
Ryan Brownfed691e2014-09-15 13:09:40 -070041 }
Todd Wang702385a2014-11-07 01:54:08 -080042 return implPingPongClientStub{name, client}
Ryan Brownfed691e2014-09-15 13:09:40 -070043}
44
Todd Wang702385a2014-11-07 01:54:08 -080045type implPingPongClientStub struct {
46 name string
47 client __ipc.Client
48}
49
50func (c implPingPongClientStub) c(ctx __context.T) __ipc.Client {
51 if c.client != nil {
52 return c.client
53 }
54 return __veyron2.RuntimeFromContext(ctx).Client()
55}
56
57func (c implPingPongClientStub) Ping(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (o0 string, err error) {
58 var call __ipc.Call
59 if call, err = c.c(ctx).StartCall(ctx, c.name, "Ping", []interface{}{i0}, opts...); err != nil {
60 return
61 }
62 if ierr := call.Finish(&o0, &err); ierr != nil {
63 err = ierr
64 }
65 return
66}
67
68func (c implPingPongClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
69 var call __ipc.Call
70 if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
71 return
72 }
73 if ierr := call.Finish(&o0, &err); ierr != nil {
74 err = ierr
75 }
76 return
77}
78
79func (c implPingPongClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
80 var call __ipc.Call
81 if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
82 return
83 }
84 if ierr := call.Finish(&o0, &err); ierr != nil {
85 err = ierr
86 }
87 return
88}
89
90// PingPongServerMethods is the interface a server writer
91// implements for PingPong.
Ryan Brownfed691e2014-09-15 13:09:40 -070092//
Todd Wang702385a2014-11-07 01:54:08 -080093// Simple service used in the agent tests.
94type PingPongServerMethods interface {
95 Ping(ctx __ipc.ServerContext, message string) (string, error)
96}
97
98// PingPongServerStubMethods is the server interface containing
99// PingPong methods, as expected by ipc.Server. The difference between
100// this interface and PingPongServerMethods is that the first context
101// argument for each method is always ipc.ServerCall here, while it is either
102// ipc.ServerContext or a typed streaming context there.
103type PingPongServerStubMethods interface {
104 Ping(call __ipc.ServerCall, message string) (string, error)
105}
106
107// PingPongServerStub adds universal methods to PingPongServerStubMethods.
108type PingPongServerStub interface {
109 PingPongServerStubMethods
110 // GetMethodTags will be replaced with DescribeInterfaces.
111 GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
112 // Signature will be replaced with DescribeInterfaces.
113 Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
114}
115
116// PingPongServer returns a server stub for PingPong.
117// It converts an implementation of PingPongServerMethods into
118// an object that may be used by ipc.Server.
119func PingPongServer(impl PingPongServerMethods) PingPongServerStub {
120 stub := implPingPongServerStub{
121 impl: impl,
Ryan Brownfed691e2014-09-15 13:09:40 -0700122 }
Todd Wang702385a2014-11-07 01:54:08 -0800123 // Initialize GlobState; always check the stub itself first, to handle the
124 // case where the user has the Glob method defined in their VDL source.
125 if gs := __ipc.NewGlobState(stub); gs != nil {
126 stub.gs = gs
127 } else if gs := __ipc.NewGlobState(impl); gs != nil {
128 stub.gs = gs
Robin Thellend94bc4642014-11-05 18:05:08 -0800129 }
Robin Thellend94bc4642014-11-05 18:05:08 -0800130 return stub
Ryan Brownfed691e2014-09-15 13:09:40 -0700131}
132
Todd Wang702385a2014-11-07 01:54:08 -0800133type implPingPongServerStub struct {
134 impl PingPongServerMethods
135 gs *__ipc.GlobState
Ken Ashcrafte027b5c2014-09-16 14:20:20 -0700136}
137
Todd Wang702385a2014-11-07 01:54:08 -0800138func (s implPingPongServerStub) Ping(call __ipc.ServerCall, i0 string) (string, error) {
139 return s.impl.Ping(call, i0)
Ryan Brownfed691e2014-09-15 13:09:40 -0700140}
141
Todd Wang702385a2014-11-07 01:54:08 -0800142func (s implPingPongServerStub) VGlob() *__ipc.GlobState {
143 return s.gs
Ryan Brownfed691e2014-09-15 13:09:40 -0700144}
145
Todd Wang702385a2014-11-07 01:54:08 -0800146func (s implPingPongServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
147 // TODO(toddw): Replace with new DescribeInterfaces implementation.
Ryan Brownfed691e2014-09-15 13:09:40 -0700148 switch method {
149 case "Ping":
150 return []interface{}{}, nil
151 default:
152 return nil, nil
153 }
154}
155
Todd Wang702385a2014-11-07 01:54:08 -0800156func (s implPingPongServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
157 // TODO(toddw) Replace with new DescribeInterfaces implementation.
158 result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
159 result.Methods["Ping"] = __ipc.MethodSignature{
160 InArgs: []__ipc.MethodArgument{
Ryan Brownfed691e2014-09-15 13:09:40 -0700161 {Name: "message", Type: 3},
162 },
Todd Wang702385a2014-11-07 01:54:08 -0800163 OutArgs: []__ipc.MethodArgument{
Ryan Brownfed691e2014-09-15 13:09:40 -0700164 {Name: "", Type: 3},
165 {Name: "", Type: 65},
166 },
167 }
168
Todd Wang702385a2014-11-07 01:54:08 -0800169 result.TypeDefs = []__vdlutil.Any{
170 __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
Ryan Brownfed691e2014-09-15 13:09:40 -0700171
172 return result, nil
173}