YmerNode.Messages (Ymer Node v0.7.2)

Copy Markdown View Source

How sessions talk with each other through the node: a session sends a message to a thread, and whoever reads that thread sees it. No message is addressed to a recipient. The process keys every message and every read mark by the thread and by the session's handle, passed as as, and only ever compares the two: it validates neither and reads no meaning into either.

This process holds every message and every read mark, in memory and nowhere else — YmerNode.Messages.Threads is the value it holds and the rules for what each call does to it. Nothing persists: a restart, an upgrade included, loses every message and every read mark. That is the design, not a gap. It is also why every answer that finds nothing says when messages started — the process's own start — so a session waiting on a reply after a restart reads a lost conversation rather than a silent one. A thread only a check has joined, and a named thread a read's filter leaves empty, say so the same way.

Bounds

A body over 8 KB is refused with where to put the content instead, and a handle or thread name over 512 bytes is refused too: together they bound what one kept message holds, and each message keeps its own copy of those strings rather than the request it arrived in. Past 10 000 messages the oldest is dropped, and a check or a read that reaches back past it says so. A thread's entry is never dropped — a check by any name makes one — which the node's load, a few sessions on one machine, keeps small.

A page holds at most 20 messages and at most 32 KB of them, measured as each message will be sent: a client parks a tool result much past that size instead of reading it, and an unread page is the token waste this tool is there to avoid.

Time

Every time an answer carries is in the node time zone with its offset, and a read's since is a span back from now or a date-time; how each is read and written is YmerNode.Messages.Clock.

Nothing here is part of a script's run, so this process is not in YmerNode.Script.Harness.run_tree/0, and YmerNode.Script.Context offers a script no way to send a message.

Summary

Functions

What is new for handle on thread, oldest first, moving its read mark past what it returns. With thread nil it is the threads handle has taken part in that hold unread messages, with counts, and no mark moves.

Returns a specification to start this module under a supervisor.

Looks without moving any mark. filters may hold thread — a name or a list of names — last, before and since. With none of them it answers the thread index. last or before with neither thread nor since is refused: they page through messages, and nothing names the messages to page through.

Sends body to thread as handle. A body over 8 KB, or a handle or thread over 512 bytes, is refused before it reaches the process.

Starts the process. Besides :name it takes :zone, the zone every time is read and rendered in; left out, that is the node time zone, read on each call. A test passes one to run the time rules in a zone with summer time.

Functions

check(handle, thread, server \\ __MODULE__)

What is new for handle on thread, oldest first, moving its read mark past what it returns. With thread nil it is the threads handle has taken part in that hold unread messages, with counts, and no mark moves.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

read(filters, server \\ __MODULE__)

Looks without moving any mark. filters may hold thread — a name or a list of names — last, before and since. With none of them it answers the thread index. last or before with neither thread nor since is refused: they page through messages, and nothing names the messages to page through.

send(handle, thread, body, server \\ __MODULE__)

Sends body to thread as handle. A body over 8 KB, or a handle or thread over 512 bytes, is refused before it reaches the process.

start_link(options)

Starts the process. Besides :name it takes :zone, the zone every time is read and rendered in; left out, that is the node time zone, read on each call. A test passes one to run the time rules in a zone with summer time.