This package does implement four different styles of how the Planet Express process of loading the spaceship for the can be organized.
The styles get more complex from increment to increment.
This project got it's inspiration from the "Coding Dojo: Christmas Delivery".
This is the easiest delivery system. It works for one client and one delivery person as a dedicated pair. The client wants to send a couple of packets from Earth to other planets. There is exactly one delivery person with a dedicated relation to this client.
For this scenario, it doesn't play a role where the packets shall go to, and there is only one delivery person working for the Planet Express.
The delivery person, if idle, calls the client back for the next packet. It is assumed, that the client is ready to ship exactly one packet when ever the delivery person calls back.
The delivery person takes over the next packet on call, carries it to the spaceship and then calls back again. Be aware that such a haul always takes the delivery person some time.
Client --> (Gives Packet) -> Delivery Person --> (Packs onto) --> Spaceship
The client when entering business does have a limited number of packets to send. The process stops just after the client runs out of packets.
This is a bit more complex. There is now a dispatcher available in planet express. She organizes a number of delivery persons who will put presents onto the spaceship. If no delivery persons are available she will keep hold of the packet until one is available. There are now several clients that all want to send packets at the same time.
Client [1-N] -> (Gives Packet) -> Dispatcher --> (Gives Packet) ->
Delivery Person [1-M] --> (Packs onto) --> Spaceship
Each packet forms part of a delivery to a planet. Each delivery may consist of 1 ... N packets.
The client cannot guarantee that all packets to a planet will be sent to the dispatcher together. Packets to other planets could come in-between. Where possible, packets to different planets should not be put on the spaceship independently.
But the delivery persons are an expensive resource, and it is preferred to interleave the requests rather than having them sit idle. A strategy is needed to allow the dispatcher to deliver presents by planet when possible.
The Planet Express boss has just received some bad news. There’s been a recent surge in docking costs at certain planets. He wants to be able to cancel packets for these planets by telling the dispatcher to refuse picking packets for those destinations.
class Spaceship:
def pack(self, packet: Packet) -> None: ...The Planet Express does operate exactly one spaceship.