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


This section is empty.


This section is empty.


type Client

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

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

Get implements logs.Get.

func (*Client) OpenBinaryStream

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

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

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

Query implements logs.Query.

func (*Client) Tail

Tail implements logs.Tail.

type Stream

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

func (s *Stream) Close() error

Close terminates this stream.

func (*Stream) Write

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