File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ from typing import Dict
2
+ import httpx
3
+
4
+
5
+ class FunctionsClient :
6
+ def __init__ (self , url : str , headers : Dict ):
7
+ self .url = url
8
+ self .headers = headers
9
+
10
+ async def invoke (self , function_name : str , invoke_options : Dict ):
11
+ try :
12
+ headers = invoke_options .get ('headers' )
13
+ body = invoke_options .get ('body' )
14
+ response = await httpx .post (f"{ self .url } /{ function_name } " , headers = headers )
15
+ is_relay_error = response .headers .get ('x-relay-header' )
16
+ if is_relay_error and is_relay_error == 'true' :
17
+ return {
18
+ "data" : None ,
19
+ "error" : response .tex
20
+ }
21
+ # TODO: Convert type accordingly
22
+
23
+ return {"data" : response .data , "error" : None }
24
+ except Exception as e :
25
+ return {
26
+ "data" : None ,
27
+ "error" : e
28
+ }
Original file line number Diff line number Diff line change
1
+ [tool .poetry ]
2
+ name = " functionz"
3
+ version = " 0.1.0"
4
+ description = " "
5
+ authors = [" Joel Lee <joel@joellee.org>" ]
6
+ license = " MIT"
7
+
8
+ [tool .poetry .dependencies ]
9
+ python = " ^3.9"
10
+
11
+ [tool .poetry .dev-dependencies ]
12
+
13
+ [build-system ]
14
+ requires = [" poetry-core>=1.0.0" ]
15
+ build-backend = " poetry.core.masonry.api"
You can’t perform that action at this time.
0 commit comments