Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
| 2 | // Source: wire.vdl |
| 3 | |
| 4 | package server |
| 5 | |
| 6 | import ( |
| 7 | "veyron2/security" |
| 8 | |
| 9 | "veyron2/security/wire" |
| 10 | |
| 11 | // The non-user imports are prefixed with "_gen_" to prevent collisions. |
| 12 | _gen_veyron2 "veyron2" |
| 13 | _gen_context "veyron2/context" |
| 14 | _gen_ipc "veyron2/ipc" |
| 15 | _gen_naming "veyron2/naming" |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 16 | _gen_vdlutil "veyron2/vdl/vdlutil" |
| 17 | _gen_wiretype "veyron2/wiretype" |
| 18 | ) |
| 19 | |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 20 | // TODO(bprosnitz) Remove this line once signatures are updated to use typevals. |
| 21 | // It corrects a bug where _gen_wiretype is unused in VDL pacakges where only bootstrap types are used on interfaces. |
| 22 | const _ = _gen_wiretype.TypeIDInvalid |
| 23 | |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 24 | // Agent is the interface the client binds and uses. |
| 25 | // Agent_ExcludingUniversal is the interface without internal framework-added methods |
| 26 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 27 | type Agent_ExcludingUniversal interface { |
| 28 | Sign(ctx _gen_context.T, message []byte, opts ..._gen_ipc.CallOpt) (reply security.Signature, err error) |
| 29 | PublicKey(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply wire.PublicKey, err error) |
| 30 | } |
| 31 | type Agent interface { |
| 32 | _gen_ipc.UniversalServiceMethods |
| 33 | Agent_ExcludingUniversal |
| 34 | } |
| 35 | |
| 36 | // AgentService is the interface the server implements. |
| 37 | type AgentService interface { |
| 38 | Sign(context _gen_ipc.ServerContext, message []byte) (reply security.Signature, err error) |
| 39 | PublicKey(context _gen_ipc.ServerContext) (reply wire.PublicKey, err error) |
| 40 | } |
| 41 | |
| 42 | // BindAgent returns the client stub implementing the Agent |
| 43 | // interface. |
| 44 | // |
| 45 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 46 | // global Runtime is used. |
| 47 | func BindAgent(name string, opts ..._gen_ipc.BindOpt) (Agent, error) { |
| 48 | var client _gen_ipc.Client |
| 49 | switch len(opts) { |
| 50 | case 0: |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 51 | // Do nothing. |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 52 | case 1: |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 53 | if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok { |
| 54 | client = clientOpt |
| 55 | } else { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 56 | return nil, _gen_vdlutil.ErrUnrecognizedOption |
| 57 | } |
| 58 | default: |
| 59 | return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
| 60 | } |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 61 | stub := &clientStubAgent{defaultClient: client, name: name} |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 62 | |
| 63 | return stub, nil |
| 64 | } |
| 65 | |
| 66 | // NewServerAgent creates a new server stub. |
| 67 | // |
| 68 | // It takes a regular server implementing the AgentService |
| 69 | // interface, and returns a new server stub. |
| 70 | func NewServerAgent(server AgentService) interface{} { |
| 71 | return &ServerStubAgent{ |
| 72 | service: server, |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // clientStubAgent implements Agent. |
| 77 | type clientStubAgent struct { |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 78 | defaultClient _gen_ipc.Client |
| 79 | name string |
| 80 | } |
| 81 | |
| 82 | func (__gen_c *clientStubAgent) client(ctx _gen_context.T) _gen_ipc.Client { |
| 83 | if __gen_c.defaultClient != nil { |
| 84 | return __gen_c.defaultClient |
| 85 | } |
| 86 | return _gen_veyron2.RuntimeFromContext(ctx).Client() |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | func (__gen_c *clientStubAgent) Sign(ctx _gen_context.T, message []byte, opts ..._gen_ipc.CallOpt) (reply security.Signature, err error) { |
| 90 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 91 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Sign", []interface{}{message}, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 92 | return |
| 93 | } |
| 94 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 95 | err = ierr |
| 96 | } |
| 97 | return |
| 98 | } |
| 99 | |
| 100 | func (__gen_c *clientStubAgent) PublicKey(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply wire.PublicKey, err error) { |
| 101 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 102 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "PublicKey", nil, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 103 | return |
| 104 | } |
| 105 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 106 | err = ierr |
| 107 | } |
| 108 | return |
| 109 | } |
| 110 | |
| 111 | func (__gen_c *clientStubAgent) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
| 112 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 113 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 114 | return |
| 115 | } |
| 116 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 117 | err = ierr |
| 118 | } |
| 119 | return |
| 120 | } |
| 121 | |
| 122 | func (__gen_c *clientStubAgent) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
| 123 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 124 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 125 | return |
| 126 | } |
| 127 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 128 | err = ierr |
| 129 | } |
| 130 | return |
| 131 | } |
| 132 | |
| 133 | func (__gen_c *clientStubAgent) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) { |
| 134 | var call _gen_ipc.Call |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame^] | 135 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 136 | return |
| 137 | } |
| 138 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 139 | err = ierr |
| 140 | } |
| 141 | return |
| 142 | } |
| 143 | |
| 144 | // ServerStubAgent wraps a server that implements |
| 145 | // AgentService and provides an object that satisfies |
| 146 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 147 | type ServerStubAgent struct { |
| 148 | service AgentService |
| 149 | } |
| 150 | |
| 151 | func (__gen_s *ServerStubAgent) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 152 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 153 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 154 | // This will change when it is replaced with Signature(). |
| 155 | switch method { |
| 156 | case "Sign": |
| 157 | return []interface{}{}, nil |
| 158 | case "PublicKey": |
| 159 | return []interface{}{}, nil |
| 160 | default: |
| 161 | return nil, nil |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | func (__gen_s *ServerStubAgent) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| 166 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 167 | result.Methods["PublicKey"] = _gen_ipc.MethodSignature{ |
| 168 | InArgs: []_gen_ipc.MethodArgument{}, |
| 169 | OutArgs: []_gen_ipc.MethodArgument{ |
| 170 | {Name: "", Type: 71}, |
| 171 | {Name: "", Type: 69}, |
| 172 | }, |
| 173 | } |
| 174 | result.Methods["Sign"] = _gen_ipc.MethodSignature{ |
| 175 | InArgs: []_gen_ipc.MethodArgument{ |
| 176 | {Name: "message", Type: 66}, |
| 177 | }, |
| 178 | OutArgs: []_gen_ipc.MethodArgument{ |
| 179 | {Name: "", Type: 68}, |
| 180 | {Name: "", Type: 69}, |
| 181 | }, |
| 182 | } |
| 183 | |
| 184 | result.TypeDefs = []_gen_vdlutil.Any{ |
| 185 | _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x3, Name: "veyron2/security.Hash", Tags: []string(nil)}, _gen_wiretype.StructType{ |
| 186 | []_gen_wiretype.FieldType{ |
Ryan Brown | 9a888a6 | 2014-09-16 12:58:43 -0700 | [diff] [blame] | 187 | _gen_wiretype.FieldType{Type: 0x42, Name: "Purpose"}, |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 188 | _gen_wiretype.FieldType{Type: 0x43, Name: "Hash"}, |
| 189 | _gen_wiretype.FieldType{Type: 0x42, Name: "R"}, |
| 190 | _gen_wiretype.FieldType{Type: 0x42, Name: "S"}, |
| 191 | }, |
| 192 | "veyron2/security.Signature", []string(nil)}, |
| 193 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "veyron2/security/wire.KeyCurve", Tags: []string(nil)}, _gen_wiretype.StructType{ |
| 194 | []_gen_wiretype.FieldType{ |
| 195 | _gen_wiretype.FieldType{Type: 0x46, Name: "Curve"}, |
| 196 | _gen_wiretype.FieldType{Type: 0x42, Name: "XY"}, |
| 197 | }, |
| 198 | "veyron2/security/wire.PublicKey", []string(nil)}, |
| 199 | } |
| 200 | |
| 201 | return result, nil |
| 202 | } |
| 203 | |
| 204 | func (__gen_s *ServerStubAgent) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 205 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
| 206 | return unresolver.UnresolveStep(call) |
| 207 | } |
| 208 | if call.Server() == nil { |
| 209 | return |
| 210 | } |
| 211 | var published []string |
| 212 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 213 | return |
| 214 | } |
| 215 | reply = make([]string, len(published)) |
| 216 | for i, p := range published { |
| 217 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 218 | } |
| 219 | return |
| 220 | } |
| 221 | |
| 222 | func (__gen_s *ServerStubAgent) Sign(call _gen_ipc.ServerCall, message []byte) (reply security.Signature, err error) { |
| 223 | reply, err = __gen_s.service.Sign(call, message) |
| 224 | return |
| 225 | } |
| 226 | |
| 227 | func (__gen_s *ServerStubAgent) PublicKey(call _gen_ipc.ServerCall) (reply wire.PublicKey, err error) { |
| 228 | reply, err = __gen_s.service.PublicKey(call) |
| 229 | return |
| 230 | } |