old_mixer_repo icon indicating copy to clipboard operation
old_mixer_repo copied to clipboard

Make the new adapter interface consistent

Open ZackButcher opened this issue 7 years ago • 4 comments

Today we have these two methods:

// map name->Type
ConfigureFooHandler(map[string]*foo.Type) error
// foo.Instance has a "Name" field
HandleFoo(context.Context, []*foo.Instance) error

We should be consistent, either: A) foo.Type needs a Name field

// foo.Type has a "Name" field
ConfigureFooHandler([]*foo.Type) error
// foo.Instance has a "Name" field
HandleFoo(context.Context, []*foo.Instance) error

B) We pull the Name field out of foo.Instance

// map name->Type
ConfigureFooHandler(map[string]*foo.Type) error
// map name->Instance
HandleFoo(context.Context, map[string][]*foo.Instance) error

As-is the asymmetry feels inconsistent.

cc @guptasu @geeknoid

ZackButcher avatar Aug 24 '17 20:08 ZackButcher

The second form would need to be:

HandleFoo(context.Context, map[string][]*foo.Instance)

since there can be multiple instances for a given type.

geeknoid avatar Aug 25 '17 12:08 geeknoid

I disagree that there is an issue here. The data being provided is in the most directly meaningful form for the adapter author.

I do think we should add a Name field to the Type objects such that Type objects can be self-contained.

geeknoid avatar Aug 25 '17 12:08 geeknoid

Can this be closed?

geeknoid avatar Oct 24 '17 22:10 geeknoid

We need to add Name to Type too. I need to fix that.

guptasu avatar Oct 24 '17 22:10 guptasu