forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.go
46 lines (36 loc) · 1.25 KB
/
factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package ackextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension"
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/ackextension/internal/metadata"
)
var defaultStorageType = (*component.ID)(nil)
const (
defaultMaxNumPartition uint64 = 1_000_000
defaultMaxNumPendingAcksPerPartition uint64 = 1_000_000
)
// NewFactory creates a factory for ack extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
createDefaultConfig,
createExtension,
metadata.ExtensionStability,
)
}
func createDefaultConfig() component.Config {
return &Config{
StorageID: defaultStorageType,
MaxNumPartition: defaultMaxNumPartition,
MaxNumPendingAcksPerPartition: defaultMaxNumPendingAcksPerPartition,
}
}
func createExtension(_ context.Context, _ extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
if cfg.(*Config).StorageID == nil {
return newInMemoryAckExtension(cfg.(*Config)), nil
}
return nil, nil
}