Skip to content

ActorKind Refactor - #20

Open
TylerBloom wants to merge 11 commits into
mainfrom
actor_kind
Open

TylerBloom wants to merge 11 commits into
mainfrom
actor_kind

Conversation

@TylerBloom

Copy link
Copy Markdown
Owner

Currently, ActorState requires four associated types. One of which, Output, is not needed in many/most cases. Another, Permanence, is a bit strange, adds confusion, and is also not important most of the time. These strange, confusing bits thread themselves all the way through the crate's model. This PR removes these pieces, making the crate easier to pick up and use while unlocking additional features in the future.

Removing Output from ActorState is a complete win for Sink actors as it is a completely unnecessary type and means that the Scheduler no longer contains additional fields that aren't used. Moreover, it means there aren't no-op methods in the scheduler's API in some cases. Replacing this is the ActorKind associated type (formerly ActorType). It now has a trait bound, ActorKind (ya, naming things is difficult). Originally, ActorKind softly implied a type of client. This change now directly encodes that. Every ActorKind has an associated Client type and will construct the initial client upon the actor's launch. Additionally, the ActorKind can contain state, rather than being a simple marker type. This state becomes embedded in the scheduler and will be accessible to the actor's state. Embedding the ActorKind like this removes the blanket broadcast field that the scheduler had before. Since that state is directly available, the Scheduler can be extended for a variety of future kinds of actors without needing to extend the scheduler itself.

These changes unlock a new dimension of extensibility. For example, there are use cases for sink and stream clients that have built-in back pressure. This feature will simply require adding a new ActorKind type along with its client. Similarly, one might need a SPSC actor. This too would just require a new ActorKind.

The Permanence associate type was also removed from ActorState as it was only really needed for some parts of the SinkClient's API. Should that type of functionality be needed in the future, it can be modeled with different types of ActorKind's (or by making SinkActor generic).

Lastly, the "edge map" feature of the scheduler and ActorBuilder was removed. This can be added back if the need arises. As it stood, this was premature and clunky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant