Package dev.agenor.core.annotations
Annotation Interface PersistenceConfig
Configures the persistence behavior for an agent class.
Place this annotation on any class that extends BaseAgent to control
when the runtime saves the fields marked with Persist
and how snapshots are managed.
Example — periodic auto-save every 30 seconds
@Agent("order-processor")
@PersistenceConfig(
strategy = PersistenceStrategy.PERIODIC,
interval = "30s"
)
public class OrderProcessorAgent extends BaseAgent {
@Persist(required = true)
private String currentOrderId;
@Persist
private int retryCount = 0;
}
Example — save on stop and hourly snapshots, keep last 24
@PersistenceConfig(
strategy = PersistenceStrategy.ON_STOP,
autoSnapshot = true,
snapshotInterval = "1h",
maxSnapshots = 24
)
public class CriticalAgent extends BaseAgent { ... }
When this annotation is absent the agent uses PersistenceStrategy.MANUAL
(no automatic persistence; the agent must call persistState() explicitly).
- Since:
- 0.2.0
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhentrue, the runtime creates point-in-time snapshots on the schedule defined bysnapshotInterval().Save interval used byPersistenceStrategy.PERIODICandPersistenceStrategy.DEBOUNCED.intMaximum number of automatic snapshots to retain.How often an automatic snapshot is taken.Determines when the runtime automatically saves agent state.
-
Element Details
-
strategy
PersistenceStrategy strategyDetermines when the runtime automatically saves agent state. Defaults toPersistenceStrategy.MANUAL— the agent is responsible for callingpersistState()at the appropriate time.- Default:
MANUAL
-
interval
String intervalSave interval used byPersistenceStrategy.PERIODICandPersistenceStrategy.DEBOUNCED. Accepts human-readable durations such as"30s","5m","1h". Ignored for other strategies.- Default:
"60s"
-
autoSnapshot
boolean autoSnapshotWhentrue, the runtime creates point-in-time snapshots on the schedule defined bysnapshotInterval(). Snapshots allow rolling back to a previous state independently of the normal save cycle.- Default:
false
-
snapshotInterval
String snapshotIntervalHow often an automatic snapshot is taken. Accepts human-readable durations such as"1h","1d". Only relevant whenautoSnapshot()istrue.- Default:
"1h"
-
maxSnapshots
int maxSnapshotsMaximum number of automatic snapshots to retain. Older snapshots are deleted once this limit is exceeded (FIFO eviction).- Default:
10
-