Skip to main content

Python plugin over gRPC for funplugin

Project description

Python plugin over gRPC

install SDK

Before you develop your python plugin, you need to install an dependency as SDK.

$ python3 -m pip install funppy

create plugin functions

Then you can write your plugin functions in python. The functions can be very flexible, only the following restrictions should be complied with.

  • function should return at most one value and one error.
  • funppy.register() must be called to register plugin functions and funppy.serve() must be called to start a plugin server process.

Here is some plugin functions as example.

import logging
from typing import List

import funppy


def sum_two_int(a: int, b: int) -> int:
    return a + b

def sum_ints(*args: List[int]) -> int:
    result = 0
    for arg in args:
        result += arg
    return result

def Sum(*args):
    result = 0
    for arg in args:
        result += arg
    return result


if __name__ == '__main__':
    funppy.register("sum_two_int", sum_two_int)
    funppy.register("sum_ints", sum_ints)
    funppy.register("sum", Sum)
    funppy.serve()

You can get more examples at funppy/examples/.

build plugin

Python plugins do not need to be complied, just make sure its file suffix is .py by convention and should not be changed.

use plugin functions

Finally, you can use Init to initialize plugin via the xxx.py path, and you can call the plugin API to handle plugin functionality.

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

funppy-0.4.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

funppy-0.4.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file funppy-0.4.0.tar.gz.

File metadata

  • Download URL: funppy-0.4.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.3.0

File hashes

Hashes for funppy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 43ad2a4d24d1c29837b470157df62581e270dbf368f4fd92e2f35790adc6d7e7
MD5 f62d4fd0f4b984c63d0fc19fb2ca3995
BLAKE2b-256 7f8b669da2470771c204db29634790f20bd0a36455dcbc4b2e9b7fa31a87d246

See more details on using hashes here.

File details

Details for the file funppy-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: funppy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.3.0

File hashes

Hashes for funppy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b46b0371a51685142794da9d82d9d1666e31c9d9eec4480e5c4e68b0c90503f3
MD5 231f23f1982bd3e24fa47e1b0b2d56ad
BLAKE2b-256 c43d02438f36c5ae81385d0e42da3a81c657b5fe7409625e58f113ad29d01425

See more details on using hashes here.

Supported by

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