Skip to content

Add dig.Name() decorator option #439

Description

@seanlafferty-ibm

Is your feature request related to a problem? Please describe.
I have multiple named providers of the same type, and I'd like to decorate one of them

c.Provide(NewReadOnlyConnection, dig.Name("ro"))
c.Provide(NewReadWriteConnection, dig.Name("rw"))

However the decorate function doesn't have an option to target these

dig/decorate.go

Lines 159 to 162 in c8eb7b9

// DecorateOption modifies the default behavior of Decorate.
type DecorateOption interface {
apply(*decorateOptions)
}

I use this mainly for tests- replacing certain dependencies with test versions.

Is there a non-obvious way to do this? I couldn't find an example in the unit tests.

Is this a breaking change?
No, we could create a new DecorateOption

Ran into this when looking into #230

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions