v5.0.0
https://github.com/sociomantic-tsunami/swarm/milestone/3
Migration Instructions
Increase minimal required ocean version
Starting with v5.0.0, swarm supports and requires ocean v4.0.0.
Require turtle
Starting with v5.0.0, swarm requires turtle v9.0.1.
Client all-nodes / suspendable cores automatically handle supported codes
swarm.neo.client.mixins.AllNodesRequestCore
,
swarm.neo.client.mixins.SuspendableRequestCore
The HandleStatusCode
template arguments and the corresponding runtime
arguments (where apporpriate) have been removed from:
* AllNodesRequestInitialiser
* createAllNodesRequestInitialiser
* SuspendableRequestInitialiser
* createSuspendableRequestInitialiser
AllNodesRequestInitialiser
now handles un/supported codes automatically,
calling the request struct's handleSupportedCodes
function.
User code that specifies a status code handler should be adapted as follows:
1. Any handling of un/supported codes should be removed.
2. Handling of request-specific status codes should be moved into the main
request handler function (i.e. the Handler
policy of
AllNodesRequestCore
).
NeoNode
-derived classes must implement getResourceAcquirer
swarm.node.model.NeoNode
The method getResourceAcquirer
is now abstract. All neo-capable node classes
must now implement this method, passing a scope-allocated request resource
acquirer to the provided delegate, for use in an active request handler.
EventDispatcher.nextEvent doesn't implicitly allow explicit resume
swarm.neo.connection.RequestOnConnBase
The EventDispatcher.nextEvent method suspends the fiber and ensures that it is
only resumed again for an expected reason. Previously, in addition to the
resume reasons specified by the user when calling the method, manual resumption
of the fiber with a positive resume code was always implicitly allowed. This
meant that user code had to manually check for this case, if it was not
desired.
Now, manual resumption of the fiber is disallowed by default, and
EventDispatcher.nextEvent will by default treat this as a protocol error, if it
occurs. Code that calls nextEvent should be updated as follows:
- If you wish to allow manual fiber resumption,
pass the new NextEventFlags.Resume flag to nextEvent. - If you wish to disallow manual fiber resumption, do nothing. For tidiness,
you should remove any user code that checks for this occurrence.
Adapt RequestEventDispatcher
usage to new initialise
method: don't store in a pool
swarm.neo.request.RequestEventDispatcher
It's no longer recommended to keep the reusable RequestEventDispatcher instance,
instead it should reuse the internal arrays (obtained by the delegate passed
to the initialise
method). All code using it must adapt to use the initialise
method in conjunction with AcquiredResources.getVoidBuffer()
method.
Support for client per-Request-on-Conn working data removed
swarm.neo.client.mixins.RequestCore
This support was added in an early iteration of swarm neo but has turned out to
not be required by any request implementation.
Client-side request handler code must be adapted as follows:
- Remove the dummy
Working
struct from your request implementation. - Do not pass the dummy
Working
struct as an argument to theRequestCore
template mixin. - Remove the
void[] working_blob
argument from your request'shandler
function. - Remove the
IRequestWorkingData working_data_iter
from your request's
all_finished_notifier
function.
Notifiers stored in UserSpecifiedParams
as plain delegates
swarm.neo.client.mixins.RequestCore
Previously, due to limitations in the serializer that was used to store request
contexts, request notifiers were stored as ubyte[]
s wrapped with getters /
setters. With the addition of the struct packer (swarm.neo.util.StructPacker
)
in swarm v4.5.0, this hack is no longer necessary.
Request assignment methods that construct a const UserSpecifiedParams
instance
like this:
auto params = Const!(Internals.Get.UserSpecifiedParams)(
Const!(Get.Args)(key),
Const!(Internals.Get.UserSpecifiedParams.SerializedNotifier)(
*(cast(Const!(ubyte[notifier.sizeof])*)¬ifier)
)
);
should be converted to work like this:
auto params = Const!(Internals.Get.UserSpecifiedParams)(
Const!(Get.Args)(key),
notifier);
Turtle Node ext base class is now in swarm
turtle.env.model.Node
This module providing the common turtle ext node base class used to be included
in the protos. Because it's the same file, it's now moved into swarm. Proto
repositories should remove their copy of this file.
Couple of changes needs to be performed while updating the protos' implementations,
and client code:
-
ignoreErrors()
is now renamed tolog_errors(bool)
method which can
enable/disable the error output. -
node_item()
method has renamed tonode_addport
and now it returns
AddrPort
structure. Make sure you don't set the port/address directly,
as the byte order might be different. Use setAddress()/port() setters/getters.
For example:// Before: this.neo_address = NodeItem(this.node_item.address, this.node_item.port() + 100); // After: this.neo_address = AddrPort(this.node_item.address) // Important - port setter converts from host to network byte order this.neo_address.port() = cast(ushort)this.node_item.port() + 100;
-
createNode
(protected method) now acceptsAddrPort
structure instead
NodeItem
structure.