Class SpoolLive
Hierarchy
- DurableObject
- SpoolLive
Constructors
constructor
-
Parameters
- ctx: DurableObjectState
- env: Env
Returns SpoolLive
Methods
alarm
-
Returns Promise<void>
Optionalconnect
-
Parameters
- socket: Socket
Returns void | Promise<void>
fetch
-
Parameters
- request: Request
Returns Promise<Response>
publish
revoke
-
sends
revokedto every stream and socket ofpartitionand closes themParameters
- partition: string
Returns void
stats
-
what this object has counted since it started
Returns LiveStats
web Socket Close
-
Parameters
- ws: WebSocket
- code: number
Returns void
web Socket Error
-
Parameters
- ws: WebSocket
Returns void
web Socket Message
-
Parameters
- ws: WebSocket
- message: string | ArrayBuffer
Returns void
The live streams of every isolate, held by one Durable Object: a page's
/.spool/liverequest is forwarded here and its response is the stream, so a bump or a revocation from any isolate reaches every open page. The object stays in memory while a stream is open and is billed for that duration. One instance serves every stream of a site, which is its ceiling. Bind it as a Durable Object class and pass the namespace to durableObjectHub.A WebSocket upgrade is accepted with the Hibernation API when the hub sets
hibernate. Those sockets hold no timer, so while no SSE stream is open the object hibernates between a publish, a revoke, a maximum-age alarm and a message that is not a ping.