@@ -19,47 +19,51 @@ Easily share functions between hosts, processes, containers without the complexi
1919
2020## Quick Start
2121
22- $ virtualenv -p python3.7 easy-rpc-env
22+ ``` bash
23+ $ virtualenv -p python3.7 easy-rpc-env
2324
24- $ source easy-rpc-env/bin/activate
25+ $ source easy-rpc-env/bin/activate
2526
26- (easy-rpc-env)$ pip install easyrpc
27+ (easy-rpc-env)$ pip install easyrpc
28+ ```
2729
2830## Basic Usage:
2931
30- # server.py
31- from fastapi import FastAPI
32- from easyrpc.server import EasyRpcServer
32+ ``` python
33+ # server.py
34+ from fastapi import FastAPI
35+ from easyrpc.server import EasyRpcServer
36+
37+ server = FastAPI()
38+
39+ ws_server_a = EasyRpcServer(server, ' /ws/server_a' , server_secret = ' abcd1234' )
40+
41+ @ws_server_a.origin (namespace = ' public' )
42+ def good_func_a (a , b , c ):
43+ print (f " good_func_a { a} { b} { c} " )
44+ return {" good_func_a" : [a, b, c]}
45+ ```
46+ ``` python
47+ # client.py
48+ import asyncio
49+ from easyrpc.proxy import EasyRpcProxy
50+
51+ async def main ():
52+ proxy = await EasyRpcProxy.create(
53+ ' 0.0.0.0' ,
54+ 8090 ,
55+ ' /ws/server_a' ,
56+ server_secret = ' abcd1234' ,
57+ ' namespace=' public'
58+ )
59+
60+ good_func_a = proxy[' good_func_a' ]
61+ result = await good_func_a(1 , 5 , 7 )
62+ print (result)
63+
64+ asyncio.run(main())
65+ ```
3366
34- server = FastAPI()
35-
36- ws_server_a = EasyRpcServer(server, '/ws/server_a', server_secret='abcd1234')
37-
38- @ws_server_a.origin(namespace='public')
39- def good_func_a(a, b, c):
40- print(f"good_func_a {a} {b} {c}")
41- return {"good_func_a": [a, b, c]}
42-
43- <br >
44-
45- # client.py
46- import asyncio
47- from easyrpc.proxy import EasyRpcProxy
48-
49- async def main():
50- proxy = await EasyRpcProxy.create(
51- '0.0.0.0',
52- 8090,
53- '/ws/server_a',
54- server_secret='abcd1234',
55- 'namespace='public'
56- )
57-
58- good_func_a = proxy['good_func_a']
59- result = await good_func_a(1, 5, 7)
60- print(result)
61-
62- asyncio.run(main())
6367## Recipes
6468See other usage examples in [ Recipes] ( https://github.com/codemation/easyrpc/tree/main/recipes )
6569- [ basic] ( https://github.com/codemation/easyrpc/tree/main/recipes/basic )
@@ -80,4 +84,4 @@ See other usage examples in [Recipes](https://github.com/codemation/easyrpc/tree
8084- Shared Database connections / cache
8185- Shared Queues
8286- Worker Pooling - Easy centralization for workers and distribution of work.
83- - Function Chaining
87+ - Function Chaining
0 commit comments