pub struct SyncManager { /* private fields */ }Expand description
Manages synchronization with the chainlink/locks coordination branch.
Uses a git worktree at .chainlink/.locks-cache/ to avoid disturbing
the user’s working tree.
Implementations§
Source§impl SyncManager
impl SyncManager
Sourcepub fn new(chainlink_dir: &Path) -> Result<Self>
pub fn new(chainlink_dir: &Path) -> Result<Self>
Create a new SyncManager for the given .chainlink directory.
Sourcepub fn chainlink_dir(&self) -> &Path
pub fn chainlink_dir(&self) -> &Path
Get the path to the .chainlink directory.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the cache directory is initialized.
Sourcepub fn cache_path(&self) -> &Path
pub fn cache_path(&self) -> &Path
Get the path to the cache directory.
Sourcepub fn init_cache(&self) -> Result<()>
pub fn init_cache(&self) -> Result<()>
Initialize the hub cache directory.
If the chainlink/locks branch exists on the remote, fetches it and
creates a worktree. If not, creates an orphan branch with an empty
locks.json.
Sourcepub fn hub_health_check(&self) -> Result<()>
pub fn hub_health_check(&self) -> Result<()>
Detect and recover from broken git states in the hub cache worktree.
Sourcepub fn read_locks(&self) -> Result<LocksFile>
pub fn read_locks(&self) -> Result<LocksFile>
Read the current locks file from the cache.
Sourcepub fn read_keyring(&self) -> Result<Keyring>
pub fn read_keyring(&self) -> Result<Keyring>
Read the trust keyring from the cache.
Sourcepub fn verify_locks_signature(&self) -> Result<GpgVerification>
pub fn verify_locks_signature(&self) -> Result<GpgVerification>
Verify GPG signature on the last commit that touched locks.json.
Sourcepub fn claim_lock(
&self,
agent: &AgentConfig,
issue_id: i64,
branch: Option<&str>,
force: bool,
) -> Result<bool>
pub fn claim_lock( &self, agent: &AgentConfig, issue_id: i64, branch: Option<&str>, force: bool, ) -> Result<bool>
Claim a lock on an issue for the given agent.
Returns Ok(true) if newly claimed, Ok(false) if already held by self.
Fails if locked by another agent (unless force is true for steal).
Sourcepub fn release_lock(
&self,
agent: &AgentConfig,
issue_id: i64,
force: bool,
) -> Result<bool>
pub fn release_lock( &self, agent: &AgentConfig, issue_id: i64, force: bool, ) -> Result<bool>
Release a lock on an issue.
Returns Ok(true) if released, Ok(false) if not locked.
Sourcepub fn push_heartbeat(
&self,
agent: &AgentConfig,
active_issue_id: Option<i64>,
) -> Result<()>
pub fn push_heartbeat( &self, agent: &AgentConfig, active_issue_id: Option<i64>, ) -> Result<()>
Write and push a heartbeat file for this agent.
Sourcepub fn read_heartbeats(&self) -> Result<Vec<Heartbeat>>
pub fn read_heartbeats(&self) -> Result<Vec<Heartbeat>>
Read all heartbeat files from the cache.