xtra::Actorcustom-derive when themacrosfeatures is enabled.
- Remove
async_traitmacro in favor of async functions in traits (AFIT). This bumps xtra's MSRV to1.75. MessageChannelis now astructthat can be constructed from anAddressviaMessageChannel::newor usingFrom/Into.- Move event-loop related functions from
Contextto xtra's top-level scope.Contextis now only used within an actor'sHandler. The default event-loop now lives atxtra::run, next toxtra::select,xtra::join,xtra::yield. - Redesign "spawn" interface:
Remove
Actor::create,ActorManagerand extension traits for spawning. Introducextra::spawn_tokio,xtra::spawn_smol,xtra::spawn_async_stdandxtra::spawn_wasm_bindgen. - Previously,
stop_allwould immediately disconnect the address. However,stop_selfdone on every actor would actually not do this in one case - if there were a free-floating (not executing an actor event loop) Context. This change bringsstop_allin line withstop_self. stop_allnow does not drain all messages when called, and acts just likestop_selfon all active actors.- Rename features from
with-crate-versionto justcrate. For example,with-tokio-1has been renamed totokio. - Sealed
RefCountertrait.
AddressSinkwas removed in favor of usingimpl Traitfor theAddress::into_sinkmethod.Context::attach_streamwas removed in favor of composingStream::forwardandAddress::into_sink.KeepRunningwas removed asContext::attach_streamwas its last usage.InstrumentedExtwas removed. All messages are now instrumented automatically wheninstrumentationis enabled.Messageno longer exists:Returnis now specified on theHandlertrait itself.stoppinghas been removed in favour ofstop_selfandstop_all. If logic to determine if the actor should stop must be executed, it should be done rather at the point of callingstop_{self,all}.Context::attachis removed in favor of implementingCloneforContext. If you want to run multiple actors on aContext, simply clone it before callingrun.- Remove
Context::notify_afterwithout a direct replacement. To delay the sending of a message, users are encouraged to use thesleepfunction of their executor of choice and combine it withAddress::sendinto a new future. To cancel the sleeping early in case the actor stops, usextra::scoped. - Remove
Context::notify_intervalwithout a direct replacement. Users are encouraged to write their own loop within which they callAddress:send.
- The
SyncHandlertrait has been removed. This simplifies the API and should not change the performance on stable.- How to upgrade: change all implementations of the
SyncHandlertrait to the normalHandlertrait.
- How to upgrade: change all implementations of the
- All
Actorlifecycle messages are now async. This allows to do more kinds of things in lifecycle methods, while adding no restrictions.- How to upgrade: add
asyncto the function definition of all actor lifecycle methods, add#[async_trait::async_trait]to theimpl Actorblock.
- How to upgrade: add
Actornow requiresSendto implement. Previously, the trait itself did not, but using it did requireSend.- How to upgrade: you probably never had a non-
Sendactor in the first place.
- How to upgrade: you probably never had a non-
- The
{Weak}{Address|MessageChannel}::attach_streammethods now require that the actor implementsHandler<M>whereM: Into<KeepRunning> + Send. This is automatically implemented for(), returningKeepRunning::Yes. This allows the user more control over the future spawned byattach_stream, but is breaking if the message returned did not implementInto<KeepRunning>.- How to upgrade: implement
Into<KeepRunning>for all message types used inattach_stream. To mimic previous behaviour, returnKeepRunning::Yesin the implementation.
- How to upgrade: implement
AddressandWeakAddresslost theirSinkimplementations. They can now be turned intoSinks by calling.into_sink().- How to upgrade: convert any addresses to be used as sinks into sinks with
.into_sink(), cloning where necessary.
- How to upgrade: convert any addresses to be used as sinks into sinks with
{Address|MessageChannel}Extwere removed in favour of inherent implementations,- How to upgrade: in most cases, this will not have broken anything. If it is directly imported, remove the import.
If you need to be generic over weak and strong addresses, be generic over
Address<A, Rc>whereRc: RefCounterfor addresses and useMessageChannel<M>trait objects.
- How to upgrade: in most cases, this will not have broken anything. If it is directly imported, remove the import.
If you need to be generic over weak and strong addresses, be generic over
{Weak}MessageChannelbecame traits rather than concrete types. In order to use them, simply cast an address to the correct trait object (e.g&addr as &dyn MessageChannel<M>orBox::new(addr)). Theinto_channelandchannelmethods were also removed.- How to upgrade: replace
{into_}channelcalls with casts to trait objects, and replace references to the old types with trait objects, boxed if necessary. If you were using theSinkimplementations of these types, first create anAddressSinkthrough.into_sink(), and then cast it to aMessageSinktrait object.
- How to upgrade: replace
Address::into_downgradedwas removed. This did nothing different todowngrade, except dropping the address after the call.- How to upgrade: Simply call
Address::downgrade, dropping the strong address afterwards if needed.
- How to upgrade: Simply call
- Some types were moved out of the root crate and into modules.
- How to upgrade: search for the type's name in the documentation and refer to it by its new path.
Actor::spawnandActor::createnow take anOption<usize>for the mailbox size.- How to upgrade: choose a suitable size of mailbox for each spawn call, or pass
Noneto give them unbounded mailboxes.
- How to upgrade: choose a suitable size of mailbox for each spawn call, or pass
- Many context methods now return
Result<..., ActorShutdown>to represent failures due to the actor having been shut down.
- The
stablefeature was removed.In order to enable the nightly API, enable the newEdit: as of 0.5.0, the nightly API has been removed.nightlyfeature.
- The default API of the
Handlertrait has now changed to anasync_traitso that xtra can compile on stable.- How to upgrade, alternative 1: change the implementations by annotating the implementation with
#[async_trait], removingResponderand makinghandleanasync fnwhich directly returns the message's result. - How to upgrade, alternative 2: if you want to avoid the extra box, you can disable the default
stablefeature in yourCargo.tomlto keep the old API.
- How to upgrade, alternative 1: change the implementations by annotating the implementation with
- Removal of the
with-runtimefeature- How to upgrade: you probably weren't using this anyway, but rather use
with-tokio-*orwith-async_std-*instead.
- How to upgrade: you probably weren't using this anyway, but rather use
Addressmethods were moved toAddressExtto accommodate newAddresstypes- How to upgrade: add
use xtra::AddressExtto wherever address methods are used (or, better yet,use xtra::prelude::*)
- How to upgrade: add
- All
*_asyncmethods were removed. Asynchronous and synchronous messages now use the same method for everything.- How to upgrade: simply switch from the
[x]_asyncmethod to the[x]method.
- How to upgrade: simply switch from the
AsyncHandlerwas renamed toHandler, and the oldHandlertoSyncHandler. Also, aHandlerandSyncHandlerimplementation can no longer coexist.- How to upgrade: rename all
Handlerimplementations toSyncHandler, and allAsyncHandlerimplementations toHandler.
- How to upgrade: rename all