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 andfunppy.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
Built Distribution
File details
Details for the file funppy-0.4.2.tar.gz
.
File metadata
- Download URL: funppy-0.4.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.10 Darwin/21.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08a5c1aed80c6a77876cd2d07db74fa13cf86d0ca238140812e7b86e28d24966 |
|
MD5 | 9d0400cd0f67e070d437b730d6562f3d |
|
BLAKE2b-256 | 31165cf3b57bbe8ba4a514c967b7ee3ac7cf92eda0f529c27308e72b8742519f |
File details
Details for the file funppy-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: funppy-0.4.2-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a76c0116ae4423589291cea80fcdd388dee20c27af2c07cda1db5d34c9729cad |
|
MD5 | 1e3728bce95e1a138fdd797484ed497d |
|
BLAKE2b-256 | 481e0e9247afcbb9fe02863796cb0a53787f7b1aba57c5fedaaca0c2a267b65b |