Skip to content

New STDIN mode #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

New STDIN mode #21

wants to merge 1 commit into from

Conversation

Alkarex
Copy link
Contributor

@Alkarex Alkarex commented Jul 4, 2024

New continous mode using STDIN to pass messages. Useful for larger / faster payloads.

Related to #20 (sorry for the poor coordination on my side)

Example of Python code:

import json
import sys

for line in sys.stdin:
    msg = json.loads(line)
    msg['payload'] = msg['payload'] * -1
    print(json.dumps(msg, separators=(',', ':')), flush=True)
flows.json
[
    {
        "id": "f14c248431d474e8",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 260,
        "wires": [
            [
                "8be43bb7c337f2b3"
            ]
        ]
    },
    {
        "id": "b50cd141069d9975",
        "type": "debug",
        "z": "f6f2187d.f17ca8",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 560,
        "y": 260,
        "wires": []
    },
    {
        "id": "8be43bb7c337f2b3",
        "type": "venv",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "code": "import json\nimport sys\n\nfor line in sys.stdin:\n    msg = json.loads(line)\n    msg['payload'] = msg['payload'] * -1\n    print(json.dumps(msg, separators=(',', ':')), flush=True)\n",
        "x": 350,
        "y": 260,
        "wires": [
            [
                "b50cd141069d9975"
            ]
        ]
    }
]

@Alkarex
Copy link
Contributor Author

Alkarex commented Jul 4, 2024

@FrederikPM will take over as am on my way to some vacations 🏖️

code = config.code
} else {
code = msg.code
// config.continuous = true // TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make an option in the UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant