forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b9ebad
commit a47d4cd
Showing
5 changed files
with
224 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package consumer // import "go.opentelemetry.io/collector/consumer" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/pdata/pentity" | ||
) | ||
|
||
// Entities is an interface that receives pentity.Entities, processes it | ||
// as needed, and sends it to the next processing node if any or to the destination. | ||
type Entities interface { | ||
baseConsumer | ||
// ConsumeEntities receives pentity.Entities for consumption. | ||
ConsumeEntities(ctx context.Context, td pentity.Entities) error | ||
} | ||
|
||
// ConsumeEntitiesFunc is a helper function that is similar to ConsumeEntities. | ||
type ConsumeEntitiesFunc func(ctx context.Context, td pentity.Entities) error | ||
|
||
// ConsumeEntities calls f(ctx, td). | ||
func (f ConsumeEntitiesFunc) ConsumeEntities(ctx context.Context, td pentity.Entities) error { | ||
return f(ctx, td) | ||
} | ||
|
||
type baseEntities struct { | ||
*baseImpl | ||
ConsumeEntitiesFunc | ||
} | ||
|
||
// NewEntities returns a Entities configured with the provided options. | ||
func NewEntities(consume ConsumeEntitiesFunc, options ...Option) (Entities, error) { | ||
if consume == nil { | ||
return nil, errNilFunc | ||
} | ||
return &baseEntities{ | ||
baseImpl: newBaseImpl(options...), | ||
ConsumeEntitiesFunc: consume, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters