{ "info": { "author": "Oisin Mulvihill", "author_email": "oisinmulvihill at gmail dot com", "bugtrack_url": null, "classifiers": [], "description": "Evasion Messenger\n=================\n\n.. contents::\n\nEvasionProject code documentation\n---------------------------------\n\n * http://www.evasionproject.com/apidocs/\n\nEvasionProject Wiki\n-------------------\n\n * http://www.evasionproject.com/\n\n\nIntroduction\n------------\n\nThe evasion-messenger uses ZeroMQ PUB-SUB pattern to create a distributed\npublish-subscribe system. This could be used between processes or across the\nnetwork.\n\n\nTutorial\n--------\n\nTime Service\n~~~~~~~~~~~~\n\nIn this tutorial we will create two endpoints. The first will be the \"server\"\nwho dispatched the current UTC date and time. The second will \"client\" will\nsubscribe to time messages and display the current time.\n\nServer\n``````\n\ntime_server.py:\n\n * https://raw.github.com/oisinmulvihill/evasion-messenger/master/examples/timeservice/time_server.py\n\n\nClient\n``````\n\ntime_client.py:: python\n\n * https://raw.github.com/oisinmulvihill/evasion-messenger/master/examples/timeservice/time_client.py\n\nThe code for these are available in the source code examples/timeservice. To\nrun these examples, start the messagehub and then run the \"time_client.py\" and\n\"time_server.py\". The order is not important in these examples.\n\nDue to the nature of 0MQ and the PUB-SUB pattern, the \"time_client.py\" will run\neven if no Hub is running. The default hub settings published a HUB_PRESENT\nframe periodically.To allow an endpoint to check if anything is\nlistening, it is possible to checkout an see if\n\nBefore we begin, in a new command line terminal run the messagehub. You should\nsee some output like::\n\n # Need messagehub default run output\n $ messagehub\n 2012-11-08 19:56:36,226 evasion.messenger.MessagingHub INFO Dispatching on: tcp://*:15566\n 2012-11-08 19:56:36,226 evasion.messenger.MessagingHub INFO Incoming on: tcp://*:15567\n 2012-11-08 19:56:36,226 evasion.messenger.MessagingHub INFO Idle Timeout (ms): 1000\n 2012-11-08 19:56:36,228 evasion.messenger.MessagingHub INFO main: Mainloop running.\n\n # (Later Press Ctrl-C to exit):\n ^C\n 2012-11-08 19:56:40,697 root WARNING signal_handler: signal<2> caught, stopping hub.\n 2012-11-08 19:56:42,697 evasion.messenger.MessagingHub INFO main: signal interrupt, exit time \n 2012-11-08 19:56:42,698 evasion.messenger.MessagingHub INFO main: Waiting for shutdown...\n 2012-11-08 19:56:42,699 evasion.messenger.MessagingHub INFO main: Shutdown complete.\n $\n\n\nImproved Client\n```````````````\n\ntime_client2.py:: python\n\n * https://raw.github.com/oisinmulvihill/evasion-messenger/master/examples/timeservice/time_client2.py\n\n\nEvasion PUB-SUB Messaging\n-------------------------\n\nThe original evasion-messenger used a complicated mashup of Twisted, the Stomp\nprotocol, Morbid and pydispatch. This has now been replaced in favour of\nbuilding on the ZeroMQ Publish-Subscribe (PUB-SUB) pattern.\n\nThe messenger provides the ability to register a callback function for a signal.\nThis signal is some user meaningful string. When an endpoint publishes data for\nthis signal, all callbacks local or remote will be called.\n\nHub\n~~~\n\nThis is the central process which takes evasion frames and propagates it to all\nconnected end points. The Hub only propagates certain frames. Only DISPATCH and\nDISPATCH_REPLY reply frames are propagated to endpoints. Other frames are\nconsumed by the hub.\n\nEnd Point\n~~~~~~~~~\n\nThis is a program connecting to a Hub receiving messages and deciding what\naction to take based on the evasion frame.\n\nEvasion Frames\n~~~~~~~~~~~~~~\n\nThe general user does not need to know this. The evasion-messenger takes care\nof this. The end-user will deal soley with the endpoint.Register subscribe,\npublish or unsubscribe methods.\n\nThe Frames are a multipart 0MQ message which when received in Python, becomes a\ntuple of strings. The format of the strings in an \"Evasion Frame\" is defined\nas::\n\n(,(, , ...))\n\nThe is a string used to give meaning to what the other items\nfollowing it will be.\n\n\nSYNC\n````\n\nThis frame is used to start a subscribe 0MQ subscribe socket going once it has\nstarted. After one of these has been recieved, you can be sure that other\nmessages will be handled.\n\nDue to the nature of 0MQ, the Hub or Endpoint does not known when its connected.\nTherefore, a SYNC message is sent prior to any message.\n\nThe 0MQ guide mentions the need for this in the PUB-SUB pattern, on which the\nevasion messenger is built:\n\n * http://zguide.zeromq.org/page:all#Getting-the-Message-Out\n\n \"There is one more important thing to know about PUB-SUB sockets: you\n do not know precisely when a subscriber starts to get messages. Even\n if you start a subscriber, wait a while, and then start the publisher,\n the subscriber will always miss the first messages that the publisher\n sends. This is because as the subscriber connects to the publisher\n (something that takes a small but non-zero time), the publisher may\n already be sending messages out.\"\n\nExample Frame::\n\n ('SYNC', '{\"from\": \"endpoint-\"}')\n\n ('SYNC', '{\"from\": \"hub-\"}')\n\n\nDISPATCH\n````````\n\nThis frame is used at the Python code level to invoke registered callbacks for\nthe given signal. The JSON object will be loaded into a python dictionary. It\nwill contain a source id string and a data dict field. The data dict will be\npassed as an argument to any registered callbacks.\n\nExample Frame::\n\n ('DISPATCH','3c14d4b7-3b88-4680-96d1-e367f051eef1','tea_time','{\"a\":1}','0')\n\n\nDISPATCH_REPLY\n``````````````\nThis is a reply to a received signal. When reply_to is '0' reply is expected. If\nreply_to is not '0' it will contain a UUID. This is used to route a reply back\nto a waiting process.\n\nExample Frame::\n\n ('DISPATCH_REPLY', 'proc_uuid', 'reply_to_uuid', '{\"a\":1}')\n\n\nHUB_PRESENT\n```````````\n\nThis frame is sent out periodically by the hub to indicate its presence. The\nversion number present is the version number of the evasion messenger package.\n\nExample Frame::\n\n ('HUB_PRESENT', '{\"version\":\"X.Y\"}')\n\n\nMessage Flow\n````````````\n\nA SYNC frame is sent prior to any message between a Hub and Endpoint. This can\nbe assumed and will not be mentioned further.\n\nWhen there is no DISPATCH or DISPATCH_REPLY traffic, the endpoint will receive\nHUB_PRESENT messages. These are used to give each endpoint an indication the hub\nis present and routing messages.\n\nThe Hub will only propagate DISPATCH and DISPATCH_REPLY messages.\n\n\n\"Client\" side API\n-----------------\n\nAll end-users will use the Register class. The Hub will need to be\n\nmessenger.endpoint.Register\n\n subscribe(signal, function)\n Registers a callback function for a signal. When this signal occurs\n invoke the function with the data dict.\n\n unsubscribe(signal, function)\n Remove a callback so it is no longer invoked for a signal.\n\n publish(signal, data)\n Call all subscribers for the signal with the given data.\n\n start()\n Start receiving messages from the Hub.\n\n stop()\n Stop receiving messages from the Hub.\n\n\nThe Hub\n-------\n\nIf the evasion-messenger is installed with easy_install or the source code is\nset up in development mode, a \"messagehub\" program will be available. This is\nrun to propagate messages between endpoints.\n\nConfiguration\n~~~~~~~~~~~~~\n\nThe Hub is configured via the command line. It has no configuration file. The\ncurrently available options are::\n\n $ messagehub --help\n Usage: messagehub [options]\n\n Options:\n -h, --help show this help message and exit\n --show-messages Log all message traffic to DEBUG logging.\n --show-hub-present Log when HUB_PRESENT is dispatched.\n --wait-for-message-timeout=WAIT_FOR_MESSAGE_TIMEOUT\n The time (in milliseconds, default: 1000) to wait for\n messages before timing out and sending a HUB_PRESENT.\n --publish-on=PUBLISH_ON\n The ZMQ Publish set up, defeault: tcp://*:15566\n --subscribe-on=SUBSCRIBE_ON\n The ZMQ Subscribe set up, defeault: tcp://*:15567\n --disable-hub-presence\n Turn off the dispatch of HUB_PRESENCE when idle.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "Evasion Project CDDL License", "maintainer": null, "maintainer_email": null, "name": "evasion-messenger", "package_url": "https://pypi.org/project/evasion-messenger/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/evasion-messenger/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/evasion-messenger/1.2.0/", "requires_dist": null, "requires_python": null, "summary": "A Python ZeroMQ Pub/Sub Implementation and Messaging library.", "version": "1.2.0" }, "last_serial": 802971, "releases": { "1.0.0": [], "1.1.0dev": [ { "comment_text": "", "digests": { "md5": "5b026e9844e7bcda3cee65a1dd4abcdf", "sha256": "9a0cfa2ee9db479c3b42e372925e5132722d013bd8645b941fc5569f37bdbc27" }, "downloads": -1, "filename": "evasion-messenger-1.1.0dev.tar.gz", "has_sig": false, "md5_digest": "5b026e9844e7bcda3cee65a1dd4abcdf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20764, "upload_time": "2011-08-23T15:43:28", "url": "https://files.pythonhosted.org/packages/5f/c0/bf514e83eb60c08879a5cb70222aab8de6f81986b2b06ea95f6e0a1c4b25/evasion-messenger-1.1.0dev.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "156b2cfc66cbcbba719f92cfffe90a83", "sha256": "e2a72f92a44fb0b27ee3f53a6e7fd78ca598e743bd82d7076449109ecde11c50" }, "downloads": -1, "filename": "evasion-messenger-1.2.0.tar.gz", "has_sig": false, "md5_digest": "156b2cfc66cbcbba719f92cfffe90a83", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16328, "upload_time": "2012-11-08T19:38:56", "url": "https://files.pythonhosted.org/packages/53/c3/9db607541670a60b94f3d93f343dd3b6cafb1e0a91495b3fcb780c7f0519/evasion-messenger-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "156b2cfc66cbcbba719f92cfffe90a83", "sha256": "e2a72f92a44fb0b27ee3f53a6e7fd78ca598e743bd82d7076449109ecde11c50" }, "downloads": -1, "filename": "evasion-messenger-1.2.0.tar.gz", "has_sig": false, "md5_digest": "156b2cfc66cbcbba719f92cfffe90a83", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16328, "upload_time": "2012-11-08T19:38:56", "url": "https://files.pythonhosted.org/packages/53/c3/9db607541670a60b94f3d93f343dd3b6cafb1e0a91495b3fcb780c7f0519/evasion-messenger-1.2.0.tar.gz" } ] }