Documentation
¶
Index ¶
- func Manifold(config ManifoldConfig) dependency.Manifold
- func NewModelLogger(ctx context.Context, key corelogger.LoggerKey, config ModelLoggerConfig) (worker.Worker, error)
- func NewWorker(cfg Config) (worker.Worker, error)
- type Config
- type LogSink
- func (w *LogSink) Close() error
- func (w *LogSink) GetLogWriter(ctx context.Context, modelUUID model.UUID) (logger.LogWriterCloser, error)
- func (w *LogSink) GetLoggerContext(ctx context.Context, modelUUID model.UUID) (logger.LoggerContext, error)
- func (w *LogSink) Kill()
- func (w *LogSink) RemoveLogWriter(modelUUID model.UUID) error
- func (w *LogSink) Wait() error
- type LogSinkConfig
- type LogSinkWriter
- type ManifoldConfig
- type ModelLoggerConfig
- type ModelService
- type ModelServiceGetterFunc
- type NewModelLoggerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a dependency manifold that runs a log sink worker, using the resource names defined in the supplied config.
func NewModelLogger ¶
func NewModelLogger( ctx context.Context, key corelogger.LoggerKey, config ModelLoggerConfig, ) (worker.Worker, error)
NewModelLogger returns a new model logger instance.
Types ¶
type Config ¶
type Config struct { Logger logger.Logger Clock clock.Clock LogSinkConfig LogSinkConfig MachineID string NewModelLogger NewModelLoggerFunc LogWriterForModelFunc logger.LogWriterForModelFunc ModelService ModelService }
Config defines the attributes used to create a log sink worker.
type LogSink ¶
type LogSink struct {
// contains filtered or unexported fields
}
LogSink is a worker which provides access to a log sink which allows log entries to be stored for specified models.
func (*LogSink) GetLogWriter ¶
func (w *LogSink) GetLogWriter(ctx context.Context, modelUUID model.UUID) (logger.LogWriterCloser, error)
GetLogWriter returns a log writer for the specified model UUID. It is an error if the log writer is not running. Call InitializeLogger to start the log writer.
func (*LogSink) GetLoggerContext ¶
func (w *LogSink) GetLoggerContext(ctx context.Context, modelUUID model.UUID) (logger.LoggerContext, error)
GetLoggerContext returns a logger context for the specified model UUID. It is an error if the log writer is not running. Call InitializeLogger to start the log writer.
func (*LogSink) RemoveLogWriter ¶
RemoveLogWriter closes then removes a log writer by model UUID. Returns an error if there was a problem closing the logger.
type LogSinkConfig ¶
type LogSinkConfig struct { // LoggerBufferSize is the capacity of the log sink logger's buffer. LoggerBufferSize int // LoggerFlushInterval is the amount of time to allow a log record // to sit in the buffer before being flushed to the destination logger. LoggerFlushInterval time.Duration }
LogSinkConfig holds parameters to control the log sink's behaviour.
func DefaultLogSinkConfig ¶
func DefaultLogSinkConfig() LogSinkConfig
DefaultLogSinkConfig returns a LogSinkConfig with default values.
func (LogSinkConfig) Validate ¶
func (cfg LogSinkConfig) Validate() error
Validate validates the logsink endpoint configuration.
type LogSinkWriter ¶
type LogSinkWriter interface { logger.LogWriterCloser logger.LoggerContext }
LogSinkWriter is a writer that writes log records to a log sink.
type ManifoldConfig ¶
type ManifoldConfig struct { // DebugLogger is used to emit debug messages. DebugLogger corelogger.Logger // NewWorker creates a log sink worker. NewWorker func(cfg Config) (worker.Worker, error) // NewModelLogger creates a new model logger. NewModelLogger NewModelLoggerFunc // ModelServiceGetter returns the model service. ModelServiceGetter ModelServiceGetterFunc ClockName string LogSinkServices string AgentName string }
ManifoldConfig defines the names of the manifolds on which a Manifold will depend.
func (ManifoldConfig) Validate ¶
func (config ManifoldConfig) Validate() error
Validate validates the manifold configuration.
type ModelLoggerConfig ¶
type ModelLoggerConfig struct { MachineID string NewLogWriter corelogger.LogWriterForModelFunc BufferSize int FlushInterval time.Duration Clock clock.Clock }
ModelLoggerConfig holds the configuration for a model logger.
type ModelService ¶
type ModelService interface { // Model returns the model information. Model(ctx context.Context, modelUUID model.UUID) (model.ModelInfo, error) }
ModelService is an interface that provides model information.
func NewModelService ¶
func NewModelService(servicesGetter services.LogSinkServicesGetter) ModelService
NewModelService returns a new model service.
type ModelServiceGetterFunc ¶
type ModelServiceGetterFunc func(services.LogSinkServicesGetter) ModelService
ModelServiceGetterFunc is a function that returns the model service.
type NewModelLoggerFunc ¶
type NewModelLoggerFunc func(ctx context.Context, key corelogger.LoggerKey, cfg ModelLoggerConfig) (worker.Worker, error)
NewModelLoggerFunc is a function that creates a new model logger.