August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
Backplanes provide a way to 'publish' data under a name, enabling other parts of the system to 'subscribe' to it on the fly, without having to know about the actual component(s) the data is coming from.
It is a quick and easy way to distribute or share data. Think of them like backplane circuit boards - where other circuit boards can plug in to send or receive any signals they need.
A system where several producers publish data, for consumers to pick up:
Pipeline( Producer1(),
PublishTo("DATA")
).activate()
Pipeline( Producer2(),
PublishTo("DATA")
).activate()
Pipeline( SubscribeTo("DATA"),
Consumer1(),
).activate()
Pipeline( SubscribeTo("DATA"),
Consumer2(),
).activate()
Backplane("DATA").run()
A server where multiple clients can connect and they all get sent the same data at the same time:
Pipeline( Producer(),
PublishTo("DATA")
).activate()
SimpleServer(protocol=SubscribeTo("DATA"), port=1500).activate()
Backplane("DATA").run()
The Backplane component collects data from publishers and sends it out to subscribers.
You can have as many backplanes as you like in a running system - provided they all register under different names.
A backplane can have multiple subscribers and multiple publishers. Publishers and subscribers can be created and destroyed on the fly.
To shut down a PublishTo() component, send a producerFinished() or shutdownMicroprocess() message to its "control" inbox. This does not propagate and therefore does not cause the Backplane or any subscribers to terminate.
To shut down a SubscribeTo() component, send a producerFinished() or shutdownMicroprocess() message to its "control" inbox. It will then immediately forward the mesage on out of its "signal" outbox and terminate.
To shut down the Backplane itself, send a producerFinished() or shutdownMicroprocess() message to its "control" inbox. It will then immediately terminate and also propagate this message onto any subscribers (SubscribeTo components), causing them to also terminate.
Backplane is actually based on a Kamaelia.Util.Splitter.PlugSplitter component, and the SubscribeTo component is a wrapper around a Kamaelia.Util.Splitter.Plug.
The Backplane registers itself with the coordinating assistant tracker.
PublishTo components look up the "Backplane_I_<name>" service and simply forward data sent to their "inbox" inboxes direct to the "inbox" inbox of the PlugSplitter - causing it to be distributed to all subscribers.
SubscribeTo components look up the "Backplane_O_<name>" service and request to have their "inbox" and "control" inboxes connected to the PlugSplitter. SubscribeTo then forwards on any messages it receives out of its "outbox" and "signal" outboxes respectively.
The PlugSplitter component's "control" inbox and "signal" outbox are not advertised as services. To shut down a Backplane you must therefore send a shutdownMicroprocess() or producerFinished() message directly to its "control" inbox. When this happens, the shutdown message will be forwarded on to all subscribers - causing SubscribeTo components to also shut down.
Backplane(name) -> new Backplane component.
A named backplane to which data can be published for subscribers to pick up.
Keyword arguments:
Warning!
You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.
Unplugs any children that have terminated, and returns true if there are no running child components left (ie. their microproceses have finished)
Main loop.
PublishTo(destination) -> new PublishTo component
Publishes data to a named Backplane. Any data sent to the "inbox" inbox is sent to all (any) subscribers to the same named Backplane.
Keyword arguments:
Warning!
You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.
Main loop.
SubscribeTo(source) -> new SubscribeTo component
Subscribes to a named Backplane. Receives any data published to that backplane and sends it on out of its "outbox" outbox.
Keyword arguments:
Warning!
You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.
Unplugs any children that have terminated, and returns true if there are no running child components left (ie. their microproceses have finished)
Main loop.
Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!
Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.
-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT