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.5.2.tar.gz
.
File metadata
- Download URL: funppy-0.5.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a65b14da7b1507118e944141d9401ad2ba199262bf6e35b4ef35554dcb817e9 |
|
MD5 | b0c1c63e8a47b8478c3ce7f0dac02a70 |
|
BLAKE2b-256 | b18fa734c6cb96e72189c4137b251536436d12a50ae8f63c0a8cc5cc00cab370 |
File details
Details for the file funppy-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: funppy-0.5.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85a9ced74a4a9560e179ae5c57cf262e8db2d023d13760d1a5261a9b3e8cb58b |
|
MD5 | 883eb27203debe55f7fb19b5ef37f759 |
|
BLAKE2b-256 | 885717478f5b44110c3f5e5a88853d83749199fcadf1415cd490ff3c818ba488 |