Add shutdown signal (#238)

* Add shutdown signal handling

Revert periodic sync interval change

Revert keep-alive interval change

CLI: Add disconnect command

SDK: Add scaffolding for is_started, shutdown()

Simplify instance init

* Rebase on savage-async-ws branch

* Avoid waiting when shutdown signal is received in the sync loop

* Directly use shutdown signal in background threads

* Acquire is_started lock at the very beginning of start()

* Fix cargo clippy warnings

* Update RN generator (kt): set bindingLiquidSdk to null on disconnect()

* Update RN generator (swift): set bindingLiquidSdk to nil on disconnect()

* Startup: only run foreground sync() if this could be the first run

* Start a sync() in background, before regular sync() loop

* Remove ensure_started check from start()

* Add bindings for disconnect()

* Remove foreground sync condition from startup

* Simplify background sync loop
This commit is contained in:
ok300
2024-05-30 08:04:30 +00:00
committed by GitHub
parent e986f75605
commit 434fb80d49
23 changed files with 395 additions and 71 deletions

View File

@@ -254,4 +254,17 @@ class BreezLiquidSDKModule(reactContext: ReactApplicationContext) : ReactContext
}
}
}
@ReactMethod
fun disconnect(promise: Promise) {
executor.execute {
try {
getBindingLiquidSdk().disconnect()
bindingLiquidSdk = null
promise.resolve(readableMapOf("status" to "ok"))
} catch (e: Exception) {
promise.reject(e.javaClass.simpleName.replace("Exception", "Error"), e.message, e)
}
}
}
}