Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review component package grammar #60

Closed
wants to merge 11 commits into from
24 changes: 12 additions & 12 deletions component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
//
// A component's lifecycle has the following phases:
//
// 1. Creation: The component is create using the factory, via a Create* call.
// 1. Creation: The component is created using its respective factory, via a Create* call.
// 2. Start: The component's Start method is called.
// 3. Running: The component is up and running.
// 4. Shutdown: The component's Shutdown method is called and the lifecycle is complete.
Expand All @@ -33,27 +33,27 @@ import (
// is created, starts, runs and is shutdown again.
type Component interface {
// Start tells the component to start. Host parameter can be used for communicating
// with the host after Start() has already returned. If error is returned by
// with the host after Start() has already returned. If an error is returned by
// Start() then the collector startup will be aborted.
// If this is an exporter component it may prepare for exporting
// by connecting to the endpoint.
//
// If the component needs to perform a long-running starting operation then it is recommended
// that Start() returns quickly and the long-running operation is performed in background.
// In that case make sure that the long-running operation does not use the context passed
// to Start() function since that context will be cancelled soon and can abort the long-running operation.
// Create a new context from the context.Background() for long-running operations.
// to Start() function since that context will be cancelled soon and can abort the long-running
// operation. Create a new context from the context.Background() for long-running operations.
Start(ctx context.Context, host Host) error

// Shutdown is invoked during service shutdown. After Shutdown() is called, if the component accept data in
// any way, it should not accept it anymore.
// Shutdown is invoked during service shutdown. After Shutdown() is called, if the component
// accepted data in any way, it should not accept it anymore.
//
// If there are any background operations running by the component they must be aborted as soon as possible.
// Remember that if you started any long-running background operation from the Start() method that operation
// must be also cancelled. If there are any buffer in the component, it should be cleared and the data sent
// immediately to the next component.
//
// Once the Shutdown() method returns the component's lifecycle is completed. No other
// If there are any background operations running by the component they must be aborted as
// soon as possible. Remember that if you started any long-running background operations from
// the Start() method, those operations must be also cancelled. If there are any buffers in the
// component, they should be cleared and the data sent immediately to the next component.
//
// The component's lifecycle is completed once the Shutdown() method returns. No other
// methods of the component are called after that. If necessary a new component with
// the same or different configuration may be created and started (this may happen
// for example if we want to restart the component).
Expand Down
14 changes: 7 additions & 7 deletions component/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ type ExporterFactory interface {
// configuration and should not cause side-effects that prevent the creation
// of multiple instances of the Exporter.
// The object returned by this method needs to pass the checks implemented by
// 'configcheck.ValidateConfig'. It is recommended to have such check in the
// 'configcheck.ValidateConfig'. It is recommended to have these checks in the
// tests of any implementation of the Factory interface.
CreateDefaultConfig() config.Exporter

// CreateTracesExporter creates a trace exporter based on this config.
// If the exporter type does not support tracing or if the config is not valid
// error will be returned instead.
// If the exporter type does not support tracing or if the config is not valid,
// an error will be returned instead.
CreateTracesExporter(ctx context.Context, params ExporterCreateParams,
cfg config.Exporter) (TracesExporter, error)

// CreateMetricsExporter creates a metrics exporter based on this config.
// If the exporter type does not support metrics or if the config is not valid
// error will be returned instead.
// If the exporter type does not support metrics or if the config is not valid,
// an error will be returned instead.
CreateMetricsExporter(ctx context.Context, params ExporterCreateParams,
cfg config.Exporter) (MetricsExporter, error)

// CreateLogsExporter creates an exporter based on the config.
// If the exporter type does not support logs or if the config is not valid
// error will be returned instead.
// If the exporter type does not support logs or if the config is not valid,
// an error will be returned instead.
CreateLogsExporter(ctx context.Context, params ExporterCreateParams,
cfg config.Exporter) (LogsExporter, error)
}
6 changes: 3 additions & 3 deletions component/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ type Extension interface {
type PipelineWatcher interface {
// Ready notifies the Extension that all pipelines were built and the
// receivers were started, i.e.: the service is ready to receive data
// (notice that it may already have received data when this method is called).
// (note that it may already have received data when this method is called).
Ready() error

// NotReady notifies the Extension that all receivers are about to be stopped,
// i.e.: pipeline receivers will not accept new data.
// This is sent before receivers are stopped, so the Extension can take any
// appropriate action before that happens.
// appropriate actions before that happens.
NotReady() error
}

Expand All @@ -65,7 +65,7 @@ type ExtensionFactory interface {
// configuration and should not cause side-effects that prevent the creation
// of multiple instances of the Extension.
// The object returned by this method needs to pass the checks implemented by
// 'configcheck.ValidateConfig'. It is recommended to have such check in the
// 'configcheck.ValidateConfig'. It is recommended to have these checks in the
// tests of any implementation of the Factory interface.
CreateDefaultConfig() config.Extension

Expand Down
8 changes: 4 additions & 4 deletions component/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ type Host interface {

// GetExtensions returns the map of extensions. Only enabled and created extensions will be returned.
// Typically is used to find an extension by type or by full config name. Both cases
// can be done by iterating the returned map. There are typically very few extensions
// so there there is no performance implications due to iteration.
// can be done by iterating the returned map. There are typically very few extensions,
// so there are no performance implications due to iteration.
//
// GetExtensions can be called by the component anytime after Component.Start() begins and
// until Component.Shutdown() ends.
GetExtensions() map[config.ComponentID]Extension

// GetExporters returns the map of exporters. Only enabled and created exporters will be returned.
// Typically is used to find exporters by type or by full config name. Both cases
// can be done by iterating the returned map. There are typically very few exporters
// so there there is no performance implications due to iteration.
// can be done by iterating the returned map. There are typically very few exporters,
// so there are no performance implications due to iteration.
// This returns a map by DataType of maps by exporter configs to the exporter instance.
// Note that an exporter with the same name may be attached to multiple pipelines and
// thus we may have an instance of the exporter for multiple data types.
Expand Down
26 changes: 13 additions & 13 deletions component/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type ProcessorCreateParams struct {
// ProcessorFactory is factory interface for processors. This is the
// new factory type that can create new style processors.
//
// This interface cannot be directly implemented, implementations need to embed
// This interface cannot be directly implemented. Implementations need to embed
// the BaseProcessorFactory or use the processorhelper.NewFactory to implement it.
type ProcessorFactory interface {
Factory
Expand All @@ -71,13 +71,13 @@ type ProcessorFactory interface {
// configuration and should not cause side-effects that prevent the creation
// of multiple instances of the Processor.
// The object returned by this method needs to pass the checks implemented by
// 'configcheck.ValidateConfig'. It is recommended to have such check in the
// 'configcheck.ValidateConfig'. It is recommended to have these checks in the
// tests of any implementation of the Factory interface.
CreateDefaultConfig() config.Processor

// CreateTracesProcessor creates a trace processor based on this config.
// If the processor type does not support tracing or if the config is not valid
// error will be returned instead.
// If the processor type does not support tracing or if the config is not valid,
// an error will be returned instead.
CreateTracesProcessor(
ctx context.Context,
params ProcessorCreateParams,
Expand All @@ -86,8 +86,8 @@ type ProcessorFactory interface {
) (TracesProcessor, error)

// CreateMetricsProcessor creates a metrics processor based on this config.
// If the processor type does not support metrics or if the config is not valid
// error will be returned instead.
// If the processor type does not support metrics or if the config is not valid,
// an error will be returned instead.
CreateMetricsProcessor(
ctx context.Context,
params ProcessorCreateParams,
Expand All @@ -96,8 +96,8 @@ type ProcessorFactory interface {
) (MetricsProcessor, error)

// CreateLogsProcessor creates a processor based on the config.
// If the processor type does not support logs or if the config is not valid
// error will be returned instead.
// If the processor type does not support logs or if the config is not valid,
// an error will be returned instead.
CreateLogsProcessor(
ctx context.Context,
params ProcessorCreateParams,
Expand All @@ -114,27 +114,27 @@ type BaseProcessorFactory struct{}

var _ ProcessorFactory = (*BaseProcessorFactory)(nil)

// Type must be override.
// Type must be overridden.
func (b BaseProcessorFactory) Type() config.Type {
panic("implement me")
}

// CreateDefaultConfig must be override.
// CreateDefaultConfig must be overridden.
func (b BaseProcessorFactory) CreateDefaultConfig() config.Processor {
panic("implement me")
}

// CreateTracesProcessor default implemented as not supported date type.
// CreateTracesProcessor default implemented as not supported data type.
func (b BaseProcessorFactory) CreateTracesProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Traces) (TracesProcessor, error) {
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateMetricsProcessor default implemented as not supported date type.
// CreateMetricsProcessor default implemented as not supported data type.
func (b BaseProcessorFactory) CreateMetricsProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Metrics) (MetricsProcessor, error) {
return nil, componenterror.ErrDataTypeIsNotSupported
}

// CreateLogsProcessor default implemented as not supported date type.
// CreateLogsProcessor default implemented as not supported data type.
func (b BaseProcessorFactory) CreateLogsProcessor(context.Context, ProcessorCreateParams, config.Processor, consumer.Logs) (LogsProcessor, error) {
return nil, componenterror.ErrDataTypeIsNotSupported
}
Expand Down
10 changes: 5 additions & 5 deletions component/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type ReceiverCreateParams struct {
// component to be used later as well.
Logger *zap.Logger

// BuildInfo can be used by components for informational purposes
// BuildInfo can be used by components for informational purposes.
BuildInfo BuildInfo
}

Expand All @@ -75,25 +75,25 @@ type ReceiverFactory interface {
// configuration and should not cause side-effects that prevent the creation
// of multiple instances of the Receiver.
// The object returned by this method needs to pass the checks implemented by
// 'configcheck.ValidateConfig'. It is recommended to have such check in the
// 'configcheck.ValidateConfig'. It is recommended to have these checks in the
// tests of any implementation of the Factory interface.
CreateDefaultConfig() config.Receiver

// CreateTracesReceiver creates a trace receiver based on this config.
// If the receiver type does not support tracing or if the config is not valid
// error will be returned instead.
// an error will be returned instead.
CreateTracesReceiver(ctx context.Context, params ReceiverCreateParams,
cfg config.Receiver, nextConsumer consumer.Traces) (TracesReceiver, error)

// CreateMetricsReceiver creates a metrics receiver based on this config.
// If the receiver type does not support metrics or if the config is not valid
// error will be returned instead.
// an error will be returned instead.
CreateMetricsReceiver(ctx context.Context, params ReceiverCreateParams,
cfg config.Receiver, nextConsumer consumer.Metrics) (MetricsReceiver, error)

// CreateLogsReceiver creates a log receiver based on this config.
// If the receiver type does not support the data type or if the config is not valid
// error will be returned instead.
// an error will be returned instead.
CreateLogsReceiver(ctx context.Context, params ReceiverCreateParams,
cfg config.Receiver, nextConsumer consumer.Logs) (LogsReceiver, error)
}