Closed ktoso closed 3 years ago
The workaround:
typealias ChangeFunc = ChangeFunction<Value>
struct ChangeFunction<Value>: NonTransportableActorMessage {
let change: (Value) throws -> Value
}
public func change(key: String, update: ChangeFunc, extra: Extras) -> EventLoopFuture<Value>
I guess that's fine; perhaps worth documenting as a pattern
This is solved in the language with the introduction of whenLocal
on distributed actors.
Actorable's today can't survive this.
I'm implementing CASPaxos for fun, and the submitting of a change is done via sending a pure function to perform the change.
The actorable would have something like:
of course, that update closure can never be sent across the wire, and we "know that", we only ever send it locally. As all messages are required to be codable now though... we can't do this anymore, since -> should never be codable.
Options...
LocalOnly(() -> ())
makes the API a bit meh...