Package org.bsc.langgraph4j.checkpoint
Class AbstractMysqlServer
java.lang.Object
org.bsc.langgraph4j.checkpoint.AbstractCheckpointSaver
org.bsc.langgraph4j.checkpoint.AbstractMysqlServer
- All Implemented Interfaces:
BaseCheckpointSaver,LG4JLoggable
- Direct Known Subclasses:
MysqlSaver
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA builder for MysqlSaver.Nested classes/interfaces inherited from interface org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver
BaseCheckpointSaver.SubGraphSaver, BaseCheckpointSaver.Tag -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CreateOptionprotected final DataSourceprotected final com.fasterxml.jackson.databind.ObjectMapperprotected final SqlResource.Commandsprotected final StateSerializer<? extends AgentState>Fields inherited from interface org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver
THREAD_ID_DEFAULTFields inherited from interface org.bsc.langgraph4j.LG4JLoggable
log -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotected constructor used by the builder to create a new instance of MysqlSaver. -
Method Summary
Modifier and TypeMethodDescriptionclearCheckpointsCache(String threadId) Deprecated, for removal: This API element is subject to removal in a future version.this method do nothing because currently this saver don't use cache anymoreprotected voidInitializes the database according the create options.protected voidinsertedCheckpoint(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Checkpoint checkpoint) Inserts a checkpoint to the databaseprotected LinkedList<Checkpoint>loadCheckpoints(RunnableConfig config) If the list of checkpoints is empty, loads the checkpoints from the database.<State extends AgentState>
CompletableFuture<InterruptionMetadata<State>>registerInterruption(RunnableConfig config, InterruptionMetadata<State> interruptionMetadata) Register Interrupt of the execution for the given config and provide interruption metadata.protected BaseCheckpointSaver.TagreleaseCheckpoints(RunnableConfig config, LinkedList<Checkpoint> checkpoints, String message) Marks the checkpoints as releasedprotected BaseCheckpointSaver.TagreleaseCheckpointsOnError(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Exception exception) tag(RunnableConfig config, Integer version) protected voidupdatedCheckpoint(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Checkpoint checkpoint) If the checkpoint exists, updates the checkpoint, otherwise it inserts it.Methods inherited from class org.bsc.langgraph4j.checkpoint.AbstractCheckpointSaver
get, list, listSubGraphSaver, put, putSubGraphSaver, release, release, releaseOnErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bsc.langgraph4j.checkpoint.BaseCheckpointSaver
lastTag, threadId
-
Field Details
-
dataSource
-
createOption
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper -
stateSerializer
-
sqlCommands
-
-
Constructor Details
-
AbstractMysqlServer
protected constructor used by the builder to create a new instance of MysqlSaver.- Parameters:
builder- Builder instance- Throws:
Exception
-
-
Method Details
-
initTables
Initializes the database according the create options.- Throws:
Exception
-
loadCheckpoints
If the list of checkpoints is empty, loads the checkpoints from the database.- Specified by:
loadCheckpointsin classAbstractCheckpointSaver- Parameters:
config- the configuration- Returns:
- a list of checkpoints
- Throws:
Exception- if an error occurs while the checkpoints are being loaded from the database.
-
insertedCheckpoint
protected void insertedCheckpoint(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Checkpoint checkpoint) throws Exception Inserts a checkpoint to the database- Specified by:
insertedCheckpointin classAbstractCheckpointSaver- Parameters:
config- the configurationcheckpoints- the list of checkpointscheckpoint- the checkpoint to insert- Throws:
Exception- if an error occurs while inserting the checkpoint in the database.
-
releaseCheckpoints
protected BaseCheckpointSaver.Tag releaseCheckpoints(RunnableConfig config, LinkedList<Checkpoint> checkpoints, String message) throws Exception Marks the checkpoints as released- Specified by:
releaseCheckpointsin classAbstractCheckpointSaver- Parameters:
config- the configurationcheckpoints- the checkpoints- Throws:
Exception- if an error occurs while marking the checkpoints as released
-
releaseCheckpointsOnError
protected BaseCheckpointSaver.Tag releaseCheckpointsOnError(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Exception exception) throws Exception - Specified by:
releaseCheckpointsOnErrorin classAbstractCheckpointSaver- Throws:
Exception
-
registerInterruption
public <State extends AgentState> CompletableFuture<InterruptionMetadata<State>> registerInterruption(RunnableConfig config, InterruptionMetadata<State> interruptionMetadata) Description copied from interface:BaseCheckpointSaverRegister Interrupt of the execution for the given config and provide interruption metadata. this is used internally and should not be called directly by the user.- Specified by:
registerInterruptionin interfaceBaseCheckpointSaver- Parameters:
config- the RunnableConfig for which to register the interruptioninterruptionMetadata- the metadata associated with the interruption
-
tag
public Optional<BaseCheckpointSaver.Tag> tag(RunnableConfig config, Integer version) throws Exception - Specified by:
tagin interfaceBaseCheckpointSaver- Throws:
Exception
-
updatedCheckpoint
protected void updatedCheckpoint(RunnableConfig config, LinkedList<Checkpoint> checkpoints, Checkpoint checkpoint) throws Exception If the checkpoint exists, updates the checkpoint, otherwise it inserts it.- Specified by:
updatedCheckpointin classAbstractCheckpointSaver- Parameters:
config- the configurationcheckpoints- the list of checkpointscheckpoint- the checkpoint- Throws:
Exception- if an error occurs while inserting or updating the checkpoint.
-
clearCheckpointsCache
Deprecated, for removal: This API element is subject to removal in a future version.this method do nothing because currently this saver don't use cache anymoreRemoves the cached checkpoints associated with the given thread identifier from the in-memory cache.- Parameters:
threadId- the thread identifier whose cached checkpoints must be cleared- Returns:
- the checkpoints removed from the cache, or an empty collection if no cached checkpoints exist
-