You could just register all your different endpoints or types in a dict
where the key is the type and the value is the handler function. And each
handler function could do the custom logic that transforms the message into
a conformned message for the output.
 On May 30, 2014 11:57 PM, "Marcus Ottosson" <konstrukt...@gmail.com> wrote:

> Hi all,
>
> I’m developing an example program to illustrate the benefits and
> disadvantages of a service-oriented approach to task-distribution;
> mimicking the instant message-approach to routing messages from one-to-many
> via a central broker, it’s not quite at the point where pros and cons start
> showing their true colors, but getting there.
>
>
> ​
> First question - Routing multiple inputs to a single output
>
> peer.py represents a running client capable of making requests to the
> server, or swarm.py. Both peer.py and swarm.py handles incoming
> requests/replies via rather long-winded if/else methods:
>
> # Incoming messagesif type == 'letter':
>         # do stuff
> elif type == 'service':
>         # do stuff
> elif type == 'receipt':
>
>             ...
>
> What would be a better/neater approach to routing multiple inputs to a
> single output, in cases where there’d be a large number (50+) of branches
> in logic?
> Go to method
> <https://github.com/abstractfactory/labs/tree/master/python/messaging/chat>
>
> Best,
> Marcus
> ​
> --
> *Marcus Ottosson*
> konstrukt...@gmail.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODUGwFEJDmR0qYEm1YHptPR-%2Ba-4dP_cFDEOWcfF__n3A%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODUGwFEJDmR0qYEm1YHptPR-%2Ba-4dP_cFDEOWcfF__n3A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA19uus2-NW7KPOSUf3Fa%2BheZjiOY59JxFqGZD0sCsmfsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to