blob: d8a6d446394530837aa7e05e854c5d090f618197 [file] [log] [blame]
Jason Campbell3ab1aa42015-05-18 14:01:48 -07001// 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.
9package fortune
10
11import (
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.
22type 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.
32type FortuneClientStub interface {
33 FortuneClientMethods
34 rpc.UniversalServiceMethods
35}
36
37// FortuneClient returns a client stub for Fortune.
38func FortuneClient(name string) FortuneClientStub {
39 return implFortuneClientStub{name}
40}
41
42type implFortuneClientStub struct {
43 name string
44}
45
46func (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
51func (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
56func (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.
65type 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.
78type FortuneServerStubMethods FortuneServerMethods
79
80// FortuneServerStub adds universal methods to FortuneServerStubMethods.
81type 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.
90func 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
104type implFortuneServerStub struct {
105 impl FortuneServerMethods
106 gs *rpc.GlobState
107}
108
109func (s implFortuneServerStub) Get(ctx *context.T, call rpc.ServerCall) (string, error) {
110 return s.impl.Get(ctx, call)
111}
112
113func (s implFortuneServerStub) Add(ctx *context.T, call rpc.ServerCall, i0 string) error {
114 return s.impl.Add(ctx, call, i0)
115}
116
117func (s implFortuneServerStub) Has(ctx *context.T, call rpc.ServerCall, i0 string) (bool, error) {
118 return s.impl.Has(ctx, call, i0)
119}
120
121func (s implFortuneServerStub) Globber() *rpc.GlobState {
122 return s.gs
123}
124
125func (s implFortuneServerStub) Describe__() []rpc.InterfaceDesc {
126 return []rpc.InterfaceDesc{FortuneDesc}
127}
128
129// FortuneDesc describes the Fortune interface.
130var FortuneDesc rpc.InterfaceDesc = descFortune
131
132// descFortune hides the desc to keep godoc clean.
133var 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}