I'm guessing that by saying "is no longer a component that can play
nicely" you mean that it wont' be shutdown-able through its control &
signal boxes:
The approach I'd personally take would be to manually wire up the
components in a graphline. I'd wire the inbox-outbox path pass through
just like for a Pipeline. I'd also do the same for the control-signal path
but instead of starting at component A and ending at D I'd start at C and
end at A.
What does this mean in practice:
EITHER: C shuts down. The shutdown message propagates to D, then to A then
to B then to the "signal" outbox of the graphline.
OR: A shutdown message arrives at the "control" inbox of the graphline.
This is routed to the "control" inbox of C. The shutdowns then propagate
to D, then to A then to B then to the "signal" outbox of the graphline.
def mySystem:
return Graphline(
A = ComponentA(),
B = ComponentB(),
C = ComponentC(),
D = ComponentD(),
linkages = {
# inbox-outbox path
("self","inbox") : ("A","inbox"),
("A","outbox") : ("B","inbox"),
("B","outbox") : ("C","inbox"),
("C","outbox") : ("D","inbox"),
("D","outbox") : ("self","outbox"),
# control-signal path
("self", "control") : ("C", "control"),
("C", "signal") : ("D", "control"),
("D", "signal") : ("A", "control"),
("A", "signal") : ("B", "control"),
("B", "signal") : ("self", "signal"),
})
mySystem().run()
I guess if this is a pattern you end up using often, and/or there are alot
more than 4 components in the pipeline, you could make a more generic
function that does this wiring. You could even use two Pipelines to save
the bother of having to wire up each link in the chain individually:
def mySystem2(firstSetOfComponents, secondSetOfComponents):
return Graphline(
FIRST = Pipeline(*firstSetOfComponents),
SECOND = Pipeline(*secondSetOfComponents),
linkages = {
# inbox-outbox path
("self","inbox") : ("FIRST","inbox"),
("FIRST","outbox") : ("SECOND","inbox"),
("SECOND","outbox") : ("self","outbox"),
# control-signal path
("self", "control") : ("SECOND", "control"),
("SECOND", "signal") : ("FIRST", "control"),
("FIRST", "signal") : ("self", "signal"),
})
mySystem2(
[
ComponentA(),
ComponentB(),
], [
ComponentC(),
ComponentD(),
]
).run()
mySystem().run()
Hope this helps.
Matt
>
> Apologies if I've missed something obvious in the documentation, but
> I'm having difficulty coming up with an elegant way of doing this:
>
> I have a pipeline of (say) four components A, B, C & D. The normal way
> to shut this down from outside is to send producerFinished to A's
> control inbox. This propagates down the line and all is well.
>
> As well as this I'd like one of the components (say C) to be able to
> decide that the pipeline's work is done and it should close down. I've
> been doing this by having C send producerFinished to its signal
> outbox, and (using Graphline) link D's signal outbox to A's control
> inbox. This is nasty, not least because my pipeline is no longer a
> component that can play nicely with other components in a larger
> system.
>
> Is there a better way to do this? All ideas welcome.
>
> Jim
>
> >
>
--
| Matt Hammond
|
| [anything you like unless it bounces] 'at' matthammond 'dot' org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"kamaelia" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---