blob: ad89ae6a9f506c4ba44ae9a2a44c71caf8cc9935 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Source: logreader.vdl
// Package logreader defines interfaces for reading log files remotely.
package logreader
import (
"io"
"v.io/v23"
"v.io/v23/context"
"v.io/v23/rpc"
"v.io/v23/security/access"
"v.io/v23/vdl"
)
// LogEntry is a log entry from a log file.
type LogEntry struct {
// The offset (in bytes) where this entry starts.
Position int64
// The content of the log entry.
Line string
}
func (LogEntry) __VDLReflect(struct {
Name string `vdl:"v.io/v23/services/logreader.LogEntry"`
}) {
}
func (m *LogEntry) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
if __VDLType_logreader_v_io_v23_services_logreader_LogEntry == nil || __VDLTypelogreader0 == nil {
panic("Initialization order error: types generated for FillVDLTarget not initialized. Consider moving caller to an init() block.")
}
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Position")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
if err := fieldTarget3.FromInt(int64(m.Position), vdl.Int64Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
keyTarget4, fieldTarget5, err := fieldsTarget1.StartField("Line")
if err != vdl.ErrFieldNoExist && err != nil {
return err
}
if err != vdl.ErrFieldNoExist {
if err := fieldTarget5.FromString(string(m.Line), vdl.StringType); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget4, fieldTarget5); err != nil {
return err
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *LogEntry) MakeVDLTarget() vdl.Target {
return nil
}
func init() {
vdl.Register((*LogEntry)(nil))
}
var __VDLTypelogreader0 *vdl.Type = vdl.TypeOf((*LogEntry)(nil))
var __VDLType_logreader_v_io_v23_services_logreader_LogEntry *vdl.Type = vdl.TypeOf(LogEntry{})
func __VDLEnsureNativeBuilt_logreader() {
}
// A special NumEntries value that indicates that all entries should be
// returned by ReadLog.
const AllEntries = int32(-1)
// LogFileClientMethods is the client interface
// containing LogFile methods.
//
// LogFile can be used to access log files remotely.
type LogFileClientMethods interface {
// Size returns the number of bytes in the receiving object.
Size(*context.T, ...rpc.CallOpt) (int64, error)
// ReadLog receives up to numEntries log entries starting at the
// startPos offset (in bytes) in the receiving object. Each stream chunk
// contains one log entry.
//
// If follow is true, ReadLog will block and wait for more entries to
// arrive when it reaches the end of the file.
//
// ReadLog returns the position where it stopped reading, i.e. the
// position where the next entry starts. This value can be used as
// startPos for successive calls to ReadLog.
//
// The returned error will be EndOfFile if and only if ReadLog reached the
// end of the file and no log entries were returned.
ReadLog(_ *context.T, startPos int64, numEntries int32, follow bool, _ ...rpc.CallOpt) (LogFileReadLogClientCall, error)
}
// LogFileClientStub adds universal methods to LogFileClientMethods.
type LogFileClientStub interface {
LogFileClientMethods
rpc.UniversalServiceMethods
}
// LogFileClient returns a client stub for LogFile.
func LogFileClient(name string) LogFileClientStub {
return implLogFileClientStub{name}
}
type implLogFileClientStub struct {
name string
}
func (c implLogFileClientStub) Size(ctx *context.T, opts ...rpc.CallOpt) (o0 int64, err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Size", nil, []interface{}{&o0}, opts...)
return
}
func (c implLogFileClientStub) ReadLog(ctx *context.T, i0 int64, i1 int32, i2 bool, opts ...rpc.CallOpt) (ocall LogFileReadLogClientCall, err error) {
var call rpc.ClientCall
if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "ReadLog", []interface{}{i0, i1, i2}, opts...); err != nil {
return
}
ocall = &implLogFileReadLogClientCall{ClientCall: call}
return
}
// LogFileReadLogClientStream is the client stream for LogFile.ReadLog.
type LogFileReadLogClientStream interface {
// RecvStream returns the receiver side of the LogFile.ReadLog client stream.
RecvStream() interface {
// Advance stages an item so that it may be retrieved via Value. Returns
// true iff there is an item to retrieve. Advance must be called before
// Value is called. May block if an item is not available.
Advance() bool
// Value returns the item that was staged by Advance. May panic if Advance
// returned false or was not called. Never blocks.
Value() LogEntry
// Err returns any error encountered by Advance. Never blocks.
Err() error
}
}
// LogFileReadLogClientCall represents the call returned from LogFile.ReadLog.
type LogFileReadLogClientCall interface {
LogFileReadLogClientStream
// Finish blocks until the server is done, and returns the positional return
// values for call.
//
// Finish returns immediately if the call has been canceled; depending on the
// timing the output could either be an error signaling cancelation, or the
// valid positional return values from the server.
//
// Calling Finish is mandatory for releasing stream resources, unless the call
// has been canceled or any of the other methods return an error. Finish should
// be called at most once.
Finish() (int64, error)
}
type implLogFileReadLogClientCall struct {
rpc.ClientCall
valRecv LogEntry
errRecv error
}
func (c *implLogFileReadLogClientCall) RecvStream() interface {
Advance() bool
Value() LogEntry
Err() error
} {
return implLogFileReadLogClientCallRecv{c}
}
type implLogFileReadLogClientCallRecv struct {
c *implLogFileReadLogClientCall
}
func (c implLogFileReadLogClientCallRecv) Advance() bool {
c.c.valRecv = LogEntry{}
c.c.errRecv = c.c.Recv(&c.c.valRecv)
return c.c.errRecv == nil
}
func (c implLogFileReadLogClientCallRecv) Value() LogEntry {
return c.c.valRecv
}
func (c implLogFileReadLogClientCallRecv) Err() error {
if c.c.errRecv == io.EOF {
return nil
}
return c.c.errRecv
}
func (c *implLogFileReadLogClientCall) Finish() (o0 int64, err error) {
err = c.ClientCall.Finish(&o0)
return
}
// LogFileServerMethods is the interface a server writer
// implements for LogFile.
//
// LogFile can be used to access log files remotely.
type LogFileServerMethods interface {
// Size returns the number of bytes in the receiving object.
Size(*context.T, rpc.ServerCall) (int64, error)
// ReadLog receives up to numEntries log entries starting at the
// startPos offset (in bytes) in the receiving object. Each stream chunk
// contains one log entry.
//
// If follow is true, ReadLog will block and wait for more entries to
// arrive when it reaches the end of the file.
//
// ReadLog returns the position where it stopped reading, i.e. the
// position where the next entry starts. This value can be used as
// startPos for successive calls to ReadLog.
//
// The returned error will be EndOfFile if and only if ReadLog reached the
// end of the file and no log entries were returned.
ReadLog(_ *context.T, _ LogFileReadLogServerCall, startPos int64, numEntries int32, follow bool) (int64, error)
}
// LogFileServerStubMethods is the server interface containing
// LogFile methods, as expected by rpc.Server.
// The only difference between this interface and LogFileServerMethods
// is the streaming methods.
type LogFileServerStubMethods interface {
// Size returns the number of bytes in the receiving object.
Size(*context.T, rpc.ServerCall) (int64, error)
// ReadLog receives up to numEntries log entries starting at the
// startPos offset (in bytes) in the receiving object. Each stream chunk
// contains one log entry.
//
// If follow is true, ReadLog will block and wait for more entries to
// arrive when it reaches the end of the file.
//
// ReadLog returns the position where it stopped reading, i.e. the
// position where the next entry starts. This value can be used as
// startPos for successive calls to ReadLog.
//
// The returned error will be EndOfFile if and only if ReadLog reached the
// end of the file and no log entries were returned.
ReadLog(_ *context.T, _ *LogFileReadLogServerCallStub, startPos int64, numEntries int32, follow bool) (int64, error)
}
// LogFileServerStub adds universal methods to LogFileServerStubMethods.
type LogFileServerStub interface {
LogFileServerStubMethods
// Describe the LogFile interfaces.
Describe__() []rpc.InterfaceDesc
}
// LogFileServer returns a server stub for LogFile.
// It converts an implementation of LogFileServerMethods into
// an object that may be used by rpc.Server.
func LogFileServer(impl LogFileServerMethods) LogFileServerStub {
stub := implLogFileServerStub{
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 := rpc.NewGlobState(stub); gs != nil {
stub.gs = gs
} else if gs := rpc.NewGlobState(impl); gs != nil {
stub.gs = gs
}
return stub
}
type implLogFileServerStub struct {
impl LogFileServerMethods
gs *rpc.GlobState
}
func (s implLogFileServerStub) Size(ctx *context.T, call rpc.ServerCall) (int64, error) {
return s.impl.Size(ctx, call)
}
func (s implLogFileServerStub) ReadLog(ctx *context.T, call *LogFileReadLogServerCallStub, i0 int64, i1 int32, i2 bool) (int64, error) {
return s.impl.ReadLog(ctx, call, i0, i1, i2)
}
func (s implLogFileServerStub) Globber() *rpc.GlobState {
return s.gs
}
func (s implLogFileServerStub) Describe__() []rpc.InterfaceDesc {
return []rpc.InterfaceDesc{LogFileDesc}
}
// LogFileDesc describes the LogFile interface.
var LogFileDesc rpc.InterfaceDesc = descLogFile
// descLogFile hides the desc to keep godoc clean.
var descLogFile = rpc.InterfaceDesc{
Name: "LogFile",
PkgPath: "v.io/v23/services/logreader",
Doc: "// LogFile can be used to access log files remotely.",
Methods: []rpc.MethodDesc{
{
Name: "Size",
Doc: "// Size returns the number of bytes in the receiving object.",
OutArgs: []rpc.ArgDesc{
{"", ``}, // int64
},
Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Debug"))},
},
{
Name: "ReadLog",
Doc: "// ReadLog receives up to numEntries log entries starting at the\n// startPos offset (in bytes) in the receiving object. Each stream chunk\n// contains one log entry.\n//\n// If follow is true, ReadLog will block and wait for more entries to\n// arrive when it reaches the end of the file.\n//\n// ReadLog returns the position where it stopped reading, i.e. the\n// position where the next entry starts. This value can be used as\n// startPos for successive calls to ReadLog.\n//\n// The returned error will be EndOfFile if and only if ReadLog reached the\n// end of the file and no log entries were returned.",
InArgs: []rpc.ArgDesc{
{"startPos", ``}, // int64
{"numEntries", ``}, // int32
{"follow", ``}, // bool
},
OutArgs: []rpc.ArgDesc{
{"", ``}, // int64
},
Tags: []*vdl.Value{vdl.ValueOf(access.Tag("Debug"))},
},
},
}
// LogFileReadLogServerStream is the server stream for LogFile.ReadLog.
type LogFileReadLogServerStream interface {
// SendStream returns the send side of the LogFile.ReadLog server stream.
SendStream() interface {
// Send places the item onto the output stream. Returns errors encountered
// while sending. Blocks if there is no buffer space; will unblock when
// buffer space is available.
Send(item LogEntry) error
}
}
// LogFileReadLogServerCall represents the context passed to LogFile.ReadLog.
type LogFileReadLogServerCall interface {
rpc.ServerCall
LogFileReadLogServerStream
}
// LogFileReadLogServerCallStub is a wrapper that converts rpc.StreamServerCall into
// a typesafe stub that implements LogFileReadLogServerCall.
type LogFileReadLogServerCallStub struct {
rpc.StreamServerCall
}
// Init initializes LogFileReadLogServerCallStub from rpc.StreamServerCall.
func (s *LogFileReadLogServerCallStub) Init(call rpc.StreamServerCall) {
s.StreamServerCall = call
}
// SendStream returns the send side of the LogFile.ReadLog server stream.
func (s *LogFileReadLogServerCallStub) SendStream() interface {
Send(item LogEntry) error
} {
return implLogFileReadLogServerCallSend{s}
}
type implLogFileReadLogServerCallSend struct {
s *LogFileReadLogServerCallStub
}
func (s implLogFileReadLogServerCallSend) Send(item LogEntry) error {
return s.s.Send(item)
}