AbstractComponent
Preconfigured abstract implementation of Component. This class provides in the companion object some helper methods to send and receive messages without specifying the serialization. Preconfigures the component defining the initialize and finalize methods.
This abstract class implements all the machinery needed for a component to work, letting the user focusing only on the implementation of the execute method. The execute method can fail with a ComponentError and it is executed in a coroutine scope. An example of generic component implementation is the following:
class MyComponent : AbstractComponent() {
override suspend fun execute(): Either<ComponentError, Unit> = either {
// component logic implementation
}
}
When a pulverization model is adopted, used the component-specific class provided in the pulverization
package.
Inheritors
Properties
Functions
Starts the execution of the component logic. The execution may fail with a ComponentError. Before calling this method the setupWiring method MUST be called.
Asynchronously finalizes the entity. Can Either succeed or fail with an Error.
Returns a symbolic reference to this component. This method is used internally by the runtime and should not be called by the user.
Asynchronously initializes the entity. Can Either succeed or fail with an Error.
Receives a message of type P by deserializing it with the given serializer. If the message pushed in the flow cannot be serialized with the given serializer the flow will fail with an exception. This method can fail with a ComponentNotRegistered if the fromComponent is not registered as link of this component.
Helper method to receive messages fromComponent without specifying the serialization.
Sends a message of type P by serializing it with the given serializer. This method can fail with a ComponentNotRegistered if the toComponent is not registered as link of this component.
Helper method to send a message without specifying the serialization.
Configures the module of the dependency injection module that the resource will use.
Setup all the other components to which this component will communicate. The components represents the symbolic references to the other components allowing a distributed communication. This method is generally called by the runtime when the pulverization model is adopted. In case of custom Logical Device partitioning this method should be called manually.