Package com.google.genkit.core
Class DefaultRegistry
java.lang.Object
com.google.genkit.core.DefaultRegistry
- All Implemented Interfaces:
Registry
DefaultRegistry is the default implementation of the Registry interface. It
provides thread-safe storage and lookup of Genkit primitives.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new root registry.DefaultRegistry(Registry parent) Creates a new child registry with the given parent. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisChild()Returns true if this registry is a child of another registry.Returns a list of all registered actions.listActions(ActionType type) Returns a list of all registered actions of the specified type.Returns a list of all registered plugins.Returns a map of all registered values.Action<?, ?, ?> lookupAction(String key) Returns the action for the given key.lookupHelper(String name) Returns a registered helper by name.lookupPartial(String name) Returns a registered partial by name.lookupPlugin(String name) Returns the plugin for the given name.lookupSchema(String name) Returns a JSON schema for the given name.lookupValue(String name) Returns the value for the given name.newChild()Creates a new child registry that inherits from this registry.voidregisterAction(String key, Action<?, ?, ?> action) Records the action in the registry.voidregisterHelper(String name, Object helper) Registers a helper function for use with prompts.voidregisterPartial(String name, String source) Registers a partial template for use with prompts.voidregisterPlugin(String name, Plugin plugin) Records the plugin in the registry.voidregisterSchema(String name, Map<String, Object> schema) Records a JSON schema in the registry.voidregisterValue(String name, Object value) Records an arbitrary value in the registry.Action<?, ?, ?> resolveAction(String key) Looks up an action by key.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.genkit.core.Registry
lookupAction, registerAction, resolveAction
-
Constructor Details
-
DefaultRegistry
public DefaultRegistry()Creates a new root registry. -
DefaultRegistry
Creates a new child registry with the given parent.- Parameters:
parent- the parent registry, or null for a root registry
-
-
Method Details
-
newChild
Description copied from interface:RegistryCreates a new child registry that inherits from this registry. Child registries are useful for scoped operations and will fall back to the parent for lookups if a value is not found in the child. -
isChild
public boolean isChild()Description copied from interface:RegistryReturns true if this registry is a child of another registry. -
registerPlugin
Description copied from interface:RegistryRecords the plugin in the registry.- Specified by:
registerPluginin interfaceRegistry- Parameters:
name- the plugin nameplugin- the plugin to register
-
registerAction
Description copied from interface:RegistryRecords the action in the registry.- Specified by:
registerActionin interfaceRegistry- Parameters:
key- the action key (type + name)action- the action to register
-
registerValue
Description copied from interface:RegistryRecords an arbitrary value in the registry.- Specified by:
registerValuein interfaceRegistry- Parameters:
name- the value namevalue- the value to register
-
registerSchema
Description copied from interface:RegistryRecords a JSON schema in the registry.- Specified by:
registerSchemain interfaceRegistry- Parameters:
name- the schema nameschema- the schema as a map
-
lookupPlugin
Description copied from interface:RegistryReturns the plugin for the given name. It first checks the current registry, then falls back to the parent if not found.- Specified by:
lookupPluginin interfaceRegistry- Parameters:
name- the plugin name- Returns:
- the plugin, or null if not found
-
lookupAction
Description copied from interface:RegistryReturns the action for the given key. It first checks the current registry, then falls back to the parent if not found.- Specified by:
lookupActionin interfaceRegistry- Parameters:
key- the action key- Returns:
- the action, or null if not found
-
lookupValue
Description copied from interface:RegistryReturns the value for the given name. It first checks the current registry, then falls back to the parent if not found.- Specified by:
lookupValuein interfaceRegistry- Parameters:
name- the value name- Returns:
- the value, or null if not found
-
lookupSchema
Description copied from interface:RegistryReturns a JSON schema for the given name. It first checks the current registry, then falls back to the parent if not found.- Specified by:
lookupSchemain interfaceRegistry- Parameters:
name- the schema name- Returns:
- the schema as a map, or null if not found
-
resolveAction
Description copied from interface:RegistryLooks up an action by key. If the action is not found, it attempts dynamic resolution through registered dynamic plugins.- Specified by:
resolveActionin interfaceRegistry- Parameters:
key- the action key- Returns:
- the action if found, or null if not found
-
listActions
Description copied from interface:RegistryReturns a list of all registered actions. This includes actions from both the current registry and its parent hierarchy.- Specified by:
listActionsin interfaceRegistry- Returns:
- list of all registered actions
-
listActions
Description copied from interface:RegistryReturns a list of all registered actions of the specified type.- Specified by:
listActionsin interfaceRegistry- Parameters:
type- the action type to filter by- Returns:
- list of actions of the specified type
-
listPlugins
Description copied from interface:RegistryReturns a list of all registered plugins.- Specified by:
listPluginsin interfaceRegistry- Returns:
- list of all registered plugins
-
listValues
Description copied from interface:RegistryReturns a map of all registered values.- Specified by:
listValuesin interfaceRegistry- Returns:
- map of all registered values
-
registerPartial
Description copied from interface:RegistryRegisters a partial template for use with prompts.- Specified by:
registerPartialin interfaceRegistry- Parameters:
name- the partial namesource- the partial template source
-
registerHelper
Description copied from interface:RegistryRegisters a helper function for use with prompts.- Specified by:
registerHelperin interfaceRegistry- Parameters:
name- the helper namehelper- the helper function
-
lookupPartial
Description copied from interface:RegistryReturns a registered partial by name.- Specified by:
lookupPartialin interfaceRegistry- Parameters:
name- the partial name- Returns:
- the partial source, or null if not found
-
lookupHelper
Description copied from interface:RegistryReturns a registered helper by name.- Specified by:
lookupHelperin interfaceRegistry- Parameters:
name- the helper name- Returns:
- the helper function, or null if not found
-