Message Protocol#
message_protocol
#
_sgen_namespace
module-attribute
#
_sgen_namespace = SgenNamespace(
"AllenNeuralDynamics.AindBehaviorServices.MessageProtocol"
)
RegisteredMessages
module-attribute
#
RegisteredMessages = _sgen_namespace.sgen_typename()(
create_model(
"RegisteredMessages",
__base__=_Message[RegisteredPayload],
)
)
SgenNamespace
#
SgenNamespace(namespace)
Source code in src/aind_behavior_services/schema/__init__.py
379 380 | |
sgen_typename
#
sgen_typename(*, typename=None)
Source code in src/aind_behavior_services/schema/__init__.py
386 387 | |
MessageType
#
Bases: StrEnum
Enumeration of possible message types in the protocol.
Examples:
MessageType.REQUEST # 'request'
MessageType.REPLY # 'reply'
MessageType.EVENT # 'event'
_Message
pydantic-model
#
Bases: BaseModel, Generic[TPayload]
A generic message container that can carry any payload type. While not marked as abstract, it is intended to be subclassed for specific message types with defined payloads.
| ATTRIBUTE | DESCRIPTION |
|---|---|
cls_type |
The specific message class type identifier (discriminator)
|
message_type |
The category of message (request, reply, or event)
TYPE:
|
protocol_version |
The major version of the message protocol being used
TYPE:
|
timestamp |
When the message was created
TYPE:
|
payload |
The actual message content
TYPE:
|
process_id |
Identifier of the process (e.g.: executable) that created the message
TYPE:
|
hostname |
Name of the host machine that created the message
TYPE:
|
rig_name |
Name of the experimental rig that created the message
TYPE:
|
Fields:
-
message_type(MessageType) -
protocol_version(Literal[PROTOCOL_VERSION]) -
timestamp(Optional[AwareDatetime]) -
payload(SerializeAsAny[TPayload]) -
process_id(Optional[str]) -
hostname(Optional[str]) -
rig_name(Optional[str])
LogLevel
#
Bases: IntEnum
Enumeration of log levels for the logging system.
Follows standard Python logging levels with integer values that allow for easy comparison and filtering.
Examples:
LogLevel.ERROR > LogLevel.WARNING # True
LogLevel.DEBUG.value # 10
str(LogLevel.INFO) # 'LogLevel.INFO'
LogPayload
pydantic-model
#
Bases: BaseModel
Payload for log messages containing logging information.
This payload carries log data including the message content, severity level, optional context, and application version.
| ATTRIBUTE | DESCRIPTION |
|---|---|
message |
The actual log message text
TYPE:
|
level |
Severity level of the log entry
TYPE:
|
context |
Optional additional data related to the log
TYPE:
|
application_version |
Version of the application generating the log
TYPE:
|
Examples:
log_payload = LogPayload(
message="System startup complete",
level=LogLevel.INFO,
context={"operator": "John Doe"},
application_version="1.0.0"
)
print(log_payload.level) # LogLevel.INFO
Fields:
-
payload_type(Literal['LogPayload']) -
message(str) -
level(LogLevel) -
context(Optional[SerializeAsAny[Any]]) -
application_version(Optional[str])
HeartbeatStatus
#
Bases: IntEnum
Enumeration of possible heartbeat status values.
Represents the health status of a system component, with higher values indicating more severe issues.
Examples:
HeartbeatStatus.OK # <HeartbeatStatus.OK: 0>
HeartbeatStatus.CRITICAL > HeartbeatStatus.WARNING # True
int(HeartbeatStatus.ERROR) # 2
HeartbeatPayload
pydantic-model
#
Bases: BaseModel
Payload for heartbeat messages indicating system health status.
Heartbeat messages are used to monitor the health and availability of system components. They include a status indicator and optional context information.
| ATTRIBUTE | DESCRIPTION |
|---|---|
context |
Optional additional data about the system state
TYPE:
|
status |
Current health status of the component
TYPE:
|
Examples:
heartbeat = HeartbeatPayload(
status=HeartbeatStatus.OK,
context={"cpu_usage": 0.25, "memory_usage": 0.60}
)
print(heartbeat.status) # HeartbeatStatus.OK
warning_heartbeat = HeartbeatPayload(
status=HeartbeatStatus.WARNING,
context={"disk_space_low": True}
)
Fields:
-
payload_type(Literal['HeartbeatPayload']) -
context(SerializeAsAny[Optional[Any]]) -
status(HeartbeatStatus)
RegisteredPayload
#
MessageProtocol
pydantic-model
#
Bases: BaseModel
Container for the complete message protocol including all registered message types.
Config:
json_schema_extra:{'x-abstract': True}
Fields: