Protocol

Defines the effective protocol used to communicate between two entities remotely. The protocol is responsible for setting up the communication channel between the two Entity and for sending and receiving messages.

Generally, this interface is implemented in a separate module leveraging protocol-specific libraries. The protocol is configured using the configuration DSL and then will be injected into the runtime to establish the communication. The end-user do not interact directly with this interface.

Properties

Link copied to clipboard
abstract val di: DI
Link copied to clipboard
open val diContext: DIContext<*>
Link copied to clipboard
open val diTrigger: DITrigger?

Functions

Link copied to clipboard
abstract suspend fun finalize(): Either<ProtocolError, Unit>

Asynchronously finalizes the entity. Can Either succeed or fail with an Error.

Link copied to clipboard
abstract suspend fun initialize(): Either<ProtocolError, Unit>

Asynchronously initializes the entity. Can Either succeed or fail with an Error.

Link copied to clipboard
abstract fun readFromChannel(from: Entity, to: Entity): Either<ProtocolError, Flow<ByteArray>>

Starts listening for messages flowing from an Entity another Entity. The returned Flow is a hot stream of messages that can be consumed by the runtime.

Link copied to clipboard
abstract suspend fun setupChannel(source: Entity, destination: Entity)

This method configures the protocol to communicate between the given source and destination entities.

Link copied to clipboard
abstract fun setupInjector(kodein: DI)

Configures the module of the dependency injection module that the resource will use.

Link copied to clipboard
abstract suspend fun writeToChannel(from: Entity, to: Entity, message: ByteArray): Either<ProtocolError, Unit>

Sends a message an Entity another Entity.