As of https://github.com/betcode-org/flumine/pull/685 getting merged, BaseStrategy.add() method receives flumine as an argument. This makes it elegant to add e.g. strategy-specific middleware or workers inside the strategy itself. The problem arises when multiple strategies require the same resource and add it multiple times.
As with streams, all the methods outlined below should check whether a resource has already been added and reject duplicates. The test should be if resource not in [resource_1, resource_2, ...] then add_resource(). It would then be expected of the end user to override __eq__() method of each custom resource to determine what constitutes a duplicate.
As of https://github.com/betcode-org/flumine/pull/685 getting merged,
BaseStrategy.add()
method receivesflumine
as an argument. This makes it elegant to add e.g. strategy-specific middleware or workers inside the strategy itself. The problem arises when multiple strategies require the same resource and add it multiple times.As with streams, all the methods outlined below should check whether a resource has already been added and reject duplicates. The test should be
if resource not in [resource_1, resource_2, ...] then add_resource()
. It would then be expected of the end user to override__eq__()
method of each custom resource to determine what constitutes a duplicate.https://github.com/betcode-org/flumine/blob/bfaa5def6dc66794f088d9e4fed539c3c3043926/flumine/baseflumine.py#L102-L122