Skip to main content

deepfos系统使用的unix socket协议

Project description

客户端调用测试用例

async def run():
    m = MasterServer("../unix_sock.sock", config="xxx.json")
    await m.task()

asyncio.run(run())

服务端自定义逻辑测试用例

''' protocol可以支持到让我在server端加入自定义逻辑, 比如可以传一个object, 这个object有dispatch方法, 每次你parse完,调这个dispatch,把mtype和解析结果传进去, 在其中我写自己定制化的逻辑 '''

async def async_main():
    m = WorkerClient("../unix_sock.sock", config="aaa.json")
    await m.create_conn() # 建立一个连接
    await m.send_msg("O", "你好")

    await WorkerClient.send_msg(
        "U", [
            {
                "key": "key",
                "name": "你好",
                "status": "status",
                "endTime": "endTime",
                "arg": "xxxx"
            }
        ]
    )
    await WorkerClient.send_msg(
        "H", {"header": "你好"}
    )
    await WorkerClient.send_msg(
        "I", [
            {
                "key": "key",
                "name": "name",
            }
        ]
    )
    await WorkerClient.send_msg(
        "E", "xxxss"
    )
    await WorkerClient.send_msg(
        "e", {"subtask_err": "err", "arg": "arg"}
    )
    await WorkerClient.send_msg(
        "o", {"subtask_out": "out", "arg": "arg"}
    )
    await m.close()
    await m.send_msg("O", "hello3")

asyncio.run(async_main())

''' 第一个参数为sock文件位置, config参数为配置参数 之后的参数都是可选参数 当ins参数为类对象时,后面必须带一个func参数,值为类下的方法名 无论使用类方法还是直接使用函数必须增加两个参数位置参数,mtype和data '''

config.json

{
    "HEADER_PROTOCOL": [
        {
            "H": ["header"]
        },
        {
            "o": ["arg", "subtask_out"]
        },
        {
            "e": ["arg", "subtask_err"]
        }
    ],
    "MESSAGE_PROTOCOL": ["O", "E"],
    "DETAILLIST_PROTOCOL": [
        {
            "I": ["key", "name"]
        },
        {
            "U": ["key", "status", "endTime", "name", "arg"]
        }
    ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepfos-ipc-protocol-1.0.11.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepfos_ipc_protocol-1.0.11-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file deepfos-ipc-protocol-1.0.11.tar.gz.

File metadata

  • Download URL: deepfos-ipc-protocol-1.0.11.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for deepfos-ipc-protocol-1.0.11.tar.gz
Algorithm Hash digest
SHA256 6d0188b2e3999b6d39b8e9a5aeba1222804f76264ac7b3fb5a6d9e5ab0d7e0ba
MD5 e94037a593aaf06879a213e7ac03b819
BLAKE2b-256 cb41220d99fd9a94d68b89f2459c57e3a26d55bdcb3143c7ecf7d20293e9c602

See more details on using hashes here.

File details

Details for the file deepfos_ipc_protocol-1.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for deepfos_ipc_protocol-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 00d1a2e494bc234df8c8b8f0bd67ba243f0b753f6e42a7506b0f577cdfa7f4dd
MD5 dca3e4ba85cc6b73ad33c47d9ef36511
BLAKE2b-256 6aa03e0aade45c3275811b97153dd6e22b13044b92fd6759de457c2c9c6f52a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page