Feat #58 - fix backpressure logic and update tests
This commit is contained in:
@@ -7,10 +7,11 @@ import json
|
||||
import re
|
||||
from datetime import datetime, timezone
|
||||
from io import BytesIO
|
||||
from typing import Dict, List
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import amqp.adapter.file_handler
|
||||
from amqp.adapter.file_handler import FileHandler, StreamingFileHandler
|
||||
from amqp.adapter.pydantic_serializer import python_type_to_json
|
||||
from amqp.adapter.serializer import (
|
||||
map_as_string,
|
||||
map_with_list_as_string,
|
||||
@@ -112,6 +113,32 @@ class DataMessageFactory:
|
||||
payload,
|
||||
)
|
||||
|
||||
def create_rpc_message(
|
||||
self,
|
||||
fq_method_name: str,
|
||||
swarm_id: str,
|
||||
args: Dict[str, Any] = None,
|
||||
) -> DataMessage:
|
||||
"""
|
||||
Create a RPC message with the given parameters.
|
||||
:param fq_method_name: fully qualified method name (e.g. 'com.example.ServiceClass.method_name')
|
||||
:param args: arguments whose serialized form will form the request body
|
||||
:return: DataMessage object
|
||||
"""
|
||||
package, class_name, method = fq_method_name.rsplit(".", 2)
|
||||
headers = {"Content-Type": ["application/octet-stream"], "Return-Address": [swarm_id]}
|
||||
trace_info = {}
|
||||
return DataMessage(
|
||||
DataMessageMagicByte.RPC_REQUEST.value,
|
||||
self.generate_snowflake_id(),
|
||||
package,
|
||||
class_name,
|
||||
method,
|
||||
headers,
|
||||
trace_info,
|
||||
python_type_to_json(args) if args else b"",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def amq_message_routing_key(message: DataMessage) -> str:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user