debug less
This commit is contained in:
parent
c3639fd331
commit
62aeec6faf
@ -1114,8 +1114,8 @@ impl NetworkManager {
|
|||||||
connection_descriptor: ConnectionDescriptor, // the connection descriptor used
|
connection_descriptor: ConnectionDescriptor, // the connection descriptor used
|
||||||
reporting_peer: NodeRef, // the peer's noderef reporting the socket address
|
reporting_peer: NodeRef, // the peer's noderef reporting the socket address
|
||||||
) {
|
) {
|
||||||
// debug code
|
#[cfg(feature = "verbose-tracing")]
|
||||||
//info!("report_global_socket_address\nsocket_address: {:#?}\nconnection_descriptor: {:#?}\nreporting_peer: {:#?}", socket_address, connection_descriptor, reporting_peer);
|
debug!("report_global_socket_address\nsocket_address: {:#?}\nconnection_descriptor: {:#?}\nreporting_peer: {:#?}", socket_address, connection_descriptor, reporting_peer);
|
||||||
|
|
||||||
// Ignore these reports if we are currently detecting public dial info
|
// Ignore these reports if we are currently detecting public dial info
|
||||||
let net = self.net();
|
let net = self.net();
|
||||||
|
@ -31,7 +31,8 @@ impl NetworkManager {
|
|||||||
cm => (cm, target_node_ref.clone(), false),
|
cm => (cm, target_node_ref.clone(), false),
|
||||||
};
|
};
|
||||||
|
|
||||||
info!(
|
#[cfg(feature = "verbose-tracing")]
|
||||||
|
debug!(
|
||||||
"ContactMethod: {:?} for {:?}",
|
"ContactMethod: {:?} for {:?}",
|
||||||
contact_method, target_node_ref
|
contact_method, target_node_ref
|
||||||
);
|
);
|
||||||
@ -247,10 +248,12 @@ impl NetworkManager {
|
|||||||
|
|
||||||
// First try to send data to the last socket we've seen this peer on
|
// First try to send data to the last socket we've seen this peer on
|
||||||
let data = if let Some(connection_descriptor) = node_ref.last_connection() {
|
let data = if let Some(connection_descriptor) = node_ref.last_connection() {
|
||||||
info!(
|
#[cfg(feature = "verbose-tracing")]
|
||||||
|
debug!(
|
||||||
"ExistingConnection: {:?} for {:?}",
|
"ExistingConnection: {:?} for {:?}",
|
||||||
connection_descriptor, node_ref
|
connection_descriptor, node_ref
|
||||||
);
|
);
|
||||||
|
|
||||||
match self
|
match self
|
||||||
.net()
|
.net()
|
||||||
.send_data_to_existing_connection(connection_descriptor, data)
|
.send_data_to_existing_connection(connection_descriptor, data)
|
||||||
|
@ -1134,7 +1134,8 @@ impl RPCProcessor {
|
|||||||
let op_id = operation.op_id();
|
let op_id = operation.op_id();
|
||||||
|
|
||||||
// Log rpc send
|
// Log rpc send
|
||||||
trace!(target: "rpc_message", dir = "send", kind = "question", op_id = op_id.as_u64(), desc = operation.kind().desc(), ?dest);
|
#[cfg(feature = "verbose-tracing")]
|
||||||
|
debug!(target: "rpc_message", dir = "send", kind = "question", op_id = op_id.as_u64(), desc = operation.kind().desc(), ?dest);
|
||||||
|
|
||||||
// Produce rendered operation
|
// Produce rendered operation
|
||||||
let RenderedOperation {
|
let RenderedOperation {
|
||||||
@ -1228,7 +1229,8 @@ impl RPCProcessor {
|
|||||||
let operation = RPCOperation::new_statement(statement, spi);
|
let operation = RPCOperation::new_statement(statement, spi);
|
||||||
|
|
||||||
// Log rpc send
|
// Log rpc send
|
||||||
info!(target: "rpc_message", dir = "send", kind = "statement", op_id = operation.op_id().as_u64(), desc = operation.kind().desc(), ?dest);
|
#[cfg(feature = "verbose-tracing")]
|
||||||
|
debug!(target: "rpc_message", dir = "send", kind = "statement", op_id = operation.op_id().as_u64(), desc = operation.kind().desc(), ?dest);
|
||||||
|
|
||||||
// Produce rendered operation
|
// Produce rendered operation
|
||||||
let RenderedOperation {
|
let RenderedOperation {
|
||||||
@ -1305,7 +1307,8 @@ impl RPCProcessor {
|
|||||||
let operation = RPCOperation::new_answer(&request.operation, answer, spi);
|
let operation = RPCOperation::new_answer(&request.operation, answer, spi);
|
||||||
|
|
||||||
// Log rpc send
|
// Log rpc send
|
||||||
trace!(target: "rpc_message", dir = "send", kind = "answer", op_id = operation.op_id().as_u64(), desc = operation.kind().desc(), ?dest);
|
#[cfg(feature = "verbose-tracing")]
|
||||||
|
debug!(target: "rpc_message", dir = "send", kind = "answer", op_id = operation.op_id().as_u64(), desc = operation.kind().desc(), ?dest);
|
||||||
|
|
||||||
// Produce rendered operation
|
// Produce rendered operation
|
||||||
let RenderedOperation {
|
let RenderedOperation {
|
||||||
|
@ -22,7 +22,7 @@ def server_info() -> tuple[str, int]:
|
|||||||
return hostname, 5959
|
return hostname, 5959
|
||||||
|
|
||||||
|
|
||||||
async def simple_update_callback(update: veilid.VeilidUpdate):
|
async def simple_update_callback(api: veilid.VeilidAPI, update: veilid.VeilidUpdate):
|
||||||
print(f"VeilidUpdate: {update}")
|
print(f"VeilidUpdate: {update}")
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import veilid
|
import veilid
|
||||||
@ -29,7 +30,7 @@ async def test_routing_context_app_message_loopback():
|
|||||||
# Seriously, mypy?
|
# Seriously, mypy?
|
||||||
app_message_queue: asyncio.Queue = asyncio.Queue()
|
app_message_queue: asyncio.Queue = asyncio.Queue()
|
||||||
|
|
||||||
async def app_message_queue_update_callback(update: veilid.VeilidUpdate):
|
async def app_message_queue_update_callback(api: veilid.VeilidAPI, update: veilid.VeilidUpdate):
|
||||||
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
|
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
|
||||||
await app_message_queue.put(update)
|
await app_message_queue.put(update)
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ async def test_routing_context_app_message_loopback():
|
|||||||
async def test_routing_context_app_call_loopback():
|
async def test_routing_context_app_call_loopback():
|
||||||
app_call_queue: asyncio.Queue = asyncio.Queue()
|
app_call_queue: asyncio.Queue = asyncio.Queue()
|
||||||
|
|
||||||
async def app_call_queue_update_callback(update: veilid.VeilidUpdate):
|
async def app_call_queue_update_callback(api: veilid.VeilidAPI, update: veilid.VeilidUpdate):
|
||||||
if update.kind == veilid.VeilidUpdateKind.APP_CALL:
|
if update.kind == veilid.VeilidUpdateKind.APP_CALL:
|
||||||
await app_call_queue.put(update)
|
await app_call_queue.put(update)
|
||||||
|
|
||||||
@ -119,11 +120,11 @@ async def test_routing_context_app_message_loopback_big_packets():
|
|||||||
|
|
||||||
global got_message
|
global got_message
|
||||||
got_message = 0
|
got_message = 0
|
||||||
async def app_message_queue_update_callback(update: veilid.VeilidUpdate):
|
async def app_message_queue_update_callback(api: veilid.VeilidAPI, update: veilid.VeilidUpdate):
|
||||||
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
|
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
|
||||||
global got_message
|
global got_message
|
||||||
got_message += 1
|
got_message += 1
|
||||||
print("got {}".format(got_message))
|
sys.stdout.write("{} ".format(got_message))
|
||||||
await app_message_queue.put(update)
|
await app_message_queue.put(update)
|
||||||
|
|
||||||
sent_messages: set[bytes] = set()
|
sent_messages: set[bytes] = set()
|
||||||
@ -165,3 +166,45 @@ async def test_routing_context_app_message_loopback_big_packets():
|
|||||||
assert isinstance(update.detail, veilid.VeilidAppMessage)
|
assert isinstance(update.detail, veilid.VeilidAppMessage)
|
||||||
|
|
||||||
assert update.detail.message in sent_messages
|
assert update.detail.message in sent_messages
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_routing_context_app_call_loopback_big_packets():
|
||||||
|
|
||||||
|
print("")
|
||||||
|
|
||||||
|
global got_message
|
||||||
|
got_message = 0
|
||||||
|
async def app_message_queue_update_callback(api: veilid.VeilidAPI, update: veilid.VeilidUpdate):
|
||||||
|
if update.kind == veilid.VeilidUpdateKind.APP_CALL:
|
||||||
|
global got_message
|
||||||
|
got_message += 1
|
||||||
|
sys.stdout.write("{} ".format(got_message))
|
||||||
|
sys.stdout.flush()
|
||||||
|
await api.app_call_reply(update.detail.call_id, update.detail.message)
|
||||||
|
|
||||||
|
hostname, port = server_info()
|
||||||
|
api = await veilid.json_api_connect(
|
||||||
|
hostname, port, app_message_queue_update_callback
|
||||||
|
)
|
||||||
|
async with api:
|
||||||
|
# purge routes to ensure we start fresh
|
||||||
|
await api.debug("purge routes")
|
||||||
|
|
||||||
|
# make a routing context that uses a safety route
|
||||||
|
rc = await (await (await api.new_routing_context()).with_privacy()).with_sequencing(veilid.Sequencing.ENSURE_ORDERED)
|
||||||
|
async with rc:
|
||||||
|
|
||||||
|
# make a new local private route
|
||||||
|
prl, blob = await api.new_private_route()
|
||||||
|
|
||||||
|
# import it as a remote route as well so we can send to it
|
||||||
|
prr = await api.import_remote_private_route(blob)
|
||||||
|
|
||||||
|
# do this test 100 times
|
||||||
|
for _ in range(100):
|
||||||
|
|
||||||
|
# send a random sized random app message to our own private route
|
||||||
|
message = random.randbytes(random.randint(0, 32768))
|
||||||
|
out_message = await rc.app_call(prr, message)
|
||||||
|
|
||||||
|
assert message == out_message
|
||||||
|
@ -51,7 +51,7 @@ _VALIDATOR_RECV_MESSAGE = _get_schema_validator(
|
|||||||
class _JsonVeilidAPI(VeilidAPI):
|
class _JsonVeilidAPI(VeilidAPI):
|
||||||
reader: Optional[asyncio.StreamReader]
|
reader: Optional[asyncio.StreamReader]
|
||||||
writer: Optional[asyncio.StreamWriter]
|
writer: Optional[asyncio.StreamWriter]
|
||||||
update_callback: Callable[[VeilidUpdate], Awaitable]
|
update_callback: Callable[[VeilidAPI, VeilidUpdate], Awaitable]
|
||||||
handle_recv_messages_task: Optional[asyncio.Task]
|
handle_recv_messages_task: Optional[asyncio.Task]
|
||||||
validate_schema: bool
|
validate_schema: bool
|
||||||
done: bool
|
done: bool
|
||||||
@ -64,7 +64,7 @@ class _JsonVeilidAPI(VeilidAPI):
|
|||||||
self,
|
self,
|
||||||
reader: asyncio.StreamReader,
|
reader: asyncio.StreamReader,
|
||||||
writer: asyncio.StreamWriter,
|
writer: asyncio.StreamWriter,
|
||||||
update_callback: Callable[[VeilidUpdate], Awaitable],
|
update_callback: Callable[[VeilidAPI, VeilidUpdate], Awaitable],
|
||||||
validate_schema: bool = True,
|
validate_schema: bool = True,
|
||||||
):
|
):
|
||||||
self.reader = reader
|
self.reader = reader
|
||||||
@ -115,7 +115,7 @@ class _JsonVeilidAPI(VeilidAPI):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def connect(
|
async def connect(
|
||||||
cls, host: str, port: int, update_callback: Callable[[VeilidUpdate], Awaitable]
|
cls, host: str, port: int, update_callback: Callable[[VeilidAPI, VeilidUpdate], Awaitable]
|
||||||
) -> Self:
|
) -> Self:
|
||||||
reader, writer = await asyncio.open_connection(host, port)
|
reader, writer = await asyncio.open_connection(host, port)
|
||||||
veilid_api = cls(reader, writer, update_callback)
|
veilid_api = cls(reader, writer, update_callback)
|
||||||
@ -155,7 +155,7 @@ class _JsonVeilidAPI(VeilidAPI):
|
|||||||
if j["type"] == "Response":
|
if j["type"] == "Response":
|
||||||
await self.handle_recv_message_response(j)
|
await self.handle_recv_message_response(j)
|
||||||
elif j["type"] == "Update":
|
elif j["type"] == "Update":
|
||||||
await self.update_callback(VeilidUpdate.from_json(j))
|
await self.update_callback(self, VeilidUpdate.from_json(j))
|
||||||
finally:
|
finally:
|
||||||
await self._cleanup_close()
|
await self._cleanup_close()
|
||||||
|
|
||||||
@ -1162,6 +1162,6 @@ class _JsonCryptoSystem(CryptoSystem):
|
|||||||
|
|
||||||
|
|
||||||
async def json_api_connect(
|
async def json_api_connect(
|
||||||
host: str, port: int, update_callback: Callable[[VeilidUpdate], Awaitable]
|
host: str, port: int, update_callback: Callable[[VeilidAPI, VeilidUpdate], Awaitable]
|
||||||
) -> _JsonVeilidAPI:
|
) -> _JsonVeilidAPI:
|
||||||
return await _JsonVeilidAPI.connect(host, port, update_callback)
|
return await _JsonVeilidAPI.connect(host, port, update_callback)
|
||||||
|
Loading…
Reference in New Issue
Block a user