Clarify that context passed to start should not be reused (#1754)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
This commit is contained in:
Bogdan Drutu 2020-09-11 11:30:32 -07:00 committed by GitHub
parent 49eb327150
commit 0f1d528827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -29,9 +29,19 @@ type Component interface {
// 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.
Start(ctx context.Context, host Host) error
// Shutdown is invoked during service shutdown.
//
// 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.
Shutdown(ctx context.Context) error
}