Messageยถ

class Message(content: RecordDict, dst_node_id: int, message_type: str, *, ttl: float | None = None, group_id: str | None = None)[์†Œ์Šค]ยถ
class Message(content: RecordDict, *, reply_to: Message, ttl: float | None = None)
class Message(error: Error, *, reply_to: Message, ttl: float | None = None)

๊ธฐ๋ฐ˜ ํด๋ž˜์Šค: InflatableObject

Represents a message exchanged between ClientApp and ServerApp.

This class encapsulates the payload and metadata necessary for communication between a ClientApp and a ServerApp.

๋งค๊ฐœ๋ณ€์ˆ˜:
  • content (Optional[RecordDict] (default: None)) โ€“ ๋‹ค๋ฅธ ์—”ํ„ฐํ‹ฐ(์˜ˆ: ์„œ๋ฒ„ ์ธก ๋กœ์ง์ด ํด๋ผ์ด์–ธํŠธ๋กœ ์ „์†กํ•˜๊ฑฐ๋‚˜ ๊ทธ ๋ฐ˜๋Œ€๋กœ ์ „์†กํ•˜๋Š” ๋“ฑ)๊ฐ€ ์ „์†กํ–ˆ๊ฑฐ๋‚˜ ์ „์†กํ•  ๋ ˆ์ฝ”๋“œ๋ฅผ ๋ณด์œ ํ•ฉ๋‹ˆ๋‹ค.

  • error (Optional[Error] (default: None)) โ€“ ๋‹ค๋ฅธ ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•  ๋•Œ ๋ฐœ์ƒํ•œ ์˜ค๋ฅ˜์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์บก์ฒ˜ํ•˜๋Š” ๋ฐ์ดํ„ฐ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.

  • dst_node_id (Optional[int] (default: None)) โ€“ ์ด ๋ฉ”์‹œ์ง€๋ฅผ ์ˆ˜์‹ ํ•˜๋Š” ๋…ธ๋“œ์˜ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค.

  • message_type (Optional[str] (default: None)) โ€“ ์ˆ˜์‹  ์ธก์—์„œ ์‹คํ–‰ํ•  ์ž‘์—…์„ ์ธ์ฝ”๋”ฉํ•˜๋Š” ๋ฌธ์ž์—ด์ž…๋‹ˆ๋‹ค.

  • ttl (Optional[float] (default: None)) โ€“ Time-to-live (TTL) for this message in seconds. If None (default), the TTL is set to 43,200 seconds (12 hours).

  • group_id (Optional[str] (default: None)) โ€“ ๋ฉ”์‹œ์ง€๋ฅผ ๊ทธ๋ฃนํ™”ํ•˜๊ธฐ ์œ„ํ•œ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค. ์ผ๋ถ€ ์„ค์ •์—์„œ๋Š” FL ๋ผ์šด๋“œ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

  • reply_to (Optional[Message] (default: None)) โ€“ The instruction message to which this message is a reply. This message does not retain the original messageโ€™s content but derives its metadata from it.

๋ฉ”์†Œ๋“œ

create_error_reply(error[, ttl])

์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋‹ต์žฅ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

create_reply(content[, ttl])

์ง€์ •๋œ ์ฝ˜ํ…์ธ ์™€ TTL์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ ๋‹ต๊ธ€์„ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

deflate()

Deflate message.

has_content()

๋ฉ”์‹œ์ง€์— ์ฝ˜ํ…์ธ ๊ฐ€ ์žˆ์œผ๋ฉด True์„ ๋ฐ˜ํ™˜ํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด False์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

has_error()

๋ฉ”์‹œ์ง€์— ์˜ค๋ฅ˜๊ฐ€ ์žˆ์œผ๋ฉด True์„ ๋ฐ˜ํ™˜ํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด False์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

inflate(object_content[, children])

Inflate an Message from bytes.

์†์„ฑ

children

Return a dictionary of a single RecordDict with its Object IDs as key.

content

์ด ๋ฉ”์‹œ์ง€์˜ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

error

์ด ๋ฉ”์‹œ์ง€๊ฐ€ ์บก์ฒ˜ํ•œ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.

is_dirty

Check if the object is dirty after the last deflation.

metadata

์‹คํ–‰ํ•  ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ํฌํ•จํ•œ ๋ฐ์ดํ„ฐ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.

object_id

Get object_id.

property children: dict[str, InflatableObject] | Noneยถ

Return a dictionary of a single RecordDict with its Object IDs as key.

property content: RecordDictยถ

์ด ๋ฉ”์‹œ์ง€์˜ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

create_error_reply(error: Error, ttl: float | None = None) Message[์†Œ์Šค]ยถ

์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋‹ต์žฅ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

๋งค๊ฐœ๋ณ€์ˆ˜:
  • error (Error) โ€“ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

  • ttl (Optional[float] (default: None)) โ€“ ์ด ๋ฉ”์‹œ์ง€์˜ ๋‚จ์€ ์‹œ๊ฐ„(์ดˆ)์ž…๋‹ˆ๋‹ค. ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์ˆ˜์‹ ๋œ ๋ฉ”์‹œ์ง€๊ฐ€ ๋งŒ๋ฃŒ๋˜๊ธฐ ์ „๊นŒ์ง€ ๋‚จ์€ ์‹œ๊ฐ„์„ ๊ธฐ์ค€์œผ๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ณต์‹์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค: ttl = msg.meta.ttl - (reply.meta.created_at - msg.meta.created_at)

๋ฐ˜ํ™˜:

message โ€“ A Message containing only the relevant error and metadata.

๋ฐ˜ํ™˜ ํ˜•์‹:

Message

create_reply(content: RecordDict, ttl: float | None = None) Message[์†Œ์Šค]ยถ

์ง€์ •๋œ ์ฝ˜ํ…์ธ ์™€ TTL์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ ๋‹ต๊ธ€์„ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

The method generates a new Message as a reply to this message. It inherits โ€˜run_idโ€™, โ€˜src_node_idโ€™, โ€˜dst_node_idโ€™, and โ€˜message_typeโ€™ from this message and sets โ€˜reply_to_message_idโ€™ to the ID of this message.

๋งค๊ฐœ๋ณ€์ˆ˜:
  • content (RecordDict) โ€“ ๋‹ต์žฅ ๋ฉ”์‹œ์ง€์˜ ์ฝ˜ํ…์ธ ์ž…๋‹ˆ๋‹ค.

  • ttl (Optional[float] (default: None)) โ€“ ์ด ๋ฉ”์‹œ์ง€์˜ ๋‚จ์€ ์‹œ๊ฐ„(์ดˆ)์ž…๋‹ˆ๋‹ค. ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์ˆ˜์‹ ๋œ ๋ฉ”์‹œ์ง€๊ฐ€ ๋งŒ๋ฃŒ๋˜๊ธฐ ์ „๊นŒ์ง€ ๋‚จ์€ ์‹œ๊ฐ„์„ ๊ธฐ์ค€์œผ๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ณต์‹์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค: ttl = msg.meta.ttl - (reply.meta.created_at - msg.meta.created_at)

๋ฐ˜ํ™˜:

๋‹ต์žฅ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ƒˆ๋กœ์šด ๋ฉ”์‹œ์ง€ ์ธ์Šคํ„ด์Šค์ž…๋‹ˆ๋‹ค.

๋ฐ˜ํ™˜ ํ˜•์‹:

Message

deflate() bytes[์†Œ์Šค]ยถ

Deflate message.

property error: Errorยถ

์ด ๋ฉ”์‹œ์ง€๊ฐ€ ์บก์ฒ˜ํ•œ ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.

has_content() bool[์†Œ์Šค]ยถ

๋ฉ”์‹œ์ง€์— ์ฝ˜ํ…์ธ ๊ฐ€ ์žˆ์œผ๋ฉด True์„ ๋ฐ˜ํ™˜ํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด False์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

has_error() bool[์†Œ์Šค]ยถ

๋ฉ”์‹œ์ง€์— ์˜ค๋ฅ˜๊ฐ€ ์žˆ์œผ๋ฉด True์„ ๋ฐ˜ํ™˜ํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด False์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

classmethod inflate(object_content: bytes, children: dict[str, InflatableObject] | None = None) Message[์†Œ์Šค]ยถ

Inflate an Message from bytes.

๋งค๊ฐœ๋ณ€์ˆ˜:
  • object_content (bytes) โ€“ The deflated object content of the Message.

  • children (Optional[dict[str, InflatableObject]] (default: None)) โ€“ Dictionary of children InflatableObjects mapped to their Object IDs. These children enable the full inflation of the Message.

๋ฐ˜ํ™˜:

The inflated Message.

๋ฐ˜ํ™˜ ํ˜•์‹:

Message

property is_dirty: boolยถ

Check if the object is dirty after the last deflation.

An object is considered dirty if its content has changed since the last its object ID was computed.

property metadata: Metadataยถ

์‹คํ–‰ํ•  ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ํฌํ•จํ•œ ๋ฐ์ดํ„ฐ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.

property object_id: strยถ

Get object_id.