ServiceFactory

@ExperimentalKmpTorApi
abstract class ServiceFactory(initializer: TorRuntime.ServiceFactory.Initializer) : TorRuntime(source)

An instance of TorRuntime that produces Lifecycle.DestroyableTorRuntime under the hood which are intended to be run within a service object.

NOTE: This and its subclasses are currently marked as ExperimentalKmpTorApi. Things may change (as the annotation states), so use at your own risk! Prefer using the stable implementation via the kmp-tor:runtime-service dependency.

See also

Constructors

Link copied to clipboard
protected constructor(initializer: TorRuntime.ServiceFactory.Initializer)

Types

Link copied to clipboard
@ExperimentalKmpTorApi
interface Binder : RuntimeEvent.Notifier, FileID

Helper for service objects to bind to the ServiceFactory by creating an instance of Lifecycle.DestroyableTorRuntime.

Link copied to clipboard
@ExperimentalKmpTorApi
class Initializer

Single use class for initializing ServiceFactory. Multiples uses will result in IllegalStateException as the ServiceFactory implementation is held as a singleton for the given Environment that it belongs to.

Link copied to clipboard
@ExperimentalKmpTorApi
abstract class Loader

Helper for loading the implementation of ServiceFactory.

Properties

Link copied to clipboard
Link copied to clipboard
override val fid: String

An ID string which is based off of a file path.

Link copied to clipboard
@get:JvmStatic
@get:JvmName(name = "fidEllipses")
val FileID.fidEllipses: String

Returns the first and last 4 characters of the fid concatenated together with an ellipses between.

Functions

Link copied to clipboard
override fun clearObservers()
Link copied to clipboard
override fun enqueue(action: Action, onFailure: OnFailure, onSuccess: OnSuccess<Unit>): EnqueuedJob

Enqueues the Action for execution.

override fun <Success : Any> enqueue(cmd: TorCmd.Unprivileged<Success>, onFailure: OnFailure, onSuccess: OnSuccess<Success>): EnqueuedJob
Link copied to clipboard

Returns the current Environment for this TorRuntime instance.

Link copied to clipboard
override fun isReady(): Boolean

Checks if the tor process backing TorRuntime (if it is running) has completed starting up.

Link copied to clipboard
override fun listeners(): TorListeners

Returns the current TorListeners of this TorRuntime instance.

Link copied to clipboard
@JvmStatic
fun RuntimeEvent.Processor.observeSignalNewNym(tag: String?, executor: OnEvent.Executor?, onEvent: OnEvent<String?>): Disposable.Once

Subscribes with provided TorRuntime a CMD observer which will intercept execution of all TorCmd.Signal.NewNym jobs in order to transform tor's generic server response of Reply.Success.OK.

Link copied to clipboard
protected abstract fun startService()

Called when Action.StartDaemon or Action.RestartDaemon has been enqueued and an instance of Lifecycle.DestroyableTorRuntime does not currently exist for this ServiceFactory.

Link copied to clipboard
override fun state(): TorState

Returns the current TorState of this TorRuntime instance.

Link copied to clipboard
override fun subscribe(observer: RuntimeEvent.Observer<*>)

Add a single Observer.

override fun subscribe(observer: TorEvent.Observer)
override fun subscribe(vararg observers: TorEvent.Observer)

override fun subscribe(vararg observers: RuntimeEvent.Observer<*>)

Add multiple Observer.

Link copied to clipboard
@JvmStatic
@JvmOverloads
@JvmName(name = "fidString")
fun FileID.toFIDString(defaultClassName: String = "Unknown", includeHashCode: Boolean = true): String

Helper for overriding a class's toString function.

Link copied to clipboard
override fun unsubscribe(observer: RuntimeEvent.Observer<*>)

Remove a single Observer.

override fun unsubscribe(observer: TorEvent.Observer)
override fun unsubscribe(vararg observers: TorEvent.Observer)

override fun unsubscribe(vararg observers: RuntimeEvent.Observer<*>)

Remove multiple Observer.

Link copied to clipboard
override fun unsubscribeAll(event: RuntimeEvent<*>)

Remove all Observer of a single RuntimeEvent.

override fun unsubscribeAll(event: TorEvent)
override fun unsubscribeAll(vararg events: TorEvent)
override fun unsubscribeAll(tag: String)

override fun unsubscribeAll(vararg events: RuntimeEvent<*>)

Remove all Observer of multiple RuntimeEvent.