Skip to content

Commit 3b13923

Browse files
Clarify Component lifecycle (#2757)
This clarifies the phases of the lifecycle of Component.
1 parent 42422ff commit 3b13923

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

component/component.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ import (
2424

2525
// Component is either a receiver, exporter, processor or extension.
2626
type Component interface {
27+
// Components lifecycle goes through the following phases:
28+
//
29+
// 1. Creation. The component is created using the factory, via Create* call.
30+
// 2. Start. The component's Start() method is called.
31+
// 3. Running. The component is up and running.
32+
// 4. Shutdown. The component's Shutdown() method is called, the lifecycle is complete.
33+
//
34+
// Once the lifecycle is complete it may be repeated, in which case a new component
35+
// is created and goes through the lifecycle.
36+
2737
// Start tells the component to start. Host parameter can be used for communicating
2838
// with the host after Start() has already returned. If error is returned by
2939
// Start() then the collector startup will be aborted.
@@ -44,6 +54,11 @@ type Component interface {
4454
// Remember that if you started any long-running background operation from the Start() method that operation
4555
// must be also cancelled. If there are any buffer in the component, it should be cleared and the data sent
4656
// immediately to the next component.
57+
//
58+
// Once the Shutdown() method returns the component's lifecycle is completed. No other
59+
// methods of the component are called after that. If necessary a new component with
60+
// the same or different configuration may be created and started (this may happen
61+
// for example if we want to restart the component).
4762
Shutdown(ctx context.Context) error
4863
}
4964

0 commit comments

Comments
 (0)