Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
Tilak Sharma | 43395f3 | 2014-05-27 11:33:38 -0700 | [diff] [blame] | 2 | // Source: root.vdl |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 3 | |
| 4 | // Package root contains root process implementation and internal |
| 5 | // interfaces and types used by the implementation. |
| 6 | package root |
| 7 | |
| 8 | import ( |
| 9 | // The non-user imports are prefixed with "_gen_" to prevent collisions. |
Cosmos Nicolaou | b07fa77 | 2014-05-16 08:07:02 -0700 | [diff] [blame] | 10 | _gen_veyron2 "veyron2" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 11 | _gen_ipc "veyron2/ipc" |
| 12 | _gen_naming "veyron2/naming" |
Cosmos Nicolaou | ae67894 | 2014-05-17 17:21:43 -0700 | [diff] [blame] | 13 | _gen_rt "veyron2/rt" |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 14 | _gen_vdl "veyron2/vdl" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 15 | _gen_wiretype "veyron2/wiretype" |
| 16 | ) |
| 17 | |
| 18 | // Root is an interface to be implemented by a process with root level |
| 19 | // privileges. |
| 20 | // Root is the interface the client binds and uses. |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 21 | // Root_ExcludingUniversal is the interface without internal framework-added methods |
| 22 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 23 | type Root_ExcludingUniversal interface { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 24 | // Reset waits for the given deadline (in milliseconds) and then |
| 25 | // restars the host node machine. |
| 26 | Reset(Deadline uint64, opts ..._gen_ipc.ClientCallOpt) (err error) |
| 27 | } |
| 28 | type Root interface { |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 29 | _gen_ipc.UniversalServiceMethods |
| 30 | Root_ExcludingUniversal |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | // RootService is the interface the server implements. |
| 34 | type RootService interface { |
| 35 | |
| 36 | // Reset waits for the given deadline (in milliseconds) and then |
| 37 | // restars the host node machine. |
| 38 | Reset(context _gen_ipc.Context, Deadline uint64) (err error) |
| 39 | } |
| 40 | |
| 41 | // BindRoot returns the client stub implementing the Root |
| 42 | // interface. |
| 43 | // |
| 44 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 45 | // global Runtime is used. |
| 46 | func BindRoot(name string, opts ..._gen_ipc.BindOpt) (Root, error) { |
| 47 | var client _gen_ipc.Client |
| 48 | switch len(opts) { |
| 49 | case 0: |
| 50 | client = _gen_rt.R().Client() |
| 51 | case 1: |
| 52 | switch o := opts[0].(type) { |
Cosmos Nicolaou | b07fa77 | 2014-05-16 08:07:02 -0700 | [diff] [blame] | 53 | case _gen_veyron2.Runtime: |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 54 | client = o.Client() |
| 55 | case _gen_ipc.Client: |
| 56 | client = o |
| 57 | default: |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 58 | return nil, _gen_vdl.ErrUnrecognizedOption |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 59 | } |
| 60 | default: |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 61 | return nil, _gen_vdl.ErrTooManyOptionsToBind |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 62 | } |
| 63 | stub := &clientStubRoot{client: client, name: name} |
| 64 | |
| 65 | return stub, nil |
| 66 | } |
| 67 | |
| 68 | // NewServerRoot creates a new server stub. |
| 69 | // |
| 70 | // It takes a regular server implementing the RootService |
| 71 | // interface, and returns a new server stub. |
| 72 | func NewServerRoot(server RootService) interface{} { |
| 73 | return &ServerStubRoot{ |
| 74 | service: server, |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // clientStubRoot implements Root. |
| 79 | type clientStubRoot struct { |
| 80 | client _gen_ipc.Client |
| 81 | name string |
| 82 | } |
| 83 | |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 84 | func (__gen_c *clientStubRoot) Reset(Deadline uint64, opts ..._gen_ipc.ClientCallOpt) (err error) { |
| 85 | var call _gen_ipc.ClientCall |
| 86 | if call, err = __gen_c.client.StartCall(__gen_c.name, "Reset", []interface{}{Deadline}, opts...); err != nil { |
| 87 | return |
| 88 | } |
| 89 | if ierr := call.Finish(&err); ierr != nil { |
| 90 | err = ierr |
| 91 | } |
| 92 | return |
| 93 | } |
| 94 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 95 | func (__gen_c *clientStubRoot) UnresolveStep(opts ..._gen_ipc.ClientCallOpt) (reply []string, err error) { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 96 | var call _gen_ipc.ClientCall |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 97 | if call, err = __gen_c.client.StartCall(__gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
| 98 | return |
| 99 | } |
| 100 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 101 | err = ierr |
| 102 | } |
| 103 | return |
| 104 | } |
| 105 | |
| 106 | func (__gen_c *clientStubRoot) Signature(opts ..._gen_ipc.ClientCallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
| 107 | var call _gen_ipc.ClientCall |
| 108 | if call, err = __gen_c.client.StartCall(__gen_c.name, "Signature", nil, opts...); err != nil { |
| 109 | return |
| 110 | } |
| 111 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 112 | err = ierr |
| 113 | } |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | func (__gen_c *clientStubRoot) GetMethodTags(method string, opts ..._gen_ipc.ClientCallOpt) (reply []interface{}, err error) { |
| 118 | var call _gen_ipc.ClientCall |
| 119 | if call, err = __gen_c.client.StartCall(__gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 120 | return |
| 121 | } |
| 122 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 123 | err = ierr |
| 124 | } |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | // ServerStubRoot wraps a server that implements |
| 129 | // RootService and provides an object that satisfies |
| 130 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 131 | type ServerStubRoot struct { |
| 132 | service RootService |
| 133 | } |
| 134 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 135 | func (__gen_s *ServerStubRoot) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 136 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 137 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 138 | // This will change when it is replaced with Signature(). |
| 139 | switch method { |
| 140 | case "Reset": |
| 141 | return []interface{}{}, nil |
| 142 | default: |
| 143 | return nil, nil |
| 144 | } |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 147 | func (__gen_s *ServerStubRoot) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 148 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 149 | result.Methods["Reset"] = _gen_ipc.MethodSignature{ |
| 150 | InArgs: []_gen_ipc.MethodArgument{ |
| 151 | {Name: "Deadline", Type: 53}, |
| 152 | }, |
| 153 | OutArgs: []_gen_ipc.MethodArgument{ |
| 154 | {Name: "", Type: 65}, |
| 155 | }, |
| 156 | } |
| 157 | |
Todd Wang | e5d67b4 | 2014-05-27 10:48:07 -0700 | [diff] [blame] | 158 | result.TypeDefs = []_gen_vdl.Any{ |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 159 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| 160 | |
| 161 | return result, nil |
| 162 | } |
| 163 | |
Benjamin Prosnitz | dcddb93 | 2014-05-27 15:55:58 -0700 | [diff] [blame^] | 164 | func (__gen_s *ServerStubRoot) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 165 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 166 | return unresolver.UnresolveStep(call) |
| 167 | } |
| 168 | if call.Server() == nil { |
| 169 | return |
| 170 | } |
| 171 | var published []string |
| 172 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 173 | return |
| 174 | } |
| 175 | reply = make([]string, len(published)) |
| 176 | for i, p := range published { |
| 177 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 178 | } |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | func (__gen_s *ServerStubRoot) Reset(call _gen_ipc.ServerCall, Deadline uint64) (err error) { |
| 183 | err = __gen_s.service.Reset(call, Deadline) |
| 184 | return |
| 185 | } |