Jason Campbell | 3ab1aa4 | 2015-05-18 14:01:48 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Vanadium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // This file was auto-generated by the vanadium vdl tool. |
| 6 | // Source: fortune.vdl |
| 7 | |
| 8 | // Package fortune defines the Fortune example interface. |
| 9 | package fortune |
| 10 | |
| 11 | import ( |
| 12 | // VDL system imports |
| 13 | "v.io/v23" |
| 14 | "v.io/v23/context" |
| 15 | "v.io/v23/rpc" |
| 16 | ) |
| 17 | |
| 18 | // FortuneClientMethods is the client interface |
| 19 | // containing Fortune methods. |
| 20 | // |
| 21 | // Fortune is the interface to a fortune-telling service. |
| 22 | type FortuneClientMethods interface { |
| 23 | // Returns a random fortune. |
| 24 | Get(*context.T, ...rpc.CallOpt) (fortune string, err error) |
| 25 | // Adds a fortune to the set used by Get(). |
| 26 | Add(ctx *context.T, fortune string, opts ...rpc.CallOpt) error |
| 27 | // Returns whether or not a fortune exists. |
| 28 | Has(ctx *context.T, fortune string, opts ...rpc.CallOpt) (bool, error) |
| 29 | } |
| 30 | |
| 31 | // FortuneClientStub adds universal methods to FortuneClientMethods. |
| 32 | type FortuneClientStub interface { |
| 33 | FortuneClientMethods |
| 34 | rpc.UniversalServiceMethods |
| 35 | } |
| 36 | |
| 37 | // FortuneClient returns a client stub for Fortune. |
| 38 | func FortuneClient(name string) FortuneClientStub { |
| 39 | return implFortuneClientStub{name} |
| 40 | } |
| 41 | |
| 42 | type implFortuneClientStub struct { |
| 43 | name string |
| 44 | } |
| 45 | |
| 46 | func (c implFortuneClientStub) Get(ctx *context.T, opts ...rpc.CallOpt) (o0 string, err error) { |
| 47 | err = v23.GetClient(ctx).Call(ctx, c.name, "Get", nil, []interface{}{&o0}, opts...) |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | func (c implFortuneClientStub) Add(ctx *context.T, i0 string, opts ...rpc.CallOpt) (err error) { |
| 52 | err = v23.GetClient(ctx).Call(ctx, c.name, "Add", []interface{}{i0}, nil, opts...) |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | func (c implFortuneClientStub) Has(ctx *context.T, i0 string, opts ...rpc.CallOpt) (o0 bool, err error) { |
| 57 | err = v23.GetClient(ctx).Call(ctx, c.name, "Has", []interface{}{i0}, []interface{}{&o0}, opts...) |
| 58 | return |
| 59 | } |
| 60 | |
| 61 | // FortuneServerMethods is the interface a server writer |
| 62 | // implements for Fortune. |
| 63 | // |
| 64 | // Fortune is the interface to a fortune-telling service. |
| 65 | type FortuneServerMethods interface { |
| 66 | // Returns a random fortune. |
| 67 | Get(*context.T, rpc.ServerCall) (fortune string, err error) |
| 68 | // Adds a fortune to the set used by Get(). |
| 69 | Add(ctx *context.T, call rpc.ServerCall, fortune string) error |
| 70 | // Returns whether or not a fortune exists. |
| 71 | Has(ctx *context.T, call rpc.ServerCall, fortune string) (bool, error) |
| 72 | } |
| 73 | |
| 74 | // FortuneServerStubMethods is the server interface containing |
| 75 | // Fortune methods, as expected by rpc.Server. |
| 76 | // There is no difference between this interface and FortuneServerMethods |
| 77 | // since there are no streaming methods. |
| 78 | type FortuneServerStubMethods FortuneServerMethods |
| 79 | |
| 80 | // FortuneServerStub adds universal methods to FortuneServerStubMethods. |
| 81 | type FortuneServerStub interface { |
| 82 | FortuneServerStubMethods |
| 83 | // Describe the Fortune interfaces. |
| 84 | Describe__() []rpc.InterfaceDesc |
| 85 | } |
| 86 | |
| 87 | // FortuneServer returns a server stub for Fortune. |
| 88 | // It converts an implementation of FortuneServerMethods into |
| 89 | // an object that may be used by rpc.Server. |
| 90 | func FortuneServer(impl FortuneServerMethods) FortuneServerStub { |
| 91 | stub := implFortuneServerStub{ |
| 92 | impl: impl, |
| 93 | } |
| 94 | // Initialize GlobState; always check the stub itself first, to handle the |
| 95 | // case where the user has the Glob method defined in their VDL source. |
| 96 | if gs := rpc.NewGlobState(stub); gs != nil { |
| 97 | stub.gs = gs |
| 98 | } else if gs := rpc.NewGlobState(impl); gs != nil { |
| 99 | stub.gs = gs |
| 100 | } |
| 101 | return stub |
| 102 | } |
| 103 | |
| 104 | type implFortuneServerStub struct { |
| 105 | impl FortuneServerMethods |
| 106 | gs *rpc.GlobState |
| 107 | } |
| 108 | |
| 109 | func (s implFortuneServerStub) Get(ctx *context.T, call rpc.ServerCall) (string, error) { |
| 110 | return s.impl.Get(ctx, call) |
| 111 | } |
| 112 | |
| 113 | func (s implFortuneServerStub) Add(ctx *context.T, call rpc.ServerCall, i0 string) error { |
| 114 | return s.impl.Add(ctx, call, i0) |
| 115 | } |
| 116 | |
| 117 | func (s implFortuneServerStub) Has(ctx *context.T, call rpc.ServerCall, i0 string) (bool, error) { |
| 118 | return s.impl.Has(ctx, call, i0) |
| 119 | } |
| 120 | |
| 121 | func (s implFortuneServerStub) Globber() *rpc.GlobState { |
| 122 | return s.gs |
| 123 | } |
| 124 | |
| 125 | func (s implFortuneServerStub) Describe__() []rpc.InterfaceDesc { |
| 126 | return []rpc.InterfaceDesc{FortuneDesc} |
| 127 | } |
| 128 | |
| 129 | // FortuneDesc describes the Fortune interface. |
| 130 | var FortuneDesc rpc.InterfaceDesc = descFortune |
| 131 | |
| 132 | // descFortune hides the desc to keep godoc clean. |
| 133 | var descFortune = rpc.InterfaceDesc{ |
| 134 | Name: "Fortune", |
| 135 | PkgPath: "v.io/x/ref/examples/fortune", |
| 136 | Doc: "// Fortune is the interface to a fortune-telling service.", |
| 137 | Methods: []rpc.MethodDesc{ |
| 138 | { |
| 139 | Name: "Get", |
| 140 | Doc: "// Returns a random fortune.", |
| 141 | OutArgs: []rpc.ArgDesc{ |
| 142 | {"fortune", ``}, // string |
| 143 | }, |
| 144 | }, |
| 145 | { |
| 146 | Name: "Add", |
| 147 | Doc: "// Adds a fortune to the set used by Get().", |
| 148 | InArgs: []rpc.ArgDesc{ |
| 149 | {"fortune", ``}, // string |
| 150 | }, |
| 151 | }, |
| 152 | { |
| 153 | Name: "Has", |
| 154 | Doc: "// Returns whether or not a fortune exists.", |
| 155 | InArgs: []rpc.ArgDesc{ |
| 156 | {"fortune", ``}, // string |
| 157 | }, |
| 158 | OutArgs: []rpc.ArgDesc{ |
| 159 | {"", ``}, // bool |
| 160 | }, |
| 161 | }, |
| 162 | }, |
| 163 | } |