Documentation ¶
Index ¶
- Constants
- func IsError(err error, otherError error) bool
- func LoggerWithReaderID(logger log.Logger, readerID ReaderID) log.Logger
- type Action
- type Fields
- type Formatter
- type FormatterFunc
- type Matcher
- type Message
- type Persister
- type Processor
- type ReadLogsParams
- type Reader
- type ReaderID
- type ReaderParams
- type Source
- type State
Constants ¶
View Source
const MessageKey = "MESSAGE"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action interface { // PerformAction does something with matched messages. PerformAction(ctx context.Context, messages []Message) error }
Action defines an action to perform when a match is found.
type FormatterFunc ¶
FormatterFunc allows functions to implement Formatter.
type Message ¶
type Message struct { Timestamp time.Time `json:"ts"` // Timestamp of the event. Cursor string `json:"cursor,omitempty"` // Cursor position of the message. Fields Fields `json:"fields,omitempty"` // Fields contains message fields. Source Source `json:"source,omitempty"` // Source the message was read from. ReaderID ReaderID `json:"reader_id,omitempty"` // ReaderID that read the message. }
Message is the main log message.
func NewMessage ¶
NewMessage is a helper function for creating a Message. The text will be added as the MESSAGE field.
type Persister ¶
type Persister interface { // LoadState loads the reader state. When the state doees not exist, it must // return no error. LoadState(context.Context, ReaderID) (State, error) // SaveSave saves the reader state. SaveState(context.Context, ReaderID, State) error }
Persister is a component for loading and reading reader state.
type Processor ¶
type Processor interface { // ProcessMessage processes the message read. ProcessMessage(context.Context, Message) error Tick(context.Context, time.Time) error }
Processor is a message processor.
type ReadLogsParams ¶
type ReadLogsParams struct { State State // State for resuming reading. Ch chan<- Message // Ch is a channel to write the messages to. }
ReadLogsParams contains parameters for Reader.ReadLogs.
type Reader ¶
type Reader interface { // ReaderID returns the reader's ID. ReaderID() ReaderID // ReadLogs reads logs until context is done, or an error is encountered. // Implementations must not close the ReadLogsParams.Ch as that is done // conditionally in Watcher. ReadLogs(context.Context, ReadLogsParams) error }
Reader describes a component that can read logs.
type ReaderParams ¶
ReaderParams contains common parameters for all Reader implementations.
type State ¶
type State struct { // Timestamp is the last timestamp read. Timestamp time.Time `json:"time"` // NumMessages is the number of messages read with the same Timestamp. NumMessages int `json:"num_messages"` // Cursor is the current cursor, if any. Cursor string `json:"cursor,omitempty"` }
State describes the reader state.
func (State) WithCursor ¶
WithCursor returns a new State with cursor.
Click to show internal directories.
Click to hide internal directories.