semvec/pypi-packages huggingface dataset:
mause-rpc 0.0.20
A dumb as hell rpc implementation built on rabbitmq
License: MIT
Requires Python: >=3.8,<4.0
Keywords: rabbitmq,rpc

Mause RPC
=========

A dumb as hell rpc implementation built on rabbitmq

Need to write a server?

```py
from mause_rpc.server import Server

rpc_queue = 'rpc.queue'
server = Server(rpc_queue, 'rabbitmq://...')


@server.register
def hello(name: str) -> str:
    return 'hello ' + name


@server.register('divide')
def div(a: int, b: int) -> float:
    if b == 0:
        raise ZeroDivisionError()
    return a / b


if __name__ == '__main__':
    server.serve()

```

Need a client?

```py
from mause_rpc.client import get_client

rpc_queue = 'rpc.queue'
client = get_client(rpc_queue, 'rabbitmq://...')


def test_basic_functionality():
    assert client.hello('mark') == 'hello mark'
    assert client.divide(5, 2) == 2.5

    with pytest.raises(ZeroDivisionError):
        client.divide(5, 0)
```
apm-agent-utils 1.4
This package can help you create Elastic APM instrumentations using regex
License: MIT
Requires Python: >=2.7
Keywords: apm,elastic,utils,apm-utils,agent

## Elastic APM Agent Utils
This package can help you create Elastic APM instrumentations using regex.

### Dependencies
1. `python2.7+ || python3.6+`  
2. `elastic-apm 5.4.0+`  

### Installation
```sh
pip install apm-agent-utils
```

### Usage
Create a file named `instrumentations.py`
```python
# instrumentations.py
from apm_agent_utils.instrumentation import InstrumentationBuilder

builder = InstrumentationBuilder("Test")
builder.add_instrument("logic.logic1", r"^hello.*")  # finding and wrapping your funtions by regex
builder.add_instrument("logic.logic2", r".*")

Test = builder.create_instrument()
```
In your `app.py`, adding the following lines at top of the file.  
```python
import elasticapm
from apm_agent_utils.utils import add_instrumentation

add_instrumentation("instrumentations.Test")
elasticapm.instrument()
```
==> `app.py`  
```python
# app.py
import elasticapm
from apm_agent_utils.utils import add_instrumentation
from elasticapm.contrib.flask import ElasticAPM
from flask import Flask

add_instrumentation("instrumentations.Instrument")
elasticapm.instrument()

app = Flask(__name__)
app.config['ELASTIC_APM'] = {
    'SERVICE_NAME': 'vuonglv_test',
    'SECRET_TOKEN': '#####',
    'SERVER_URL': 'http://##.##.##.##:8200/',
    'DEBUG': True
}

apm = ElasticAPM(app)
```
`main.py` - your controllers
```python
# main.py
from app import app

from logic.logic1 import hello
from logic.logic2 import foo, bar


@app.route("/")
def run():
    print(hello())
    print(foo())
    print(bar())
    return {"ok": True}


if __name__ == "__main__":
    app.run(debug=True)
```
Project structure look like this:  
![structure](screenshots/structure.png)  
Run app
```bash
python3 main.py
```
Get your endpoint
```curl
curl --location --request GET 'http://localhost:5000'
```
Goto your APM dashboard, result look like this:
![successful dashboard](screenshots/dashboard.png)