Documentation
¶
Overview ¶
Package mounts is the VM side of dynamic share mounts. An operator (e.g. a teacher) publishes a ShareMount on the event bus — to one VM, or via control-plane fan-out to a whole class of student VMs — and each VM applies it: mount on action "" / "mount", tear down on "unmount".
State is pushed whole and applied idempotently (replace-by-ID), so a missed message self-heals on the next publish — the same model pkg/mesh uses for WireGuard membership.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleMessage ¶
HandleMessage decodes a published mount update and applies it. Pure aside from the injected apply, so the decode/validate path is testable without a broker or a kernel.
Types ¶
type ApplyFunc ¶
type ApplyFunc func(pod.ShareMount) error
ApplyFunc mounts or unmounts one share according to spec.Action. The real implementation drives the CubeFS FUSE client (Linux); tests inject a stub.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber listens for this VM's share-mount updates and applies each one.
func NewSubscriber ¶
NewSubscriber builds a Subscriber for vmID that applies updates via apply.
func (*Subscriber) Start ¶
func (s *Subscriber) Start() (*nats.Subscription, error)
Start subscribes to the VM's mounts subject. The returned subscription is live until unsubscribed or the connection drops.
Two delivery modes :
JetStream (production) : a stream named `weft-mounts` with `weft.mounts.*` subjects + LastPerSubject retention is the boot-time replay guarantee — the subscriber's first connect gets the most recent ShareMount state for its VM, even if the publisher (e.g. loom-server) emitted it before the VM was alive. The subscriber auto-ensures the stream exists ; a re-attempt after a transient publisher failure is a no-op.
Core NATS (dev fallback) : when JetStream isn't available on the broker the subscriber falls back to a plain Subscribe, matching the original behaviour. Boot-time delivery is then best-effort (depends on publisher timing) but interactive publish-while-running keeps working.