blob: 65339b03dd50dded6968febc4976a6036a5e0945 [file] [log] [blame]
// This file was auto-generated by the veyron idl tool.
// Source: service.idl
/*
Package estore defines an extended interface for the Veyron store.
The extended interface supports synchronizing with remote stores by transporting Mutations.
*/
package estore
import (
"veyron2/services/store"
"veyron2/storage"
// The non-user imports are prefixed with "_gen_" to prevent collisions.
_gen_veyron2 "veyron2"
_gen_idl "veyron2/idl"
_gen_ipc "veyron2/ipc"
_gen_naming "veyron2/naming"
_gen_rt "veyron2/rt"
_gen_wiretype "veyron2/wiretype"
)
// Mutation represents an update to an entry in the store, and contains enough
// information for a privileged service to replicate the update elsewhere.
type Mutation struct {
// ID is the key that identifies the entry.
ID storage.ID
// The version of the entry immediately before the update. For new entries,
// the PriorVersion is NoVersion.
PriorVersion storage.Version
// The version of the entry immediately after the update. For deleted entries,
// the Version is NoVersion.
Version storage.Version
// IsRoot is true if
// 1) The entry was the store root immediately before being deleted, or
// 2) The entry is the store root immediately after the update.
IsRoot bool
// Value is value stored at this entry.
Value _gen_idl.AnyData
// Tags specify permissions on this entry.
Tags storage.TagList
// Dir is the implicit directory of this entry, and may contain references
// to other entries in the store.
Dir []storage.DEntry
}
// Store defines an extended interface for the Veyron store. Mutations can be
// received via the Watcher interface, and committed via PutMutations().
// Store is the interface the client binds and uses.
// Store_InternalNoTagGetter is the interface without the TagGetter
// and UnresolveStep methods (both framework-added, rathern than user-defined),
// to enable embedding without method collisions. Not to be used directly by
// clients.
type Store_InternalNoTagGetter interface {
store.Store_InternalNoTagGetter
// PutMutations puts external mutations in the store, within a transaction.
PutMutations(Mutations []Mutation, opts ..._gen_ipc.ClientCallOpt) (err error)
}
type Store interface {
_gen_idl.TagGetter
// UnresolveStep returns the names for the remote service, rooted at the
// service's immediate namespace ancestor.
UnresolveStep(opts ..._gen_ipc.ClientCallOpt) ([]string, error)
Store_InternalNoTagGetter
}
// StoreService is the interface the server implements.
type StoreService interface {
store.StoreService
// PutMutations puts external mutations in the store, within a transaction.
PutMutations(context _gen_ipc.Context, Mutations []Mutation) (err error)
}
// BindStore returns the client stub implementing the Store
// interface.
//
// If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the
// global Runtime is used.
func BindStore(name string, opts ..._gen_ipc.BindOpt) (Store, error) {
var client _gen_ipc.Client
switch len(opts) {
case 0:
client = _gen_rt.R().Client()
case 1:
switch o := opts[0].(type) {
case _gen_veyron2.Runtime:
client = o.Client()
case _gen_ipc.Client:
client = o
default:
return nil, _gen_idl.ErrUnrecognizedOption
}
default:
return nil, _gen_idl.ErrTooManyOptionsToBind
}
stub := &clientStubStore{client: client, name: name}
stub.Store_InternalNoTagGetter, _ = store.BindStore(name, client)
return stub, nil
}
// NewServerStore creates a new server stub.
//
// It takes a regular server implementing the StoreService
// interface, and returns a new server stub.
func NewServerStore(server StoreService) interface{} {
return &ServerStubStore{
ServerStubStore: *store.NewServerStore(server).(*store.ServerStubStore),
service: server,
}
}
// clientStubStore implements Store.
type clientStubStore struct {
store.Store_InternalNoTagGetter
client _gen_ipc.Client
name string
}
func (c *clientStubStore) GetMethodTags(method string) []interface{} {
return GetStoreMethodTags(method)
}
func (__gen_c *clientStubStore) PutMutations(Mutations []Mutation, opts ..._gen_ipc.ClientCallOpt) (err error) {
var call _gen_ipc.ClientCall
if call, err = __gen_c.client.StartCall(__gen_c.name, "PutMutations", []interface{}{Mutations}, opts...); err != nil {
return
}
if ierr := call.Finish(&err); ierr != nil {
err = ierr
}
return
}
func (c *clientStubStore) UnresolveStep(opts ..._gen_ipc.ClientCallOpt) (reply []string, err error) {
var call _gen_ipc.ClientCall
if call, err = c.client.StartCall(c.name, "UnresolveStep", nil, opts...); err != nil {
return
}
if ierr := call.Finish(&reply, &err); ierr != nil {
err = ierr
}
return
}
// ServerStubStore wraps a server that implements
// StoreService and provides an object that satisfies
// the requirements of veyron2/ipc.ReflectInvoker.
type ServerStubStore struct {
store.ServerStubStore
service StoreService
}
func (s *ServerStubStore) GetMethodTags(method string) []interface{} {
return GetStoreMethodTags(method)
}
func (s *ServerStubStore) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) {
result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)}
result.Methods["PutMutations"] = _gen_ipc.MethodSignature{
InArgs: []_gen_ipc.MethodArgument{
{Name: "Mutations", Type: 76},
},
OutArgs: []_gen_ipc.MethodArgument{
{Name: "Err", Type: 77},
},
}
result.TypeDefs = []_gen_idl.AnyData{
_gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, _gen_wiretype.ArrayType{Elem: 0x41, Len: 0x10, Name: "storage.ID", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x35, Name: "storage.Version", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x32, Name: "TagOp", Tags: []string(nil)}, _gen_wiretype.ArrayType{Elem: 0x41, Len: 0x10, Name: "ID", Tags: []string(nil)}, _gen_wiretype.StructType{
[]_gen_wiretype.FieldType{
_gen_wiretype.FieldType{Type: 0x45, Name: "Op"},
_gen_wiretype.FieldType{Type: 0x46, Name: "ACL"},
},
"Tag", []string(nil)},
_gen_wiretype.SliceType{Elem: 0x47, Name: "storage.TagList", Tags: []string(nil)}, _gen_wiretype.StructType{
[]_gen_wiretype.FieldType{
_gen_wiretype.FieldType{Type: 0x3, Name: "Name"},
_gen_wiretype.FieldType{Type: 0x46, Name: "ID"},
},
"storage.DEntry", []string(nil)},
_gen_wiretype.SliceType{Elem: 0x49, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
[]_gen_wiretype.FieldType{
_gen_wiretype.FieldType{Type: 0x42, Name: "ID"},
_gen_wiretype.FieldType{Type: 0x43, Name: "PriorVersion"},
_gen_wiretype.FieldType{Type: 0x43, Name: "Version"},
_gen_wiretype.FieldType{Type: 0x2, Name: "IsRoot"},
_gen_wiretype.FieldType{Type: 0x44, Name: "Value"},
_gen_wiretype.FieldType{Type: 0x48, Name: "Tags"},
_gen_wiretype.FieldType{Type: 0x4a, Name: "Dir"},
},
"Mutation", []string(nil)},
_gen_wiretype.SliceType{Elem: 0x4b, Name: "", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
var ss _gen_ipc.ServiceSignature
var firstAdded int
ss, _ = s.ServerStubStore.Signature(call)
firstAdded = len(result.TypeDefs)
for k, v := range ss.Methods {
for i, _ := range v.InArgs {
if v.InArgs[i].Type >= _gen_wiretype.TypeIDFirst {
v.InArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
}
}
for i, _ := range v.OutArgs {
if v.OutArgs[i].Type >= _gen_wiretype.TypeIDFirst {
v.OutArgs[i].Type += _gen_wiretype.TypeID(firstAdded)
}
}
if v.InStream >= _gen_wiretype.TypeIDFirst {
v.InStream += _gen_wiretype.TypeID(firstAdded)
}
if v.OutStream >= _gen_wiretype.TypeIDFirst {
v.OutStream += _gen_wiretype.TypeID(firstAdded)
}
result.Methods[k] = v
}
//TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
for _, d := range ss.TypeDefs {
switch wt := d.(type) {
case _gen_wiretype.SliceType:
if wt.Elem >= _gen_wiretype.TypeIDFirst {
wt.Elem += _gen_wiretype.TypeID(firstAdded)
}
d = wt
case _gen_wiretype.ArrayType:
if wt.Elem >= _gen_wiretype.TypeIDFirst {
wt.Elem += _gen_wiretype.TypeID(firstAdded)
}
d = wt
case _gen_wiretype.MapType:
if wt.Key >= _gen_wiretype.TypeIDFirst {
wt.Key += _gen_wiretype.TypeID(firstAdded)
}
if wt.Elem >= _gen_wiretype.TypeIDFirst {
wt.Elem += _gen_wiretype.TypeID(firstAdded)
}
d = wt
case _gen_wiretype.StructType:
for _, fld := range wt.Fields {
if fld.Type >= _gen_wiretype.TypeIDFirst {
fld.Type += _gen_wiretype.TypeID(firstAdded)
}
}
d = wt
}
result.TypeDefs = append(result.TypeDefs, d)
}
return result, nil
}
func (s *ServerStubStore) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) {
if unresolver, ok := s.service.(_gen_ipc.Unresolver); ok {
return unresolver.UnresolveStep(call)
}
if call.Server() == nil {
return
}
var published []string
if published, err = call.Server().Published(); err != nil || published == nil {
return
}
reply = make([]string, len(published))
for i, p := range published {
reply[i] = _gen_naming.Join(p, call.Name())
}
return
}
func (__gen_s *ServerStubStore) PutMutations(call _gen_ipc.ServerCall, Mutations []Mutation) (err error) {
err = __gen_s.service.PutMutations(call, Mutations)
return
}
func GetStoreMethodTags(method string) []interface{} {
if resp := store.GetStoreMethodTags(method); resp != nil {
return resp
}
switch method {
case "PutMutations":
return []interface{}{}
default:
return nil
}
}