Repository navigation
Push cache invalidations over a client-opened stream - #22
Merged
Merged
Conversation
Invalidations were delivered by the fileserver dialling a listener on each client. That fails whenever the fileserver cannot reach the client directly (NAT, campus Wi-Fi, home networks, client firewalls), so shared users silently stopped seeing each other's changes. Clients now open a long-lived WatchEvents stream to their fileserver and the server pushes events down it. The client dials out like every other RPC, so it works through NAT and firewalls and opens no listening port (no OS firewall prompt). The stream uses the existing TLS session and SST stream authentication, and is bound to the authenticated user. Server: - New rpc WatchEvents(WatchEventsRequest) returns (stream WatchEvent). The first message (type 0) confirms the stream; type-0 keepalives every 20s keep NAT mappings open and detect dead connections. - A session can hold one stream per running client; all receive events. An open stream marks the session live regardless of the activity TTL. - Events go to streams when present and fall back to the callback dial for clients that have none. A stream that falls 256 events behind is closed so the client resyncs instead of stalling the server. - UnregisterClient closes the user's streams. Client: - Connect opens the stream; no callback listener is started. - Reconnects with backoff (1s..30s), then re-reports its directory and re-fetches it, since events may have been missed. - If the session is rejected (expired, IP changed) it says so once; refresh re-registers and reopens the stream. - Servers without WatchEvents (Unimplemented) get the old callback listener, so new clients keep working with old fileservers. - The session token is guarded by its own lock, as the stream and heartbeat goroutines read it. Regenerated with protoc 3.21.12, protoc-gen-go v1.36.12 and protoc-gen-go-grpc v1.6.2 (the versions of the committed code).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Invalidations were delivered by the fileserver dialling a listener on each client. That fails whenever the fileserver cannot reach the client directly (NAT, campus Wi-Fi, home networks, client firewalls), so shared users silently stopped seeing each other's changes.
Clients now open a long-lived WatchEvents stream to their fileserver and the server pushes events down it. The client dials out like every other RPC, so it works through NAT and firewalls and opens no listening port (no OS firewall prompt). The stream uses the existing TLS session and SST stream authentication, and is bound to the authenticated user.
Server:
Client:
Regenerated with protoc 3.21.12, protoc-gen-go v1.36.12 and protoc-gen-go-grpc v1.6.2 (the versions of the committed code).