Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerLogStreamer ¶
type ContainerLogStreamer struct {
// contains filtered or unexported fields
}
ContainerLogStreamer connects and activates container's log stream with io.Writer
func NewContainerLogStreamer ¶
func NewContainerLogStreamer(params ContainerStreamerParams) *ContainerLogStreamer
NewContainerLogStreamer makes log streamer for given container with writers and log emitter
func (*ContainerLogStreamer) Close ¶
func (l *ContainerLogStreamer) Close(ctx context.Context) (err error)
Close kills streamer
func (*ContainerLogStreamer) Name ¶
func (l *ContainerLogStreamer) Name() string
Name of the streamed container
func (*ContainerLogStreamer) Run ¶
func (l *ContainerLogStreamer) Run() error
Run activates streamer, blocking
type ContainerStreamerParams ¶
type ContainerStreamerParams struct {
ID string
Name string
LogWriter io.WriteCloser
ErrWriter io.WriteCloser
LogsEmitter LogsEmitter
}
ContainerStreamerParams defines everything used to construct container's log streamer
type DemoEmitter ¶
DemoEmitter is a emitter for fake logs, no docker involved
func (*DemoEmitter) Logs ¶
func (d *DemoEmitter) Logs(o docker.LogsOptions) error
Logs generates random log messages
type DemoEventNotifier ¶
type DemoEventNotifier struct {
// contains filtered or unexported fields
}
DemoEventNotifier is a fake/replacement for docker notifier
func NewDemoEventNotifier ¶
func NewDemoEventNotifier(ctx context.Context) *DemoEventNotifier
NewDemoEventNotifier makes notifier emitting 3 events
func (*DemoEventNotifier) Channel ¶
func (e *DemoEventNotifier) Channel() (res <-chan Event)
Channel gets eventsCh with all containers events
type DockerClient ¶
type DockerClient interface {
ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
AddEventListener(listener chan<- *docker.APIEvents) error
}
DockerClient defines interface listing containers and subscribing to events
type Event ¶
type Event struct {
ContainerID string
ContainerName string
Group string // group is the "path" part of the image tag, i.e. for umputun/system/logger:latest it will be "system"
TS time.Time
Status bool
}
Event is simplified docker.APIEvents for containers only, exposed to caller
type EventLoop ¶
type EventLoop struct {
MixOuts bool
WriterFactory func(ctx context.Context, containerName, group string) (logWriter, errWriter io.WriteCloser, err error)
LogEmitter LogEmitter
Events Eventer
// contains filtered or unexported fields
}
EventLoop reacts on messages from Events, adds+activate LogStreamer as well as stop+remove them.
type EventNotifier ¶
type EventNotifier struct {
// contains filtered or unexported fields
}
EventNotifier emits all changes from all containers states
func NewEventNotifier ¶
func NewEventNotifier(dockerClient DockerClient, excludes, includes []string) (*EventNotifier, error)
NewEventNotifier makes EventNotifier publishing all changes to eventsCh
func (*EventNotifier) Channel ¶
func (e *EventNotifier) Channel() (res <-chan Event)
Channel gets eventsCh with all containers events
type LogEmitter ¶
type LogEmitter interface {
Logs(opts docker.LogsOptions) error
}
LogEmitter wraps DockerClient with the minimal interface
type LogStreamer ¶
LogStreamer defines runnable interface created on event
type LogsEmitter ¶
type LogsEmitter interface {
Logs(docker.LogsOptions) error // runs endless loop publishing logs to writers from LogsOptions
}
LogsEmitter wraps DockerClient with the minimal interface to emit logs
type MultiWriter ¶
type MultiWriter struct {
// contains filtered or unexported fields
}
MultiWriter implements WriteCloser for multiple destinations. It is simplified version of stdlib MultiWriter. Ignores write error and don't stop the loop unless all writes failed.
func NewMultiWriterIgnoreErrors ¶
func NewMultiWriterIgnoreErrors(writers ...io.WriteCloser) *MultiWriter
NewMultiWriterIgnoreErrors create WriteCloser for multiple destinations
func (*MultiWriter) WithExtJSON ¶
func (w *MultiWriter) WithExtJSON(containerName, group string) *MultiWriter
WithExtJSON turn JSON output mode on