appmesh 1.2.2__py3-none-any.whl → 1.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
appmesh/appmesh_client.py CHANGED
@@ -21,8 +21,8 @@ import requests
21
21
  # pylint: disable=broad-exception-raised,line-too-long,broad-exception-caught,too-many-lines, import-outside-toplevel
22
22
 
23
23
  DEFAULT_TOKEN_EXPIRE_SECONDS = "P1W" # default 7 day(s)
24
- DEFAULT_RUN_APP_TIMEOUT_SECONDS = "PT1H" # 1 hour
25
- DEFAULT_RUN_APP_LIFECYCLE_SECONDS = "PT10H" # 10 hours
24
+ DEFAULT_RUN_APP_TIMEOUT_SECONDS = "P2D" # 2 days
25
+ DEFAULT_RUN_APP_LIFECYCLE_SECONDS = "P2DT12H" # 2.5 days
26
26
  REST_TEXT_MESSAGE_JSON_KEY = "message"
27
27
  MESSAGE_ENCODING_UTF8 = "utf-8"
28
28
  TCP_MESSAGE_HEADER_LENGTH = 4
@@ -359,10 +359,11 @@ class AppMeshClient(metaclass=abc.ABCMeta):
359
359
  """
360
360
 
361
361
  self.server_url = rest_url
362
- self.__jwt_token = jwt_token
362
+ self._jwt_token = jwt_token
363
363
  self.ssl_verify = rest_ssl_verify
364
364
  self.ssl_client_cert = rest_ssl_client_cert
365
365
  self.rest_timeout = rest_timeout
366
+ self._delegate_host = None
366
367
 
367
368
  @property
368
369
  def jwt_token(self) -> str:
@@ -371,7 +372,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
371
372
  Returns:
372
373
  str: _description_
373
374
  """
374
- return self.__jwt_token
375
+ return self._jwt_token
375
376
 
376
377
  @jwt_token.setter
377
378
  def jwt_token(self, token: str) -> None:
@@ -380,7 +381,25 @@ class AppMeshClient(metaclass=abc.ABCMeta):
380
381
  Args:
381
382
  token (str): _description_
382
383
  """
383
- self.__jwt_token = token
384
+ self._jwt_token = token
385
+
386
+ @property
387
+ def delegate_host(self) -> str:
388
+ """property for delegate_host
389
+
390
+ Returns:
391
+ str: delegate request to target host (host:port)
392
+ """
393
+ return self._delegate_host
394
+
395
+ @delegate_host.setter
396
+ def delegate_host(self, host: str) -> None:
397
+ """setter for delegate_host
398
+
399
+ Args:
400
+ host (str): delegate request to target host (host:port)
401
+ """
402
+ self._delegate_host = host
384
403
 
385
404
  ########################################
386
405
  # Security
@@ -1298,6 +1317,11 @@ class AppMeshClient(metaclass=abc.ABCMeta):
1298
1317
  header = {} if header is None else header
1299
1318
  if self.jwt_token:
1300
1319
  header["Authorization"] = "Bearer " + self.jwt_token
1320
+ if self.delegate_host and len(self.delegate_host) > 0:
1321
+ if ":" in self.delegate_host:
1322
+ header["X-Target-Host"] = self.delegate_host
1323
+ else:
1324
+ header["X-Target-Host"] = self.delegate_host + ":" + str(parse.urlsplit(self.server_url).port)
1301
1325
  header[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT
1302
1326
 
1303
1327
  if method is AppMeshClient.Method.GET:
@@ -1371,6 +1395,8 @@ class AppMeshClientTCP(AppMeshClient):
1371
1395
  self.__socket_client = context.wrap_socket(sock, server_hostname=self.tcp_address[0])
1372
1396
  # Connect to the server
1373
1397
  self.__socket_client.connect(self.tcp_address)
1398
+ # Disable Nagle's algorithm
1399
+ self.__socket_client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
1374
1400
 
1375
1401
  def __close_socket(self) -> None:
1376
1402
  """Close socket connection"""
@@ -1459,6 +1485,11 @@ class AppMeshClientTCP(AppMeshClient):
1459
1485
  appmesh_requst = RequestMsg()
1460
1486
  if super().jwt_token:
1461
1487
  appmesh_requst.headers["Authorization"] = "Bearer " + super().jwt_token
1488
+ if super().delegate_host and len(super().delegate_host) > 0:
1489
+ if ":" in super().delegate_host:
1490
+ appmesh_requst.headers["X-Target-Host"] = super().delegate_host
1491
+ else:
1492
+ appmesh_requst.headers["X-Target-Host"] = super().delegate_host + ":" + str(parse.urlsplit(self.server_url).port)
1462
1493
  appmesh_requst.headers[HTTP_USER_AGENT_HEADER_NAME] = HTTP_USER_AGENT
1463
1494
  appmesh_requst.uuid = str(uuid.uuid1())
1464
1495
  appmesh_requst.http_method = method.value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: appmesh
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: Client SDK for App Mesh
5
5
  Home-page: https://github.com/laoshanxi/app-mesh
6
6
  Author: laoshanxi
@@ -43,7 +43,7 @@ Cloud native | Schedule cloud-level applications to run on multiple hosts with r
43
43
  Micro service application | ⚡️ [Consul micro-service cluster management](https://app-mesh.readthedocs.io/en/latest/CONSUL.html)
44
44
  Extra Features | Collect host/app resource usage <br> Remote shell command execution <br> File upload/download interface <br> Hot-update support `systemctl reload appmesh` <br> Bash completion <br> Reverse proxy <br> [Web GUI](https://github.com/laoshanxi/app-mesh-ui)
45
45
  Platform support | X86_64 <br> ARM32 <br> ARM64
46
- SDK | [Python](https://app-mesh.readthedocs.io/en/latest/api/appmesh_client.html) <br> [Golang](https://github.com/laoshanxi/app-mesh/blob/main/src/sdk/go/appmesh_client.go) <br> Swagger [OpenAPI Specification](https://raw.githubusercontent.com/laoshanxi/app-mesh/main/src/daemon/rest/openapi.yaml) `https://localhost:6060/swagger`
46
+ SDK | [Python](https://app-mesh.readthedocs.io/en/latest/api/appmesh_client.html) <br> [Golang](https://github.com/laoshanxi/app-mesh/blob/main/src/sdk/go/appmesh_client.go) <br> [Swagger OpenAPI Specification](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/laoshanxi/app-mesh/main/src/daemon/rest/openapi.yaml)
47
47
 
48
48
  ## Getting started
49
49
 
@@ -0,0 +1,6 @@
1
+ appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
2
+ appmesh/appmesh_client.py,sha256=HBAjO77YIsBCLwKl9oM2ajtlR6BuW1ctKBPxvNrZq0w,61947
3
+ appmesh-1.2.4.dist-info/METADATA,sha256=218Garru27v7El3OqdpKSc94pi4SXr9bxOI-G8IdxuY,10927
4
+ appmesh-1.2.4.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
5
+ appmesh-1.2.4.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
6
+ appmesh-1.2.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- appmesh/__init__.py,sha256=xRdXeFHEieRauuJZElbEBASgXG0ZzU1a5_0isAhM7Gw,11
2
- appmesh/appmesh_client.py,sha256=b1UOMQm8GUy6WAl3385YGMbs4qyZqKukZn9vx8RRswU,60702
3
- appmesh-1.2.2.dist-info/METADATA,sha256=KKa_D2yOSXcf_lrhou76EJ7A3b5Lp5MCu6LLmA0mB9w,10928
4
- appmesh-1.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
5
- appmesh-1.2.2.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
6
- appmesh-1.2.2.dist-info/RECORD,,