blob: 92ed7fbc22bd5d5cbebc68223f8a01f4ce464085 [file] [log] [blame]
// This file was auto-generated by the veyron vdl tool.
// Source: vdl.vdl
// Package test provides a VDL specification for a service used in the unittest of the acl package.
package test
import (
// The non-user imports are prefixed with "__" to prevent collisions.
__veyron2 "veyron.io/veyron/veyron2"
__context "veyron.io/veyron/veyron2/context"
__ipc "veyron.io/veyron/veyron2/ipc"
__vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
__wiretype "veyron.io/veyron/veyron2/wiretype"
)
// TODO(toddw): Remove this line once the new signature support is done.
// It corrects a bug where __wiretype is unused in VDL pacakges where only
// bootstrap types are used on interfaces.
const _ = __wiretype.TypeIDInvalid
// Any package can define tags (of arbitrary types) to be attached to methods.
// This type can be used to index into a TaggedACLMap.
type MyTag string
// For this example/unittest, there are three possible values of MyTag,
// each represented by a single-character string.
const Read = MyTag("R")
const Write = MyTag("W")
const Execute = MyTag("X")
// MyObjectClientMethods is the client interface
// containing MyObject methods.
//
// MyObject demonstrates how tags are attached to methods.
type MyObjectClientMethods interface {
Get(__context.T, ...__ipc.CallOpt) error
Put(__context.T, ...__ipc.CallOpt) error
Resolve(__context.T, ...__ipc.CallOpt) error
NoTags(__context.T, ...__ipc.CallOpt) error // No tags attached to this.
AllTags(__context.T, ...__ipc.CallOpt) error
}
// MyObjectClientStub adds universal methods to MyObjectClientMethods.
type MyObjectClientStub interface {
MyObjectClientMethods
__ipc.UniversalServiceMethods
}
// MyObjectClient returns a client stub for MyObject.
func MyObjectClient(name string, opts ...__ipc.BindOpt) MyObjectClientStub {
var client __ipc.Client
for _, opt := range opts {
if clientOpt, ok := opt.(__ipc.Client); ok {
client = clientOpt
}
}
return implMyObjectClientStub{name, client}
}
type implMyObjectClientStub struct {
name string
client __ipc.Client
}
func (c implMyObjectClientStub) c(ctx __context.T) __ipc.Client {
if c.client != nil {
return c.client
}
return __veyron2.RuntimeFromContext(ctx).Client()
}
func (c implMyObjectClientStub) Get(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "Get", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
err = ierr
}
return
}
func (c implMyObjectClientStub) Put(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "Put", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
err = ierr
}
return
}
func (c implMyObjectClientStub) Resolve(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "Resolve", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
err = ierr
}
return
}
func (c implMyObjectClientStub) NoTags(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "NoTags", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
err = ierr
}
return
}
func (c implMyObjectClientStub) AllTags(ctx __context.T, opts ...__ipc.CallOpt) (err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "AllTags", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
err = ierr
}
return
}
func (c implMyObjectClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
func (c implMyObjectClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) {
var call __ipc.Call
if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil {
return
}
if ierr := call.Finish(&o0, &err); ierr != nil {
err = ierr
}
return
}
// MyObjectServerMethods is the interface a server writer
// implements for MyObject.
//
// MyObject demonstrates how tags are attached to methods.
type MyObjectServerMethods interface {
Get(__ipc.ServerContext) error
Put(__ipc.ServerContext) error
Resolve(__ipc.ServerContext) error
NoTags(__ipc.ServerContext) error // No tags attached to this.
AllTags(__ipc.ServerContext) error
}
// MyObjectServerStubMethods is the server interface containing
// MyObject methods, as expected by ipc.Server. The difference between
// this interface and MyObjectServerMethods is that the first context
// argument for each method is always ipc.ServerCall here, while it is either
// ipc.ServerContext or a typed streaming context there.
type MyObjectServerStubMethods interface {
Get(__ipc.ServerCall) error
Put(__ipc.ServerCall) error
Resolve(__ipc.ServerCall) error
NoTags(__ipc.ServerCall) error // No tags attached to this.
AllTags(__ipc.ServerCall) error
}
// MyObjectServerStub adds universal methods to MyObjectServerStubMethods.
type MyObjectServerStub interface {
MyObjectServerStubMethods
// GetMethodTags will be replaced with DescribeInterfaces.
GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error)
// Signature will be replaced with DescribeInterfaces.
Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error)
}
// MyObjectServer returns a server stub for MyObject.
// It converts an implementation of MyObjectServerMethods into
// an object that may be used by ipc.Server.
func MyObjectServer(impl MyObjectServerMethods) MyObjectServerStub {
stub := implMyObjectServerStub{
impl: impl,
}
// Initialize GlobState; always check the stub itself first, to handle the
// case where the user has the Glob method defined in their VDL source.
if gs := __ipc.NewGlobState(stub); gs != nil {
stub.gs = gs
} else if gs := __ipc.NewGlobState(impl); gs != nil {
stub.gs = gs
}
return stub
}
type implMyObjectServerStub struct {
impl MyObjectServerMethods
gs *__ipc.GlobState
}
func (s implMyObjectServerStub) Get(call __ipc.ServerCall) error {
return s.impl.Get(call)
}
func (s implMyObjectServerStub) Put(call __ipc.ServerCall) error {
return s.impl.Put(call)
}
func (s implMyObjectServerStub) Resolve(call __ipc.ServerCall) error {
return s.impl.Resolve(call)
}
func (s implMyObjectServerStub) NoTags(call __ipc.ServerCall) error {
return s.impl.NoTags(call)
}
func (s implMyObjectServerStub) AllTags(call __ipc.ServerCall) error {
return s.impl.AllTags(call)
}
func (s implMyObjectServerStub) VGlob() *__ipc.GlobState {
return s.gs
}
func (s implMyObjectServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) {
// TODO(toddw): Replace with new DescribeInterfaces implementation.
switch method {
case "Get":
return []interface{}{MyTag("R")}, nil
case "Put":
return []interface{}{MyTag("W")}, nil
case "Resolve":
return []interface{}{MyTag("X")}, nil
case "NoTags":
return []interface{}{}, nil
case "AllTags":
return []interface{}{MyTag("R"), MyTag("W"), MyTag("X")}, nil
default:
return nil, nil
}
}
func (s implMyObjectServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) {
// TODO(toddw) Replace with new DescribeInterfaces implementation.
result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
result.Methods["AllTags"] = __ipc.MethodSignature{
InArgs: []__ipc.MethodArgument{},
OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
result.Methods["Get"] = __ipc.MethodSignature{
InArgs: []__ipc.MethodArgument{},
OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
result.Methods["NoTags"] = __ipc.MethodSignature{
InArgs: []__ipc.MethodArgument{},
OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
result.Methods["Put"] = __ipc.MethodSignature{
InArgs: []__ipc.MethodArgument{},
OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
result.Methods["Resolve"] = __ipc.MethodSignature{
InArgs: []__ipc.MethodArgument{},
OutArgs: []__ipc.MethodArgument{
{Name: "", Type: 65},
},
}
result.TypeDefs = []__vdlutil.Any{
__wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
return result, nil
}