Files
warmbly/internal/models/mailbox.go
T
Matthew Meszaros f106c8541d feat: make the bus envelopes Avro-encodable (#535)
* feat: make both bus envelopes Avro-encodable by deriving each one's schema from a declared registry of body types, with a union branch per body and our own struct walk that skips unexported fields and honours avro:"-" before descending, so the schema describes exactly what encoding/json already puts on the wire, and narrow the two sync cursors on the wire DTOs to int64 because Avro has no unsigned 64-bit type

* feat: stop the instance health check, the config registry and the docs all claiming Avro cannot serialize a worker envelope, which stopped being true once the envelopes carried a declared union, and check the one thing that is still a real misconfiguration instead: avro selected with no SCHEMA_REGISTRY_URL to resolve against

* feat: emit a reference the second time a record appears in an envelope schema instead of defining it again, because Avro names a record once and a document that defines warmbly.events.Token three times is rejected outright, and keep the Schema Registry round-trip as a skip-by-default test since only a registry judges the document rather than the objects it was built from

* feat: carry uint64 as Avro fixed(8) rather than long, which lets the sync cursors keep their unsigned type instead of being narrowed, name every event field after its json tag so the schema and the JSON wire agree, and populate every field in the round-trip test because zero values are why a uint64 mapped to long passed in the first place

* feat: frame Avro in Confluent's wire format and encode through hamba's default API instead of going through avrov2, whose private avro.API holds a type resolver avro.Register cannot reach, so a union body failed there with unable to resolve type while encoding cleanly against the same schema, and keep the registry round-trip as a skip-by-default test
2026-09-15 10:50:30 -07:00

28 lines
1.2 KiB
Go

package models
import "time"
// Mailbox is one folder of an account. Its identity is Name, which IMAP
// guarantees is unique per account; UIDValidity is not an identity and never
// was, since RFC 3501 only promises UIDs are stable within one folder and
// servers deriving the number from a creation time give a whole folder tree
// the same one.
type Mailbox struct {
Name string `json:"name" avro:"name"`
Attrs []string `json:"attributes" avro:"attributes"`
// UIDValidity is the validity marker for the UIDs held below: when the
// server changes it, every stored uid for this folder is void and the
// cursors have to be rebuilt.
UIDValidity uint32 `json:"uid_validity" avro:"uid_validity"`
HighestModSeq uint64 `json:"highestmodseq" avro:"highestmodseq"`
// UIDNext is the folder's next UID as last seen. It is the incremental
// cursor on a server without CONDSTORE, where HighestModSeq stays 0.
UIDNext uint32 `json:"uid_next" avro:"uid_next"`
// Delim is the hierarchy delimiter this server reported for the folder
// ("/" on Gmail, "." on many Dovecots). Empty when the server reported
// none, where the leaf is guessed instead.
Delim string `json:"delim,omitempty" avro:"delim"`
UpdatedAt time.Time `json:"updated_at" avro:"updated_at"`
}