Skip to content

Commit 827f5e1

Browse files
Standarize Settings, Params and Parameters in Extensions (#3294)
* Replace ExtensionCreateParams with ExtensionCreateSettings. Replace all dependencies in Extensions. Signed-off-by: Patryk Matyjasek <[email protected]> * Update changelog Signed-off-by: Patryk Matyjasek <[email protected]> # Conflicts: # CHANGELOG.md * Add missing files Signed-off-by: Patryk Matyjasek <[email protected]>
1 parent 146973f commit 827f5e1

File tree

22 files changed

+39
-38
lines changed

22 files changed

+39
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Remove unused testutil.TempSocketName (#3291)
1010
- Move BigEndian helper functions in `tracetranslator` to an internal package.(#3298)
1111
- Rename `configtest.LoadConfigFile` to `configtest.LoadConfigAndValidate` (#3306)
12+
- Replace `ExtensionCreateParams` with `ExtensionCreateSettings` (#3294)
1213

1314
## 💡 Enhancements 💡
1415

component/componenttest/nop_extension.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (f *nopExtensionFactory) CreateDefaultConfig() config.Extension {
5151
// CreateExtension implements component.ExtensionFactory interface.
5252
func (f *nopExtensionFactory) CreateExtension(
5353
_ context.Context,
54-
_ component.ExtensionCreateParams,
54+
_ component.ExtensionCreateSettings,
5555
_ config.Extension,
5656
) (component.Extension, error) {
5757
return nopExtensionInstance, nil

component/componenttest/nop_extension_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestNewNopExtensionFactory(t *testing.T) {
3232
cfg := factory.CreateDefaultConfig()
3333
assert.Equal(t, &nopExtensionConfig{ExtensionSettings: config.NewExtensionSettings(config.NewID("nop"))}, cfg)
3434

35-
traces, err := factory.CreateExtension(context.Background(), component.ExtensionCreateParams{}, cfg)
35+
traces, err := factory.CreateExtension(context.Background(), component.ExtensionCreateSettings{}, cfg)
3636
require.NoError(t, err)
3737
assert.NoError(t, traces.Start(context.Background(), NewNopHost()))
3838
assert.NoError(t, traces.Shutdown(context.Background()))

component/extension.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type PipelineWatcher interface {
4646
NotReady() error
4747
}
4848

49-
// ExtensionCreateParams is passed to ExtensionFactory.Create* functions.
50-
type ExtensionCreateParams struct {
49+
// ExtensionCreateSettings is passed to ExtensionFactory.Create* functions.
50+
type ExtensionCreateSettings struct {
5151
// Logger that the factory can use during creation and can pass to the created
5252
// component to be used later as well.
5353
Logger *zap.Logger
@@ -70,5 +70,5 @@ type ExtensionFactory interface {
7070
CreateDefaultConfig() config.Extension
7171

7272
// CreateExtension creates a service extension based on the given config.
73-
CreateExtension(ctx context.Context, params ExtensionCreateParams, cfg config.Extension) (Extension, error)
73+
CreateExtension(ctx context.Context, set ExtensionCreateSettings, cfg config.Extension) (Extension, error)
7474
}

config/configcheck/configcheck_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,6 @@ func (b badConfigExtensionFactory) CreateDefaultConfig() config.Extension {
198198
}{}
199199
}
200200

201-
func (b badConfigExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateParams, _ config.Extension) (component.Extension, error) {
201+
func (b badConfigExtensionFactory) CreateExtension(_ context.Context, _ component.ExtensionCreateSettings, _ config.Extension) (component.Extension, error) {
202202
return nil, nil
203203
}

extension/ballastextension/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ func createDefaultConfig() config.Extension {
4141
}
4242
}
4343

44-
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg config.Extension) (component.Extension, error) {
45-
return newMemoryBallast(cfg.(*Config), params.Logger), nil
44+
func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg config.Extension) (component.Extension, error) {
45+
return newMemoryBallast(cfg.(*Config), set.Logger), nil
4646
}

extension/ballastextension/factory_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ func TestFactory_CreateDefaultConfig(t *testing.T) {
3232
assert.Equal(t, &Config{ExtensionSettings: config.NewExtensionSettings(config.NewID(typeStr))}, cfg)
3333

3434
assert.NoError(t, configcheck.ValidateConfig(cfg))
35-
ext, err := createExtension(context.Background(), component.ExtensionCreateParams{Logger: zap.NewNop()}, cfg)
35+
ext, err := createExtension(context.Background(), component.ExtensionCreateSettings{Logger: zap.NewNop()}, cfg)
3636
require.NoError(t, err)
3737
require.NotNil(t, ext)
3838
}
3939

4040
func TestFactory_CreateExtension(t *testing.T) {
4141
cfg := createDefaultConfig().(*Config)
42-
ext, err := createExtension(context.Background(), component.ExtensionCreateParams{Logger: zap.NewNop()}, cfg)
42+
ext, err := createExtension(context.Background(), component.ExtensionCreateSettings{Logger: zap.NewNop()}, cfg)
4343
require.NoError(t, err)
4444
require.NotNil(t, ext)
4545
}

extension/extensionhelper/factory.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type FactoryOption func(o *factory)
2828
type CreateDefaultConfig func() config.Extension
2929

3030
// CreateServiceExtension is the equivalent of component.ExtensionFactory.CreateExtension()
31-
type CreateServiceExtension func(context.Context, component.ExtensionCreateParams, config.Extension) (component.Extension, error)
31+
type CreateServiceExtension func(context.Context, component.ExtensionCreateSettings, config.Extension) (component.Extension, error)
3232

3333
type factory struct {
3434
cfgType config.Type
@@ -66,7 +66,7 @@ func (f *factory) CreateDefaultConfig() config.Extension {
6666
// CreateExtension creates a component.TraceExtension based on this config.
6767
func (f *factory) CreateExtension(
6868
ctx context.Context,
69-
params component.ExtensionCreateParams,
69+
set component.ExtensionCreateSettings,
7070
cfg config.Extension) (component.Extension, error) {
71-
return f.createServiceExtension(ctx, params, cfg)
71+
return f.createServiceExtension(ctx, set, cfg)
7272
}

extension/extensionhelper/factory_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestNewFactory(t *testing.T) {
3838
createExtension)
3939
assert.EqualValues(t, typeStr, factory.Type())
4040
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
41-
ext, err := factory.CreateExtension(context.Background(), component.ExtensionCreateParams{}, &defaultCfg)
41+
ext, err := factory.CreateExtension(context.Background(), component.ExtensionCreateSettings{}, &defaultCfg)
4242
assert.NoError(t, err)
4343
assert.Same(t, nopExtensionInstance, ext)
4444
}
@@ -47,7 +47,7 @@ func defaultConfig() config.Extension {
4747
return &defaultCfg
4848
}
4949

50-
func createExtension(context.Context, component.ExtensionCreateParams, config.Extension) (component.Extension, error) {
50+
func createExtension(context.Context, component.ExtensionCreateSettings, config.Extension) (component.Extension, error) {
5151
return nopExtensionInstance, nil
5252
}
5353

extension/healthcheckextension/factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ func createDefaultConfig() config.Extension {
4949
}
5050
}
5151

52-
func createExtension(_ context.Context, params component.ExtensionCreateParams, cfg config.Extension) (component.Extension, error) {
52+
func createExtension(_ context.Context, set component.ExtensionCreateSettings, cfg config.Extension) (component.Extension, error) {
5353
config := cfg.(*Config)
5454

55-
return newServer(*config, params.Logger), nil
55+
return newServer(*config, set.Logger), nil
5656
}

0 commit comments

Comments
 (0)