luci: go.chromium.org/luci/logdog/api/endpoints/coordinator/logs/v1/fakelogs Index | Files

package fakelogs

import "go.chromium.org/luci/logdog/api/endpoints/coordinator/logs/v1/fakelogs"

Index

Package Files

client.go stream.go

Constants

const Project = coordinatorTest.AllAccessProject

Project is the logdog project namespace that you should use with your fakelogs clients.

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client implements the logs.LogsClient API, and also has some 'reach-around' APIs to insert stream data into the backend.

The reach-around APIs are very primitive; they don't simulate butler-side constraints (i.e. no prefix secrets, no multi-stream bundling, etc.), however from the server-side they should present a sufficient surface to write testable server code.

The Open*Stream methods take a singular optional flags object. If provided, a copy of this Flags object will be populated with the given logdog path and stream type. You can use this to give your streams a content type, tags, etc.

func NewClient Uses

func NewClient() *Client

NewClient generates a new fake Client which can be used as a logs.LogsClient, and can also have its underlying stream data manipulated by the test.

Functions taking context.Context will ignore it (i.e. they don't expect anything in the context).

This client is attached to an in-memory datastore of its own and the real coordinator services are attached to that in-memory datastore. That means that the Client API SHOULD actually behave identically to the real coordinator (since it's the same code). Additionally, the 'Open' methods on the Client do the full Prefix/Stream registration process, and so should also behave like the real thing.

func (*Client) Get Uses

func (c *Client) Get(_ context.Context, in *logs_api.GetRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error)

Get implements logs.Get.

func (*Client) OpenBinaryStream Uses

func (c *Client) OpenBinaryStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error)

OpenBinaryStream returns a stream for binary data.

Each Write will append to the binary data like a normal raw file.

func (*Client) OpenDatagramStream Uses

func (c *Client) OpenDatagramStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error)

OpenDatagramStream returns a stream for datagrams.

Each Write will produce a single complete datagram in the stream.

func (*Client) OpenTextStream Uses

func (c *Client) OpenTextStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error)

OpenTextStream returns a stream for text (line delimited) data.

- Lines are always delimited with "\n".
- Write calls will always have an implied "\n" at the end, if the input
  data doesn't have one. If you want to do multiple Write calls to affect
  the same line, you'll need to buffer it yourself.

func (*Client) Query Uses

func (c *Client) Query(_ context.Context, in *logs_api.QueryRequest, _ ...grpc.CallOption) (*logs_api.QueryResponse, error)

Query implements logs.Query.

func (*Client) Tail Uses

func (c *Client) Tail(_ context.Context, in *logs_api.TailRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error)

Tail implements logs.Tail.

type Stream Uses

type Stream struct {
    // contains filtered or unexported fields
}

Stream represents a single logdog stream.

Each invocation of Write() will append a new LogEntry to the stream internally. For datagram streams, this means that each Write is a single datagram.

Once the Stream is Close()'d it will be marked as complete.

func (*Stream) Close Uses

func (s *Stream) Close() error

Close terminates this stream.

func (*Stream) Write Uses

func (s *Stream) Write(bs []byte) (int, error)

Package fakelogs imports 26 packages (graph). Updated 2018-08-20. Refresh now. Tools for package owners.