| // This file was auto-generated by the veyron vdl tool. |
| // Source: p2b.vdl |
| |
| // Package vdl is an example of a veyron service for |
| // streaming data from a pipe to a browser, which can visualize this |
| // data. |
| package vdl |
| |
| import ( |
| // VDL system imports |
| "io" |
| "v.io/v23" |
| "v.io/v23/context" |
| "v.io/v23/ipc" |
| "v.io/v23/vdl" |
| ) |
| |
| // ViewerClientMethods is the client interface |
| // containing Viewer methods. |
| // |
| // Viewer allows clients to stream data to it and to request a |
| // particular viewer to format and display the data. |
| type ViewerClientMethods interface { |
| // Pipe creates a bidirectional pipe between client and viewer |
| // service, returns total number of bytes received by the service |
| // after streaming ends |
| Pipe(*context.T, ...ipc.CallOpt) (ViewerPipeClientCall, error) |
| } |
| |
| // ViewerClientStub adds universal methods to ViewerClientMethods. |
| type ViewerClientStub interface { |
| ViewerClientMethods |
| ipc.UniversalServiceMethods |
| } |
| |
| // ViewerClient returns a client stub for Viewer. |
| func ViewerClient(name string, opts ...ipc.BindOpt) ViewerClientStub { |
| var client ipc.Client |
| for _, opt := range opts { |
| if clientOpt, ok := opt.(ipc.Client); ok { |
| client = clientOpt |
| } |
| } |
| return implViewerClientStub{name, client} |
| } |
| |
| type implViewerClientStub struct { |
| name string |
| client ipc.Client |
| } |
| |
| func (c implViewerClientStub) c(ctx *context.T) ipc.Client { |
| if c.client != nil { |
| return c.client |
| } |
| return v23.GetClient(ctx) |
| } |
| |
| func (c implViewerClientStub) Pipe(ctx *context.T, opts ...ipc.CallOpt) (ocall ViewerPipeClientCall, err error) { |
| var call ipc.ClientCall |
| if call, err = c.c(ctx).StartCall(ctx, c.name, "Pipe", nil, opts...); err != nil { |
| return |
| } |
| ocall = &implViewerPipeClientCall{ClientCall: call} |
| return |
| } |
| |
| // ViewerPipeClientStream is the client stream for Viewer.Pipe. |
| type ViewerPipeClientStream interface { |
| // SendStream returns the send side of the Viewer.Pipe client stream. |
| SendStream() interface { |
| // Send places the item onto the output stream. Returns errors |
| // encountered while sending, or if Send is called after Close or |
| // the stream has been canceled. Blocks if there is no buffer |
| // space; will unblock when buffer space is available or after |
| // the stream has been canceled. |
| Send(item []byte) error |
| // Close indicates to the server that no more items will be sent; |
| // server Recv calls will receive io.EOF after all sent items. |
| // This is an optional call - e.g. a client might call Close if it |
| // needs to continue receiving items from the server after it's |
| // done sending. Returns errors encountered while closing, or if |
| // Close is called after the stream has been canceled. Like Send, |
| // blocks if there is no buffer space available. |
| Close() error |
| } |
| } |
| |
| // ViewerPipeClientCall represents the call returned from Viewer.Pipe. |
| type ViewerPipeClientCall interface { |
| ViewerPipeClientStream |
| // Finish performs the equivalent of SendStream().Close, then blocks until |
| // the server is done, and returns the positional return values for the 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() (*vdl.Value, error) |
| } |
| |
| type implViewerPipeClientCall struct { |
| ipc.ClientCall |
| } |
| |
| func (c *implViewerPipeClientCall) SendStream() interface { |
| Send(item []byte) error |
| Close() error |
| } { |
| return implViewerPipeCallSend{c} |
| } |
| |
| type implViewerPipeCallSend struct { |
| c *implViewerPipeClientCall |
| } |
| |
| func (c implViewerPipeCallSend) Send(item []byte) error { |
| return c.c.Send(item) |
| } |
| func (c implViewerPipeCallSend) Close() error { |
| return c.c.CloseSend() |
| } |
| func (c *implViewerPipeClientCall) Finish() (o0 *vdl.Value, err error) { |
| err = c.ClientCall.Finish(&o0) |
| return |
| } |
| |
| // ViewerServerMethods is the interface a server writer |
| // implements for Viewer. |
| // |
| // Viewer allows clients to stream data to it and to request a |
| // particular viewer to format and display the data. |
| type ViewerServerMethods interface { |
| // Pipe creates a bidirectional pipe between client and viewer |
| // service, returns total number of bytes received by the service |
| // after streaming ends |
| Pipe(ViewerPipeContext) (*vdl.Value, error) |
| } |
| |
| // ViewerServerStubMethods is the server interface containing |
| // Viewer methods, as expected by ipc.Server. |
| // The only difference between this interface and ViewerServerMethods |
| // is the streaming methods. |
| type ViewerServerStubMethods interface { |
| // Pipe creates a bidirectional pipe between client and viewer |
| // service, returns total number of bytes received by the service |
| // after streaming ends |
| Pipe(*ViewerPipeContextStub) (*vdl.Value, error) |
| } |
| |
| // ViewerServerStub adds universal methods to ViewerServerStubMethods. |
| type ViewerServerStub interface { |
| ViewerServerStubMethods |
| // Describe the Viewer interfaces. |
| Describe__() []ipc.InterfaceDesc |
| } |
| |
| // ViewerServer returns a server stub for Viewer. |
| // It converts an implementation of ViewerServerMethods into |
| // an object that may be used by ipc.Server. |
| func ViewerServer(impl ViewerServerMethods) ViewerServerStub { |
| stub := implViewerServerStub{ |
| 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 implViewerServerStub struct { |
| impl ViewerServerMethods |
| gs *ipc.GlobState |
| } |
| |
| func (s implViewerServerStub) Pipe(ctx *ViewerPipeContextStub) (*vdl.Value, error) { |
| return s.impl.Pipe(ctx) |
| } |
| |
| func (s implViewerServerStub) Globber() *ipc.GlobState { |
| return s.gs |
| } |
| |
| func (s implViewerServerStub) Describe__() []ipc.InterfaceDesc { |
| return []ipc.InterfaceDesc{ViewerDesc} |
| } |
| |
| // ViewerDesc describes the Viewer interface. |
| var ViewerDesc ipc.InterfaceDesc = descViewer |
| |
| // descViewer hides the desc to keep godoc clean. |
| var descViewer = ipc.InterfaceDesc{ |
| Name: "Viewer", |
| PkgPath: "p2b/vdl", |
| Doc: "// Viewer allows clients to stream data to it and to request a\n// particular viewer to format and display the data.", |
| Methods: []ipc.MethodDesc{ |
| { |
| Name: "Pipe", |
| Doc: "// Pipe creates a bidirectional pipe between client and viewer\n// service, returns total number of bytes received by the service\n// after streaming ends", |
| OutArgs: []ipc.ArgDesc{ |
| {"", ``}, // *vdl.Value |
| }, |
| }, |
| }, |
| } |
| |
| // ViewerPipeServerStream is the server stream for Viewer.Pipe. |
| type ViewerPipeServerStream interface { |
| // RecvStream returns the receiver side of the Viewer.Pipe server 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() []byte |
| // Err returns any error encountered by Advance. Never blocks. |
| Err() error |
| } |
| } |
| |
| // ViewerPipeContext represents the context passed to Viewer.Pipe. |
| type ViewerPipeContext interface { |
| ipc.ServerCall |
| ViewerPipeServerStream |
| } |
| |
| // ViewerPipeContextStub is a wrapper that converts ipc.StreamServerCall into |
| // a typesafe stub that implements ViewerPipeContext. |
| type ViewerPipeContextStub struct { |
| ipc.StreamServerCall |
| valRecv []byte |
| errRecv error |
| } |
| |
| // Init initializes ViewerPipeContextStub from ipc.StreamServerCall. |
| func (s *ViewerPipeContextStub) Init(call ipc.StreamServerCall) { |
| s.StreamServerCall = call |
| } |
| |
| // RecvStream returns the receiver side of the Viewer.Pipe server stream. |
| func (s *ViewerPipeContextStub) RecvStream() interface { |
| Advance() bool |
| Value() []byte |
| Err() error |
| } { |
| return implViewerPipeContextRecv{s} |
| } |
| |
| type implViewerPipeContextRecv struct { |
| s *ViewerPipeContextStub |
| } |
| |
| func (s implViewerPipeContextRecv) Advance() bool { |
| s.s.errRecv = s.s.Recv(&s.s.valRecv) |
| return s.s.errRecv == nil |
| } |
| func (s implViewerPipeContextRecv) Value() []byte { |
| return s.s.valRecv |
| } |
| func (s implViewerPipeContextRecv) Err() error { |
| if s.s.errRecv == io.EOF { |
| return nil |
| } |
| return s.s.errRecv |
| } |