MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / bracket_bridge_transaction

Function bracket_bridge_transaction

atomic-agent/src/watcher/bridge.rs:76–107  ·  view source on GitHub ↗

Synchronous bracket for CLI bridge commands. Creates the best available watcher, enters `atomic-bridge` with the journaled operation ID, runs `body`, and leaves the state on success and failure alike. Writes performed inside the span are suppressed, so the bridge's own Git writes never trigger a self-reconciliation loop.

(
    config: WatcherConfig,
    operation_id: &str,
    body: impl FnOnce() -> Result<T, E>,
)

Source from the content-addressed store, hash-verified

74/// failure alike. Writes performed inside the span are suppressed, so the
75/// bridge's own Git writes never trigger a self-reconciliation loop.
76pub fn bracket_bridge_transaction<T, E>(
77 config: WatcherConfig,
78 operation_id: &str,
79 body: impl FnOnce() -> Result<T, E>,
80) -> Result<T, E> {
81 let runtime = match tokio::runtime::Builder::new_current_thread()
82 .enable_all()
83 .build()
84 {
85 Ok(runtime) => runtime,
86 Err(error) => {
87 log::warn!(
88 "could not create the atomic-bridge watcher runtime: {error}; \
89 continuing without the optional accelerator"
90 );
91 return body();
92 }
93 };
94 runtime.block_on(async {
95 let mut watcher = match create_watcher(config).await {
96 Ok(watcher) => watcher,
97 Err(error) => {
98 log::warn!(
99 "could not create the file watcher for atomic-bridge: {error}; \
100 continuing without the optional accelerator"
101 );
102 return body();
103 }
104 };
105 with_bridge_state(&mut *watcher, operation_id, async { body() }).await
106 })
107}
108
109/// Whether the given repo root can open a session-scoped watcher.
110pub fn watcher_config(repo_root: &Path) -> WatcherConfig {

Callers 3

reconcileFunction · 0.85
switchFunction · 0.85
bracket_passFunction · 0.85

Calls 4

bodyFunction · 0.85
create_watcherFunction · 0.85
with_bridge_stateFunction · 0.85
buildMethod · 0.45

Tested by

no test coverage detected