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

Method RegisterScope

component/container.go:445–463  ·  view source on GitHub ↗

RegisterScope adds a new scope with the specified name to the registry.

(name string, scope Scope)

Source from the content-addressed store, hash-verified

443
444// RegisterScope adds a new scope with the specified name to the registry.
445func (d *DefaultContainer) RegisterScope(name string, scope Scope) error {
446 if strings.TrimSpace(name) == "" {
447 return ErrInvalidScopeName
448 }
449
450 if scope == nil {
451 return errors.New("nil scope")
452 }
453
454 if SingletonScope != name && PrototypeScope != name {
455 d.muScopes.Lock()
456 defer d.muScopes.Unlock()
457
458 d.scopes[name] = scope
459 return nil
460 }
461
462 return ErrScopeReplacementNotAllowed
463}
464
465// Scope retrieves the scope associated with the given name.
466// Returns the scope and a boolean indicating its existence.

Calls

no outgoing calls

Tested by 3