MCPcopy Create free account
hub / github.com/codnect/procyon / Singleton

Method Singleton

component/container.go:227–236  ·  view source on GitHub ↗

Singleton retrieves the singleton instance associated with the given name. Returns the instance and a boolean indicating its existence.

(name string)

Source from the content-addressed store, hash-verified

225// Singleton retrieves the singleton instance associated with the given name.
226// Returns the instance and a boolean indicating its existence.
227func (d *DefaultContainer) Singleton(name string) (any, bool) {
228 d.muSingletons.Lock()
229 defer d.muSingletons.Unlock()
230
231 if singleton, exists := d.singletons[name]; exists {
232 return singleton, true
233 }
234
235 return nil, false
236}
237
238// RemoveSingleton removes the singleton instance associated with the specified name.
239func (d *DefaultContainer) RemoveSingleton(name string) error {

Callers 2

ResolveMethod · 0.95

Calls

no outgoing calls

Tested by 1