Documentation
¶
Overview ¶
Package status is what a party knows about each peer beyond the session itself, and the roster page that shows it (design §8 花名册页).
The activity record, key "act.<channel>" in the party's store beside the channel's "ss." record, holds the channel's last message from the peer and the unread count: serve notes every message it births, peer send notes every message it commits. It is advisory — a failed note is logged by the caller and never costs a message — and shared by every host of the party like the rest of the store, so any host's serve or status reads the same numbers.
Unread counts the peer's messages born on this party since the party last sent anything on the channel; an ack from the peer is not counted. The store knows no reader, so "read" is "answered": sending on the channel — a reply, an ack, anything — clears it.
Index ¶
- Constants
- func ActivityKey(channel string) string
- func NoteIn(ctx context.Context, b store.Backend, channel string, seq int64, at time.Time, ...) error
- func NoteOut(ctx context.Context, b store.Backend, channel string, at time.Time) error
- func RowKey(root ed25519.PublicKey) string
- type Activity
- type Error
- type Page
- type Row
Constants ¶
const ActiveWindow = 30 * 24 * time.Hour
ActiveWindow is how long a peer counts as active after its last message: the relay's retention, past which what it sent is gone unread anyway.
const RowSchema = "peer-roster@1"
RowSchema is the K7 schema id of a roster page record.
const StaleBeats = 3
StaleBeats is the heartbeat rule: a row not written for more than this many beats reads stale — the serve that kept it is gone.
const Timeout = 30 * time.Second
Timeout bounds one request when NewPage is given no client.
Variables ¶
This section is empty.
Functions ¶
func ActivityKey ¶
ActivityKey is a channel's activity record key.
func NoteIn ¶
func NoteIn(ctx context.Context, b store.Backend, channel string, seq int64, at time.Time, kind string) error
NoteIn records a message from the peer born under relay seq: the newest by seq is the last message, and every one but an ack is unread.
Types ¶
type Activity ¶
type Activity struct {
V int `json:"v"`
// LastAt and LastKind are the peer's newest message born here: its own
// at stamp and kind; LastSeq the relay seq it came under. Zero before
// the first.
LastAt time.Time `json:"lastAt"`
LastKind string `json:"lastKind"`
LastSeq int64 `json:"lastSeq"`
// Unread is the peer's messages born since SentAt, acks not counted.
Unread int `json:"unread"`
// SentAt is the at stamp of this party's newest message committed on
// the channel; zero before the first.
SentAt time.Time `json:"sentAt"`
}
Activity is one channel's activity record.
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page is the roster page's /d/ store: plaintext rows under RowSchema, CAS by ?v= with the owner Bearer. It remembers the version it last read or wrote per key — the first write of a key reads it — so a round's write is one PUT; a conflict, another host's write in between, is retried once at the version the refusal names.
func NewPage ¶
NewPage opens the page slug on the ccc-pages service at base with the owner login "<user>:<token>"; a nil client is one with Timeout.
func (*Page) Create ¶
Create writes data under key and schema only if the key is absent: one PUT at ?v=0. A key already there answers created false and no error — the caller's key names its content, so what is there is what it would write. It is the timeline's write; the roster's rows, rewritten every round, are Put's.
type Row ¶
type Row struct {
Name string `json:"name"`
Party string `json:"party"`
Channel string `json:"channel"`
Side string `json:"side"`
State string `json:"state"`
// LastAt and LastKind are the peer's last message, null and "" before one.
LastAt *time.Time `json:"lastAt"`
LastKind string `json:"lastKind"`
Unread int `json:"unread"`
// Active: the channel has a session and the peer sent within ActiveWindow.
Active bool `json:"active"`
// Beat is the serve interval in seconds; At this write's time.
Beat int64 `json:"beat"`
At time.Time `json:"at"`
}
Row is one peer's roster page record, plaintext on a private page. It names the peer and the channel, never the host that wrote it, the login or any local id (design §3.6).