ioc

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterWithGroup

func RegisterWithGroup(groupCreation any, groupName string, groupType any) any

RegisterWithGroup registers a constructor with a group name and type. This is useful for grouping constructors together.

Parameters:

  • groupCreation: the constructor to register. This should be a function that returns an instance of the group type given in the groupType parameter.
  • groupName: the name of the group to register the constructor with.
  • groupType: the type of the group to register the constructor with. This should be an interface type.

Returns:

  • the constructor annotated with the group name and type.

Example:

 fx.Provide(
	    ioc.RegisterWithGroup(NewGroup, "my-group", new(MyGroup)),
 )

func RegisterWithName

func RegisterWithName(constructor any, name ...string) any

RegisterWithName registers a constructor with a name and parameters. This is useful for providing multiple instances of the same type.

Parameters:

  • constructor: The constructor to register, should be a function that returns an instance of the type to register.
  • name: The unique name used to register with container.

Returns:

  • the constructor annotated with the name and parameters.

Example:

 fx.Provide(
	    ioc.RegisterWithName(NewService, "service1"),
	    ioc.RegisterWithName(NewService, "service2"),
 )

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL