Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
| 2 | // Source: repository.vdl |
| 3 | |
| 4 | // Package repository contains implementation of the interface for |
| 5 | // storing and serving various veyron management objects. |
| 6 | package repository |
| 7 | |
| 8 | import ( |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 9 | "veyron.io/veyron/veyron/services/mgmt/profile" |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 10 | |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 11 | "veyron.io/veyron/veyron2/security" |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 12 | |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 13 | "veyron.io/veyron/veyron2/services/mgmt/application" |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 14 | |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 15 | "veyron.io/veyron/veyron2/services/mgmt/repository" |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 16 | |
| 17 | // The non-user imports are prefixed with "_gen_" to prevent collisions. |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 18 | _gen_veyron2 "veyron.io/veyron/veyron2" |
| 19 | _gen_context "veyron.io/veyron/veyron2/context" |
| 20 | _gen_ipc "veyron.io/veyron/veyron2/ipc" |
| 21 | _gen_naming "veyron.io/veyron/veyron2/naming" |
| 22 | _gen_vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil" |
| 23 | _gen_wiretype "veyron.io/veyron/veyron2/wiretype" |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
Jing Jin | 896d776 | 2014-11-03 11:18:52 -0800 | [diff] [blame] | 26 | // TODO(toddw): Remove this line once the new signature support is done. |
| 27 | // It corrects a bug where _gen_wiretype is unused in VDL pacakges where only |
| 28 | // bootstrap types are used on interfaces. |
Shyam Jayaraman | c4aed6e | 2014-07-22 14:25:06 -0700 | [diff] [blame] | 29 | const _ = _gen_wiretype.TypeIDInvalid |
| 30 | |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 31 | // Application describes an application repository internally. Besides |
| 32 | // the public Application interface, it allows to add and remove |
| 33 | // application envelopes. |
| 34 | // Application is the interface the client binds and uses. |
| 35 | // Application_ExcludingUniversal is the interface without internal framework-added methods |
| 36 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 37 | type Application_ExcludingUniversal interface { |
| 38 | // Application provides access to application envelopes. An |
| 39 | // application envelope is identified by an application name and an |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 40 | // application version, which are specified through the object name, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 41 | // and a profile name, which is specified using a method argument. |
| 42 | // |
| 43 | // Example: |
| 44 | // /apps/search/v1.Match([]string{"base", "media"}) |
| 45 | // returns an application envelope that can be used for downloading |
| 46 | // and executing the "search" application, version "v1", runnable |
| 47 | // on either the "base" or "media" profile. |
| 48 | repository.Application_ExcludingUniversal |
| 49 | // Put adds the given tuple of application version (specified |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 50 | // through the object name suffix) and application envelope to all |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 51 | // of the given application profiles. |
| 52 | Put(ctx _gen_context.T, Profiles []string, Envelope application.Envelope, opts ..._gen_ipc.CallOpt) (err error) |
| 53 | // Remove removes the application envelope for the given profile |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 54 | // name and application version (specified through the object name |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 55 | // suffix). If no version is specified as part of the suffix, the |
| 56 | // method removes all versions for the given profile. |
| 57 | // |
| 58 | // TODO(jsimsa): Add support for using "*" to specify all profiles |
| 59 | // when Matt implements Globing (or Ken implements querying). |
| 60 | Remove(ctx _gen_context.T, Profile string, opts ..._gen_ipc.CallOpt) (err error) |
| 61 | } |
| 62 | type Application interface { |
| 63 | _gen_ipc.UniversalServiceMethods |
| 64 | Application_ExcludingUniversal |
| 65 | } |
| 66 | |
| 67 | // ApplicationService is the interface the server implements. |
| 68 | type ApplicationService interface { |
| 69 | |
| 70 | // Application provides access to application envelopes. An |
| 71 | // application envelope is identified by an application name and an |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 72 | // application version, which are specified through the object name, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 73 | // and a profile name, which is specified using a method argument. |
| 74 | // |
| 75 | // Example: |
| 76 | // /apps/search/v1.Match([]string{"base", "media"}) |
| 77 | // returns an application envelope that can be used for downloading |
| 78 | // and executing the "search" application, version "v1", runnable |
| 79 | // on either the "base" or "media" profile. |
| 80 | repository.ApplicationService |
| 81 | // Put adds the given tuple of application version (specified |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 82 | // through the object name suffix) and application envelope to all |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 83 | // of the given application profiles. |
| 84 | Put(context _gen_ipc.ServerContext, Profiles []string, Envelope application.Envelope) (err error) |
| 85 | // Remove removes the application envelope for the given profile |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 86 | // name and application version (specified through the object name |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 87 | // suffix). If no version is specified as part of the suffix, the |
| 88 | // method removes all versions for the given profile. |
| 89 | // |
| 90 | // TODO(jsimsa): Add support for using "*" to specify all profiles |
| 91 | // when Matt implements Globing (or Ken implements querying). |
| 92 | Remove(context _gen_ipc.ServerContext, Profile string) (err error) |
| 93 | } |
| 94 | |
| 95 | // BindApplication returns the client stub implementing the Application |
| 96 | // interface. |
| 97 | // |
| 98 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 99 | // global Runtime is used. |
| 100 | func BindApplication(name string, opts ..._gen_ipc.BindOpt) (Application, error) { |
| 101 | var client _gen_ipc.Client |
| 102 | switch len(opts) { |
| 103 | case 0: |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 104 | // Do nothing. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 105 | case 1: |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 106 | if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok { |
| 107 | client = clientOpt |
| 108 | } else { |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 109 | return nil, _gen_vdlutil.ErrUnrecognizedOption |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 110 | } |
| 111 | default: |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 112 | return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 113 | } |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 114 | stub := &clientStubApplication{defaultClient: client, name: name} |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 115 | stub.Application_ExcludingUniversal, _ = repository.BindApplication(name, client) |
| 116 | |
| 117 | return stub, nil |
| 118 | } |
| 119 | |
| 120 | // NewServerApplication creates a new server stub. |
| 121 | // |
| 122 | // It takes a regular server implementing the ApplicationService |
| 123 | // interface, and returns a new server stub. |
| 124 | func NewServerApplication(server ApplicationService) interface{} { |
| 125 | return &ServerStubApplication{ |
| 126 | ServerStubApplication: *repository.NewServerApplication(server).(*repository.ServerStubApplication), |
| 127 | service: server, |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // clientStubApplication implements Application. |
| 132 | type clientStubApplication struct { |
| 133 | repository.Application_ExcludingUniversal |
| 134 | |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 135 | defaultClient _gen_ipc.Client |
| 136 | name string |
| 137 | } |
| 138 | |
| 139 | func (__gen_c *clientStubApplication) client(ctx _gen_context.T) _gen_ipc.Client { |
| 140 | if __gen_c.defaultClient != nil { |
| 141 | return __gen_c.defaultClient |
| 142 | } |
| 143 | return _gen_veyron2.RuntimeFromContext(ctx).Client() |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | func (__gen_c *clientStubApplication) Put(ctx _gen_context.T, Profiles []string, Envelope application.Envelope, opts ..._gen_ipc.CallOpt) (err error) { |
| 147 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 148 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Put", []interface{}{Profiles, Envelope}, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 149 | return |
| 150 | } |
| 151 | if ierr := call.Finish(&err); ierr != nil { |
| 152 | err = ierr |
| 153 | } |
| 154 | return |
| 155 | } |
| 156 | |
| 157 | func (__gen_c *clientStubApplication) Remove(ctx _gen_context.T, Profile string, opts ..._gen_ipc.CallOpt) (err error) { |
| 158 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 159 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Remove", []interface{}{Profile}, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 160 | return |
| 161 | } |
| 162 | if ierr := call.Finish(&err); ierr != nil { |
| 163 | err = ierr |
| 164 | } |
| 165 | return |
| 166 | } |
| 167 | |
| 168 | func (__gen_c *clientStubApplication) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
| 169 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 170 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 171 | return |
| 172 | } |
| 173 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 174 | err = ierr |
| 175 | } |
| 176 | return |
| 177 | } |
| 178 | |
| 179 | func (__gen_c *clientStubApplication) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
| 180 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 181 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 182 | return |
| 183 | } |
| 184 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 185 | err = ierr |
| 186 | } |
| 187 | return |
| 188 | } |
| 189 | |
| 190 | func (__gen_c *clientStubApplication) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) { |
| 191 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 192 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 193 | return |
| 194 | } |
| 195 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 196 | err = ierr |
| 197 | } |
| 198 | return |
| 199 | } |
| 200 | |
| 201 | // ServerStubApplication wraps a server that implements |
| 202 | // ApplicationService and provides an object that satisfies |
| 203 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 204 | type ServerStubApplication struct { |
| 205 | repository.ServerStubApplication |
| 206 | |
| 207 | service ApplicationService |
| 208 | } |
| 209 | |
| 210 | func (__gen_s *ServerStubApplication) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 211 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 212 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 213 | // This will change when it is replaced with Signature(). |
| 214 | if resp, err := __gen_s.ServerStubApplication.GetMethodTags(call, method); resp != nil || err != nil { |
| 215 | return resp, err |
| 216 | } |
| 217 | switch method { |
| 218 | case "Put": |
Tilak Sharma | ab4f10d | 2014-07-23 11:28:37 -0700 | [diff] [blame] | 219 | return []interface{}{security.Label(4)}, nil |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 220 | case "Remove": |
Tilak Sharma | ab4f10d | 2014-07-23 11:28:37 -0700 | [diff] [blame] | 221 | return []interface{}{security.Label(4)}, nil |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 222 | default: |
| 223 | return nil, nil |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | func (__gen_s *ServerStubApplication) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| 228 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 229 | result.Methods["Put"] = _gen_ipc.MethodSignature{ |
| 230 | InArgs: []_gen_ipc.MethodArgument{ |
| 231 | {Name: "Profiles", Type: 61}, |
| 232 | {Name: "Envelope", Type: 65}, |
| 233 | }, |
| 234 | OutArgs: []_gen_ipc.MethodArgument{ |
| 235 | {Name: "", Type: 66}, |
| 236 | }, |
| 237 | } |
| 238 | result.Methods["Remove"] = _gen_ipc.MethodSignature{ |
| 239 | InArgs: []_gen_ipc.MethodArgument{ |
| 240 | {Name: "Profile", Type: 3}, |
| 241 | }, |
| 242 | OutArgs: []_gen_ipc.MethodArgument{ |
| 243 | {Name: "", Type: 66}, |
| 244 | }, |
| 245 | } |
| 246 | |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 247 | result.TypeDefs = []_gen_vdlutil.Any{ |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 248 | _gen_wiretype.StructType{ |
| 249 | []_gen_wiretype.FieldType{ |
Srdjan Petrovic | d9c222c | 2014-07-14 11:23:19 -0700 | [diff] [blame] | 250 | _gen_wiretype.FieldType{Type: 0x3, Name: "Title"}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 251 | _gen_wiretype.FieldType{Type: 0x3d, Name: "Args"}, |
| 252 | _gen_wiretype.FieldType{Type: 0x3, Name: "Binary"}, |
| 253 | _gen_wiretype.FieldType{Type: 0x3d, Name: "Env"}, |
| 254 | }, |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 255 | "veyron.io/veyron/veyron2/services/mgmt/application.Envelope", []string(nil)}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 256 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| 257 | var ss _gen_ipc.ServiceSignature |
| 258 | var firstAdded int |
| 259 | ss, _ = __gen_s.ServerStubApplication.Signature(call) |
| 260 | firstAdded = len(result.TypeDefs) |
| 261 | for k, v := range ss.Methods { |
| 262 | for i, _ := range v.InArgs { |
| 263 | if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| 264 | v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| 265 | } |
| 266 | } |
| 267 | for i, _ := range v.OutArgs { |
| 268 | if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| 269 | v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| 270 | } |
| 271 | } |
| 272 | if v.InStream >= _gen_wiretype.TypeIDFirst { |
| 273 | v.InStream += _gen_wiretype.TypeID(firstAdded) |
| 274 | } |
| 275 | if v.OutStream >= _gen_wiretype.TypeIDFirst { |
| 276 | v.OutStream += _gen_wiretype.TypeID(firstAdded) |
| 277 | } |
| 278 | result.Methods[k] = v |
| 279 | } |
| 280 | //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication. |
| 281 | for _, d := range ss.TypeDefs { |
| 282 | switch wt := d.(type) { |
| 283 | case _gen_wiretype.SliceType: |
| 284 | if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| 285 | wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| 286 | } |
| 287 | d = wt |
| 288 | case _gen_wiretype.ArrayType: |
| 289 | if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| 290 | wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| 291 | } |
| 292 | d = wt |
| 293 | case _gen_wiretype.MapType: |
| 294 | if wt.Key >= _gen_wiretype.TypeIDFirst { |
| 295 | wt.Key += _gen_wiretype.TypeID(firstAdded) |
| 296 | } |
| 297 | if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| 298 | wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| 299 | } |
| 300 | d = wt |
| 301 | case _gen_wiretype.StructType: |
| 302 | for i, fld := range wt.Fields { |
| 303 | if fld.Type >= _gen_wiretype.TypeIDFirst { |
| 304 | wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded) |
| 305 | } |
| 306 | } |
| 307 | d = wt |
| 308 | // NOTE: other types are missing, but we are upgrading anyways. |
| 309 | } |
| 310 | result.TypeDefs = append(result.TypeDefs, d) |
| 311 | } |
| 312 | |
| 313 | return result, nil |
| 314 | } |
| 315 | |
| 316 | func (__gen_s *ServerStubApplication) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 317 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
| 318 | return unresolver.UnresolveStep(call) |
| 319 | } |
| 320 | if call.Server() == nil { |
| 321 | return |
| 322 | } |
| 323 | var published []string |
| 324 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 325 | return |
| 326 | } |
| 327 | reply = make([]string, len(published)) |
| 328 | for i, p := range published { |
| 329 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 330 | } |
| 331 | return |
| 332 | } |
| 333 | |
| 334 | func (__gen_s *ServerStubApplication) Put(call _gen_ipc.ServerCall, Profiles []string, Envelope application.Envelope) (err error) { |
| 335 | err = __gen_s.service.Put(call, Profiles, Envelope) |
| 336 | return |
| 337 | } |
| 338 | |
| 339 | func (__gen_s *ServerStubApplication) Remove(call _gen_ipc.ServerCall, Profile string) (err error) { |
| 340 | err = __gen_s.service.Remove(call, Profile) |
| 341 | return |
| 342 | } |
| 343 | |
| 344 | // Profile describes a profile internally. Besides the public Profile |
| 345 | // interface, it allows to add and remove profile specifications. |
| 346 | // Profile is the interface the client binds and uses. |
| 347 | // Profile_ExcludingUniversal is the interface without internal framework-added methods |
| 348 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 349 | type Profile_ExcludingUniversal interface { |
| 350 | // Profile abstracts a device's ability to run binaries, and hides |
| 351 | // specifics such as the operating system, hardware architecture, and |
| 352 | // the set of installed libraries. Profiles describe binaries and |
| 353 | // devices, and are used to match them. |
| 354 | repository.Profile_ExcludingUniversal |
| 355 | // Specification returns the profile specification for the profile |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 356 | // identified through the object name suffix. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 357 | Specification(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply profile.Specification, err error) |
| 358 | // Put sets the profile specification for the profile identified |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 359 | // through the object name suffix. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 360 | Put(ctx _gen_context.T, Specification profile.Specification, opts ..._gen_ipc.CallOpt) (err error) |
| 361 | // Remove removes the profile specification for the profile |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 362 | // identified through the object name suffix. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 363 | Remove(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) |
| 364 | } |
| 365 | type Profile interface { |
| 366 | _gen_ipc.UniversalServiceMethods |
| 367 | Profile_ExcludingUniversal |
| 368 | } |
| 369 | |
| 370 | // ProfileService is the interface the server implements. |
| 371 | type ProfileService interface { |
| 372 | |
| 373 | // Profile abstracts a device's ability to run binaries, and hides |
| 374 | // specifics such as the operating system, hardware architecture, and |
| 375 | // the set of installed libraries. Profiles describe binaries and |
| 376 | // devices, and are used to match them. |
| 377 | repository.ProfileService |
| 378 | // Specification returns the profile specification for the profile |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 379 | // identified through the object name suffix. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 380 | Specification(context _gen_ipc.ServerContext) (reply profile.Specification, err error) |
| 381 | // Put sets the profile specification for the profile identified |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 382 | // through the object name suffix. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 383 | Put(context _gen_ipc.ServerContext, Specification profile.Specification) (err error) |
| 384 | // Remove removes the profile specification for the profile |
Bogdan Caprita | d9281a3 | 2014-07-02 14:40:39 -0700 | [diff] [blame] | 385 | // identified through the object name suffix. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 386 | Remove(context _gen_ipc.ServerContext) (err error) |
| 387 | } |
| 388 | |
| 389 | // BindProfile returns the client stub implementing the Profile |
| 390 | // interface. |
| 391 | // |
| 392 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 393 | // global Runtime is used. |
| 394 | func BindProfile(name string, opts ..._gen_ipc.BindOpt) (Profile, error) { |
| 395 | var client _gen_ipc.Client |
| 396 | switch len(opts) { |
| 397 | case 0: |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 398 | // Do nothing. |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 399 | case 1: |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 400 | if clientOpt, ok := opts[0].(_gen_ipc.Client); opts[0] == nil || ok { |
| 401 | client = clientOpt |
| 402 | } else { |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 403 | return nil, _gen_vdlutil.ErrUnrecognizedOption |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 404 | } |
| 405 | default: |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 406 | return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 407 | } |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 408 | stub := &clientStubProfile{defaultClient: client, name: name} |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 409 | stub.Profile_ExcludingUniversal, _ = repository.BindProfile(name, client) |
| 410 | |
| 411 | return stub, nil |
| 412 | } |
| 413 | |
| 414 | // NewServerProfile creates a new server stub. |
| 415 | // |
| 416 | // It takes a regular server implementing the ProfileService |
| 417 | // interface, and returns a new server stub. |
| 418 | func NewServerProfile(server ProfileService) interface{} { |
| 419 | return &ServerStubProfile{ |
| 420 | ServerStubProfile: *repository.NewServerProfile(server).(*repository.ServerStubProfile), |
| 421 | service: server, |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | // clientStubProfile implements Profile. |
| 426 | type clientStubProfile struct { |
| 427 | repository.Profile_ExcludingUniversal |
| 428 | |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 429 | defaultClient _gen_ipc.Client |
| 430 | name string |
| 431 | } |
| 432 | |
| 433 | func (__gen_c *clientStubProfile) client(ctx _gen_context.T) _gen_ipc.Client { |
| 434 | if __gen_c.defaultClient != nil { |
| 435 | return __gen_c.defaultClient |
| 436 | } |
| 437 | return _gen_veyron2.RuntimeFromContext(ctx).Client() |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | func (__gen_c *clientStubProfile) Specification(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply profile.Specification, err error) { |
| 441 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 442 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Specification", nil, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 443 | return |
| 444 | } |
| 445 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 446 | err = ierr |
| 447 | } |
| 448 | return |
| 449 | } |
| 450 | |
| 451 | func (__gen_c *clientStubProfile) Put(ctx _gen_context.T, Specification profile.Specification, opts ..._gen_ipc.CallOpt) (err error) { |
| 452 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 453 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Put", []interface{}{Specification}, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 454 | return |
| 455 | } |
| 456 | if ierr := call.Finish(&err); ierr != nil { |
| 457 | err = ierr |
| 458 | } |
| 459 | return |
| 460 | } |
| 461 | |
| 462 | func (__gen_c *clientStubProfile) Remove(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (err error) { |
| 463 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 464 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Remove", nil, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 465 | return |
| 466 | } |
| 467 | if ierr := call.Finish(&err); ierr != nil { |
| 468 | err = ierr |
| 469 | } |
| 470 | return |
| 471 | } |
| 472 | |
| 473 | func (__gen_c *clientStubProfile) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
| 474 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 475 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 476 | return |
| 477 | } |
| 478 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 479 | err = ierr |
| 480 | } |
| 481 | return |
| 482 | } |
| 483 | |
| 484 | func (__gen_c *clientStubProfile) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
| 485 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 486 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 487 | return |
| 488 | } |
| 489 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 490 | err = ierr |
| 491 | } |
| 492 | return |
| 493 | } |
| 494 | |
| 495 | func (__gen_c *clientStubProfile) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) { |
| 496 | var call _gen_ipc.Call |
Matt Rosencrantz | bf85d54 | 2014-08-22 13:31:14 -0700 | [diff] [blame] | 497 | if call, err = __gen_c.client(ctx).StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 498 | return |
| 499 | } |
| 500 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 501 | err = ierr |
| 502 | } |
| 503 | return |
| 504 | } |
| 505 | |
| 506 | // ServerStubProfile wraps a server that implements |
| 507 | // ProfileService and provides an object that satisfies |
| 508 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 509 | type ServerStubProfile struct { |
| 510 | repository.ServerStubProfile |
| 511 | |
| 512 | service ProfileService |
| 513 | } |
| 514 | |
| 515 | func (__gen_s *ServerStubProfile) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 516 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 517 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 518 | // This will change when it is replaced with Signature(). |
| 519 | if resp, err := __gen_s.ServerStubProfile.GetMethodTags(call, method); resp != nil || err != nil { |
| 520 | return resp, err |
| 521 | } |
| 522 | switch method { |
| 523 | case "Specification": |
Tilak Sharma | ab4f10d | 2014-07-23 11:28:37 -0700 | [diff] [blame] | 524 | return []interface{}{security.Label(2)}, nil |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 525 | case "Put": |
Tilak Sharma | ab4f10d | 2014-07-23 11:28:37 -0700 | [diff] [blame] | 526 | return []interface{}{security.Label(4)}, nil |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 527 | case "Remove": |
Tilak Sharma | ab4f10d | 2014-07-23 11:28:37 -0700 | [diff] [blame] | 528 | return []interface{}{security.Label(4)}, nil |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 529 | default: |
| 530 | return nil, nil |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | func (__gen_s *ServerStubProfile) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| 535 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 536 | result.Methods["Put"] = _gen_ipc.MethodSignature{ |
| 537 | InArgs: []_gen_ipc.MethodArgument{ |
Jiri Simsa | 2f8bc27 | 2014-07-16 12:29:15 -0700 | [diff] [blame] | 538 | {Name: "Specification", Type: 70}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 539 | }, |
| 540 | OutArgs: []_gen_ipc.MethodArgument{ |
Jiri Simsa | 2f8bc27 | 2014-07-16 12:29:15 -0700 | [diff] [blame] | 541 | {Name: "", Type: 71}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 542 | }, |
| 543 | } |
| 544 | result.Methods["Remove"] = _gen_ipc.MethodSignature{ |
| 545 | InArgs: []_gen_ipc.MethodArgument{}, |
| 546 | OutArgs: []_gen_ipc.MethodArgument{ |
Jiri Simsa | 2f8bc27 | 2014-07-16 12:29:15 -0700 | [diff] [blame] | 547 | {Name: "", Type: 71}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 548 | }, |
| 549 | } |
| 550 | result.Methods["Specification"] = _gen_ipc.MethodSignature{ |
| 551 | InArgs: []_gen_ipc.MethodArgument{}, |
| 552 | OutArgs: []_gen_ipc.MethodArgument{ |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 553 | {Name: "", Type: 70}, |
Jiri Simsa | 2f8bc27 | 2014-07-16 12:29:15 -0700 | [diff] [blame] | 554 | {Name: "", Type: 71}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 555 | }, |
| 556 | } |
| 557 | |
Todd Wang | 0ecdd7a | 2014-07-14 16:24:38 -0700 | [diff] [blame] | 558 | result.TypeDefs = []_gen_vdlutil.Any{ |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 559 | _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{ |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 560 | []_gen_wiretype.FieldType{ |
| 561 | _gen_wiretype.FieldType{Type: 0x3, Name: "Name"}, |
| 562 | _gen_wiretype.FieldType{Type: 0x3, Name: "MajorVersion"}, |
| 563 | _gen_wiretype.FieldType{Type: 0x3, Name: "MinorVersion"}, |
| 564 | }, |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 565 | "veyron.io/veyron/veyron/services/mgmt/profile.Library", []string(nil)}, |
| 566 | _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{ |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 567 | []_gen_wiretype.FieldType{ |
Jiri Simsa | 2f8bc27 | 2014-07-16 12:29:15 -0700 | [diff] [blame] | 568 | _gen_wiretype.FieldType{Type: 0x41, Name: "Arch"}, |
| 569 | _gen_wiretype.FieldType{Type: 0x3, Name: "Description"}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 570 | _gen_wiretype.FieldType{Type: 0x42, Name: "Format"}, |
| 571 | _gen_wiretype.FieldType{Type: 0x44, Name: "Libraries"}, |
| 572 | _gen_wiretype.FieldType{Type: 0x3, Name: "Label"}, |
Jiri Simsa | 2f8bc27 | 2014-07-16 12:29:15 -0700 | [diff] [blame] | 573 | _gen_wiretype.FieldType{Type: 0x45, Name: "OS"}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 574 | }, |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 575 | "veyron.io/veyron/veyron/services/mgmt/profile.Specification", []string(nil)}, |
Jiri Simsa | ddbfebb | 2014-06-20 15:56:06 -0700 | [diff] [blame] | 576 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| 577 | var ss _gen_ipc.ServiceSignature |
| 578 | var firstAdded int |
| 579 | ss, _ = __gen_s.ServerStubProfile.Signature(call) |
| 580 | firstAdded = len(result.TypeDefs) |
| 581 | for k, v := range ss.Methods { |
| 582 | for i, _ := range v.InArgs { |
| 583 | if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| 584 | v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| 585 | } |
| 586 | } |
| 587 | for i, _ := range v.OutArgs { |
| 588 | if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst { |
| 589 | v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded) |
| 590 | } |
| 591 | } |
| 592 | if v.InStream >= _gen_wiretype.TypeIDFirst { |
| 593 | v.InStream += _gen_wiretype.TypeID(firstAdded) |
| 594 | } |
| 595 | if v.OutStream >= _gen_wiretype.TypeIDFirst { |
| 596 | v.OutStream += _gen_wiretype.TypeID(firstAdded) |
| 597 | } |
| 598 | result.Methods[k] = v |
| 599 | } |
| 600 | //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication. |
| 601 | for _, d := range ss.TypeDefs { |
| 602 | switch wt := d.(type) { |
| 603 | case _gen_wiretype.SliceType: |
| 604 | if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| 605 | wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| 606 | } |
| 607 | d = wt |
| 608 | case _gen_wiretype.ArrayType: |
| 609 | if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| 610 | wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| 611 | } |
| 612 | d = wt |
| 613 | case _gen_wiretype.MapType: |
| 614 | if wt.Key >= _gen_wiretype.TypeIDFirst { |
| 615 | wt.Key += _gen_wiretype.TypeID(firstAdded) |
| 616 | } |
| 617 | if wt.Elem >= _gen_wiretype.TypeIDFirst { |
| 618 | wt.Elem += _gen_wiretype.TypeID(firstAdded) |
| 619 | } |
| 620 | d = wt |
| 621 | case _gen_wiretype.StructType: |
| 622 | for i, fld := range wt.Fields { |
| 623 | if fld.Type >= _gen_wiretype.TypeIDFirst { |
| 624 | wt.Fields[i].Type += _gen_wiretype.TypeID(firstAdded) |
| 625 | } |
| 626 | } |
| 627 | d = wt |
| 628 | // NOTE: other types are missing, but we are upgrading anyways. |
| 629 | } |
| 630 | result.TypeDefs = append(result.TypeDefs, d) |
| 631 | } |
| 632 | |
| 633 | return result, nil |
| 634 | } |
| 635 | |
| 636 | func (__gen_s *ServerStubProfile) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 637 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
| 638 | return unresolver.UnresolveStep(call) |
| 639 | } |
| 640 | if call.Server() == nil { |
| 641 | return |
| 642 | } |
| 643 | var published []string |
| 644 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 645 | return |
| 646 | } |
| 647 | reply = make([]string, len(published)) |
| 648 | for i, p := range published { |
| 649 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 650 | } |
| 651 | return |
| 652 | } |
| 653 | |
| 654 | func (__gen_s *ServerStubProfile) Specification(call _gen_ipc.ServerCall) (reply profile.Specification, err error) { |
| 655 | reply, err = __gen_s.service.Specification(call) |
| 656 | return |
| 657 | } |
| 658 | |
| 659 | func (__gen_s *ServerStubProfile) Put(call _gen_ipc.ServerCall, Specification profile.Specification) (err error) { |
| 660 | err = __gen_s.service.Put(call, Specification) |
| 661 | return |
| 662 | } |
| 663 | |
| 664 | func (__gen_s *ServerStubProfile) Remove(call _gen_ipc.ServerCall) (err error) { |
| 665 | err = __gen_s.service.Remove(call) |
| 666 | return |
| 667 | } |