schedulers

package
v0.0.0-...-62c67db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

Schedulers

Schedulers are the components responsible for managing log sources (pkg/log/sources.LogSource) and services [1]. These sources and services are then recognized by logs-agent launchers, which create tailers and attach them to the logs-agent pipeline.

In short, schedulers control what is and is not logged, and how it is logged.

The logs-agent maintains a set of current schedulers, starting them at startup and stopping them when the logs-agent stops.

[1] In planned development, schedulers will only manage sources, not services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockAddRemove

type MockAddRemove struct {
	// Added is true if this source was added; otherwise it was removed
	Add bool

	// Source is the source that was added or removed, or nil.
	Source *sources.LogSource

	// Service is the service that was added or removed, or nil.
	Service *service.Service
}

MockAddRemove is an event observed by MockSourceManager

type MockSourceManager

type MockSourceManager struct {
	// Events are the events that occurred in the spy
	Events []MockAddRemove

	// Sources are the sources returned by GetSources
	Sources []*sources.LogSource
}

MockSourceManager is a "spy" that records the AddSource and RemoveSource calls that it receives.

This is a useful tool in testing schedulers. Its zero value is a valid beginning state.

func (*MockSourceManager) AddService

func (sm *MockSourceManager) AddService(service *service.Service)

AddService implements SourceManager#AddService.

func (*MockSourceManager) AddSource

func (sm *MockSourceManager) AddSource(source *sources.LogSource)

AddSource implements SourceManager#AddSource.

func (*MockSourceManager) GetSources

func (sm *MockSourceManager) GetSources() []*sources.LogSource

GetSources implements SourceManager#GetSources.

func (*MockSourceManager) RemoveService

func (sm *MockSourceManager) RemoveService(service *service.Service)

RemoveService implements SourceManager#RemoveService.

func (*MockSourceManager) RemoveSource

func (sm *MockSourceManager) RemoveSource(source *sources.LogSource)

RemoveSource implements SourceManager#RemoveSource.

type Scheduler

type Scheduler interface {
	// Start the scheduler, managing sources and services via the given manager.
	Start(sourceMgr SourceManager)

	// Stop the scheduler, and wait until shutdown is complete.  It is not
	// necessary to remove sources or services here, but any background
	// goroutines or other resources should be freed.
	Stop()
}

Scheduler implementations manage logs-agent sources.

Schedulers are started when the logs-agent starts, and stopped when it stops.

type Schedulers

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

Schedulers manages a collection of schedulers.

func NewSchedulers

func NewSchedulers(sources *sources.LogSources, services *service.Services) *Schedulers

NewSchedulers creates a new, empty Schedulers instance

func (*Schedulers) AddScheduler

func (ss *Schedulers) AddScheduler(scheduler Scheduler)

AddScheduler adds a scheduler to the collection. If called after Start(), then the scheduler will be started immediately.

func (*Schedulers) GetSources

func (ss *Schedulers) GetSources() []*sources.LogSource

GetSources returns all the log source from the source manager.

func (*Schedulers) Start

func (ss *Schedulers) Start()

Start starts all schedulers in the collection.

func (*Schedulers) Stop

func (ss *Schedulers) Stop()

Stop all schedulers and wait until they are complete.

type SourceManager

type SourceManager interface {
	// AddSource adds a new source to the logs agent.  The new source is
	// distributed to all active launchers, which may create appropriate
	// tailers and begin forwarding messages.
	AddSource(source *sources.LogSource)

	// RemoveSource removes an existing source from the logs agent.  The
	// source is recognized by pointer equality.
	RemoveSource(source *sources.LogSource)

	// GetSources returns all the sources currently held.  The result is copied and
	// will not be modified after it is returned, and represents a "snapshot" of the
	// state when the function was called.
	GetSources() []*sources.LogSource

	// AddService adds a new service to the logs agent.
	AddService(service *service.Service)

	// RemoveService removes a service added with AddService.  The source
	// is recognized by pointer equality.
	RemoveService(service *service.Service)
}

SourceManager is the interface by which schedulers add and remove sources from the agent.

(services are also included here, temporarily)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL