1
1
import dataclasses
2
2
from dataclasses import dataclass
3
3
from typing import Any , Mapping , Optional
4
+ from urllib .parse import urlparse
4
5
5
6
import temporalio .api .failure .v1
6
7
import temporalio .api .nexus .v1
@@ -59,7 +60,7 @@ async def start_operation(
59
60
# TODO(nexus-preview): Support callback URL as query param
60
61
async with httpx .AsyncClient () as http_client :
61
62
return await http_client .post (
62
- f"{ self .server_address } /nexus/endpoints/{ self .endpoint } /services/{ self .service } /{ operation } " ,
63
+ f"http:// { self .server_address } /nexus/endpoints/{ self .endpoint } /services/{ self .service } /{ operation } " ,
63
64
json = body ,
64
65
headers = headers ,
65
66
)
@@ -71,7 +72,7 @@ async def cancel_operation(
71
72
) -> httpx .Response :
72
73
async with httpx .AsyncClient () as http_client :
73
74
return await http_client .post (
74
- f"{ self .server_address } /nexus/endpoints/{ self .endpoint } /services/{ self .service } /{ operation } /cancel" ,
75
+ f"http:// { self .server_address } /nexus/endpoints/{ self .endpoint } /services/{ self .service } /{ operation } /cancel" ,
75
76
# Token can also be sent as "Nexus-Operation-Token" header
76
77
params = {"token" : token },
77
78
)
@@ -80,8 +81,10 @@ async def cancel_operation(
80
81
def default_server_address (env : WorkflowEnvironment ) -> str :
81
82
# TODO(nexus-preview): nexus tests are making http requests directly but this is
82
83
# not officially supported.
84
+ parsed = urlparse (env .client .service_client .config .target_host )
85
+ host = parsed .hostname or "127.0.0.1"
83
86
http_port = getattr (env , "_http_port" , 7243 )
84
- return f"http://127.0.0.1 :{ http_port } "
87
+ return f"{ host } :{ http_port } "
85
88
86
89
87
90
def dataclass_as_dict (dataclass : Any ) -> dict [str , Any ]:
0 commit comments