morp


Namemorp JSON
Version 5.2.2 PyPI version JSON
download
home_pagehttp://github.com/Jaymon/morp
SummarySend and receive messages without thinking about it
upload_time2023-06-24 21:16:45
maintainer
docs_urlNone
authorJay Marcyes
requires_python
licenseMIT
keywords amazon aws sqs messages message-passing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Morp

Send messages without really thinking about it.


## Installation

Use pip to install the latest stable version:

    pip install morp
    
To install the development version:

    pip install -U "git+https://github.com/Jaymon/morp#egg=morp"


## 1 Minute Getting Started

Send and receive a `Foo` message.

First, let's set our environment variable to use the dropfile (local files suitable for development and prototyping) interface:

    export MORP_DSN=dropfile:///${TMPDIR}

Second, let's create a `Foo` Message class:

```python
from morp import Message

class Foo(Message):
    def target(self):
        # this will be run when a Foo message is consumed
        print(self.fields)
```

Third, let's start our message consumer in a shell:

```
$ morp
```

Fourth, let's send a message:

```python
f = Foo()
f.some_field = 1
f.some_other_field = 2
f.send()
```

That's it!


## DSN

You configure your connection using a dsn in the form:

    InterfaceName://username:password@host:port/path?param1=value1&param2=value2

So, to connect to [Amazon SQS](http://aws.amazon.com/sqs/), you would do:

    sqs://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@

You can also override some default values like `region` and `read_lock`:

    sqs://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@?region=${AWS_DEFAULT_REGION}&read_lock=120


## Encryption

If you would like to encrypt all your messages, you can pass in a `key` argument to your dsn and Morp will take care of encrypting and decrypting the messages for you transparently.

Let's just modify our dsn to pass in our key:

    sqs://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@?key=jy4XWRuEsrH98RD2VeLG62uVLCPWpdUh

That's it, every message will now be encrypted on send and decrypted on receive. If you're using SQS you can also use [Amazon's key management service](https://github.com/Jaymon/morp/blob/master/docs/KMS.md) to handle the encryption for you.


## Environment configuration

### MORP_DISABLED

By default every message will be sent, if you just want to test functionality without actually sending the message you can set this environment variable to turn off all the queues.

    MORP_DISABLED = 1 # queue is off
    MORP_DISABLED = 0 # queue is on


### MORP_PREFIX

If you would like to have your queue names prefixed with something (eg, `prod` or `dev`) then you can set this environment variable and it will be prefixed to the queue name.


### MORP_DSN

Set this environment variable with your connection dsn so morp can automatically configure itself when the interface is first requested.


## FAQ

### I would like to have multiple queues

By default, Morp will send any message from any `morp.Message` derived class to `Message.get_name()`, you can override this behavior by giving your child class a `.name` attribute:

```python
from morp import Message

class childMsg(Message):
    name = "custom-queue-name"
```

Now, you can have the Morp command line consumer read from that queue instead:

```
$ morp custom-queue-name
```

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/Jaymon/morp",
    "name": "morp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Amazon AWS SQS messages message-passing",
    "author": "Jay Marcyes",
    "author_email": "jay@marcyes.com",
    "download_url": "https://files.pythonhosted.org/packages/b2/4b/40c24f2a01cbba02eb24f091d278846cf37c5912d39f93907ea88d1476e4/morp-5.2.2.tar.gz",
    "platform": null,
    "description": "# Morp\n\nSend messages without really thinking about it.\n\n\n## Installation\n\nUse pip to install the latest stable version:\n\n    pip install morp\n    \nTo install the development version:\n\n    pip install -U \"git+https://github.com/Jaymon/morp#egg=morp\"\n\n\n## 1 Minute Getting Started\n\nSend and receive a `Foo` message.\n\nFirst, let's set our environment variable to use the dropfile (local files suitable for development and prototyping) interface:\n\n    export MORP_DSN=dropfile:///${TMPDIR}\n\nSecond, let's create a `Foo` Message class:\n\n```python\nfrom morp import Message\n\nclass Foo(Message):\n    def target(self):\n        # this will be run when a Foo message is consumed\n        print(self.fields)\n```\n\nThird, let's start our message consumer in a shell:\n\n```\n$ morp\n```\n\nFourth, let's send a message:\n\n```python\nf = Foo()\nf.some_field = 1\nf.some_other_field = 2\nf.send()\n```\n\nThat's it!\n\n\n## DSN\n\nYou configure your connection using a dsn in the form:\n\n    InterfaceName://username:password@host:port/path?param1=value1&param2=value2\n\nSo, to connect to [Amazon SQS](http://aws.amazon.com/sqs/), you would do:\n\n    sqs://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@\n\nYou can also override some default values like `region` and `read_lock`:\n\n    sqs://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@?region=${AWS_DEFAULT_REGION}&read_lock=120\n\n\n## Encryption\n\nIf you would like to encrypt all your messages, you can pass in a `key` argument to your dsn and Morp will take care of encrypting and decrypting the messages for you transparently.\n\nLet's just modify our dsn to pass in our key:\n\n    sqs://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@?key=jy4XWRuEsrH98RD2VeLG62uVLCPWpdUh\n\nThat's it, every message will now be encrypted on send and decrypted on receive. If you're using SQS you can also use [Amazon's key management service](https://github.com/Jaymon/morp/blob/master/docs/KMS.md) to handle the encryption for you.\n\n\n## Environment configuration\n\n### MORP_DISABLED\n\nBy default every message will be sent, if you just want to test functionality without actually sending the message you can set this environment variable to turn off all the queues.\n\n    MORP_DISABLED = 1 # queue is off\n    MORP_DISABLED = 0 # queue is on\n\n\n### MORP_PREFIX\n\nIf you would like to have your queue names prefixed with something (eg, `prod` or `dev`) then you can set this environment variable and it will be prefixed to the queue name.\n\n\n### MORP_DSN\n\nSet this environment variable with your connection dsn so morp can automatically configure itself when the interface is first requested.\n\n\n## FAQ\n\n### I would like to have multiple queues\n\nBy default, Morp will send any message from any `morp.Message` derived class to `Message.get_name()`, you can override this behavior by giving your child class a `.name` attribute:\n\n```python\nfrom morp import Message\n\nclass childMsg(Message):\n    name = \"custom-queue-name\"\n```\n\nNow, you can have the Morp command line consumer read from that queue instead:\n\n```\n$ morp custom-queue-name\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Send and receive messages without thinking about it",
    "version": "5.2.2",
    "project_urls": {
        "Homepage": "http://github.com/Jaymon/morp"
    },
    "split_keywords": [
        "amazon",
        "aws",
        "sqs",
        "messages",
        "message-passing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b24b40c24f2a01cbba02eb24f091d278846cf37c5912d39f93907ea88d1476e4",
                "md5": "4a802f8b50a6f732d5a0a2bcf7052098",
                "sha256": "656622cfd126bd805569b435645586bb5365e1406072346b8a5dd3252515fe7e"
            },
            "downloads": -1,
            "filename": "morp-5.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4a802f8b50a6f732d5a0a2bcf7052098",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20492,
            "upload_time": "2023-06-24T21:16:45",
            "upload_time_iso_8601": "2023-06-24T21:16:45.528715Z",
            "url": "https://files.pythonhosted.org/packages/b2/4b/40c24f2a01cbba02eb24f091d278846cf37c5912d39f93907ea88d1476e4/morp-5.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-24 21:16:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Jaymon",
    "github_project": "morp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "morp"
}
        
Elapsed time: 0.29543s