Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Get(_ context.Context, in *logs_api.GetRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error)
- func (c *Client) OpenBinaryStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error)
- func (c *Client) OpenDatagramStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error)
- func (c *Client) OpenTextStream(prefix, path logdog_types.StreamName, flags ...*streamproto.Flags) (*Stream, error)
- func (c *Client) Query(_ context.Context, in *logs_api.QueryRequest, _ ...grpc.CallOption) (*logs_api.QueryResponse, error)
- func (c *Client) Tail(_ context.Context, in *logs_api.TailRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error)
- type Stream
Constants ¶
const ( // Project is the logdog project namespace that you should use with your // fakelogs clients. Project = "fakelogs-project" // Realm is a realm all fake logs end up associated with. Realm = "fakelogs-realm" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
func (c *Client) Get(_ context.Context, in *logs_api.GetRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error)
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 ¶
func (c *Client) Query(_ context.Context, in *logs_api.QueryRequest, _ ...grpc.CallOption) (*logs_api.QueryResponse, error)
Query implements logs.Query.
func (*Client) Tail ¶
func (c *Client) Tail(_ context.Context, in *logs_api.TailRequest, _ ...grpc.CallOption) (*logs_api.GetResponse, error)
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.