跳转到正文

recording API ​

完整接口目录 · 协议包用法 · 工具包下载

模块说明 ​

text
Bounded, single-reader packet archives. Reading never connects or sends.

SCHEMA ​

python
SCHEMA = 'neomega-packet-recording-v1'

DEFAULT_SECONDS ​

python
DEFAULT_SECONDS = 30

DEFAULT_MAX_EVENTS ​

python
DEFAULT_MAX_EVENTS = 1000

DEFAULT_MAX_BYTES ​

python
DEFAULT_MAX_BYTES = 8 << 20

open_recording ​

python
def open_recording(data_dir, *, prefix='packet-observation-')

SDK 说明:

text
Create a private, exclusive archive directly in the Host data directory.

PacketRecorder ​

python
class PacketRecorder

SDK 说明:

text
Synchronous sink owned by an existing stream's only reader.

record() and note() return False when recording must stop. Check
limit_reason even on idle polls. Close the stream before finish(); pass any
stream/cancellation/close error to finish(error=...). No implicit reader,
subscription, background task or retry is created here.

PacketRecorder.__init__ ​

python
def __init__(
    self,
    output,
    *,
    session,
    snapshot,
    packet_catalog = (),
    seconds = DEFAULT_SECONDS,
    max_events = DEFAULT_MAX_EVENTS,
    max_bytes = DEFAULT_MAX_BYTES,
)

PacketRecorder.limit_reason ​

python
@property
def limit_reason(self)

PacketRecorder.record ​

python
def record(self, event)

PacketRecorder.note ​

python
def note(self, name, value)

SDK 说明:

text
Save an explicit intent/baseline/receipt under the same byte budget.

PacketRecorder.finish ​

python
def finish(self, reason='completed', *, error=None)

SDK 说明:

text
Seal once, after actual stream cleanup. Incomplete results stay so.

PacketRecorder.output ​

python
self.output

公开实例属性,在 __init__ 中设置。

PacketRecorder.session ​

python
self.session

公开实例属性,在 __init__ 中设置。

PacketRecorder.snapshot ​

python
self.snapshot

公开实例属性,在 __init__ 中设置。

PacketRecorder.seconds ​

python
self.seconds

公开实例属性,在 __init__ 中设置。

PacketRecorder.max_events ​

python
self.max_events

公开实例属性,在 __init__ 中设置。

PacketRecorder.max_bytes ​

python
self.max_bytes

公开实例属性,在 __init__ 中设置。

PacketRecorder.started ​

python
self.started

公开实例属性,在 __init__ 中设置。

PacketRecorder.records ​

python
self.records

公开实例属性,在 __init__ 中设置。

PacketRecorder.bytes_written ​

python
self.bytes_written

公开实例属性,在 __init__ 中设置。

PacketRecorder.sequence ​

python
self.sequence

公开实例属性,在 __init__、record 中设置。

PacketRecorder.revision ​

python
self.revision

公开实例属性,在 __init__、record 中设置。

collect ​

python
async def collect(
    ctx,
    output,
    packet_ids,
    *,
    max_events = DEFAULT_MAX_EVENTS,
    seconds = DEFAULT_SECONDS,
    max_bytes = DEFAULT_MAX_BYTES,
    expected_names = None,
    on_event = None,
)

SDK 说明:

text
Collect selected packets with one bounded poll loop; callbacks share it.

on_event is an optional async callback, called after each archived event.
Local time limits never cancel an admitted IPC poll. Its bounded host wait
may finish just after the local limit; transport failures remain failures.

PacketRecording ​

python
@dataclass
class PacketRecording

字段(包含继承字段):

PacketRecording.snapshot ​

python
snapshot: dict

数据类字段;声明于 recording.PacketRecording。

PacketRecording.events ​

python
events: list

数据类字段;声明于 recording.PacketRecording。

PacketRecording.notes ​

python
notes: list

数据类字段;声明于 recording.PacketRecording。

PacketRecording.end ​

python
end: dict | None

数据类字段;声明于 recording.PacketRecording。

PacketRecording.complete ​

python
complete: bool

数据类字段;声明于 recording.PacketRecording。

PacketRecording.issues ​

python
issues: tuple

数据类字段;声明于 recording.PacketRecording。

PacketRecording.rows ​

python
rows: list

数据类字段;声明于 recording.PacketRecording。

read_recording ​

python
def read_recording(
    source,
    *,
    max_bytes = DEFAULT_MAX_BYTES,
    max_events = DEFAULT_MAX_EVENTS,
)

SDK 说明:

text
Read a bounded archive offline. Invalid schema/footer raises ValueError.

Missing footer or a truncated final line returns complete=False. The caller
must check complete before using the same parsed events for a conclusion.
completeness only describes the archive; it never proves server coverage.

Neomega · 使用、开发与参考文档