Implements: ReferencesDecorator
Description
The ManagedReferences class allows you to create managed references that in additon to keeping and locating references can also manage their lifecycle, such as:
- Auto-creation of missing components using available factories
 - Auto-linking newly added components
 - Auto-opening newly added components
 - Auto-closing removed components
 
Constructors
NewManagedReferences
Creates a new instance of the decorator.
NewManagedReferences(ctx context.Context, tuples []any) *ManagedReferences
- ctx: context.Context - operation context.
 - tuples: []any - tuples where odd values are component locators (descriptors) and even values are component references
 
NewEmptyManagedReferences
Creates a new instance of the references
NewEmptyManagedReferences() *ManagedReferences
NewEmptyManagedReferences
Creates a new instance of the references
NewEmptyManagedReferences() *ManagedReferences
NewManagedReferencesFromTuples
Removes all component references that match the specified locator.
NewManagedReferencesFromTuples(ctx context.Context, tuples …any) *ManagedReferences
- ctx: context.Context - operation cotext.
 - locator: …any - locator to remove references by.
 - returns: ManagedReferences - list containing all removed references.
 
Methods
Close
Closes the component and frees used resources.
(c *ManagedReferences) Close(ctx context.Context, correlationId string) error
- ctx: context.Context - operation cotext.
 - correlationId: string - (optional) transaction id used to trace execution through the call chain.
 - retunrs: error - returns error if not closed
 
IsOpen
Checks if the component is open.
(c *ManagedReferences) IsOpen() bool
- returns: bool - True if the component is open and False otherwise.
 
Open
Opens the component.
(c *ManagedReferences) Open(ctx context.Context, correlationId string) error
- ctx: context.Context - operation cotext.
 - correlationId: string - (optional) transaction id used to trace execution through the call chain.
 - returns: error - return error if not opened