Skip to content

Commit

Permalink
websocket: Add a bit of API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
cfergeau committed Feb 20, 2023
1 parent c413ac6 commit ebccd16
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/crc/api/websocket/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"sync"
)

// websocket endpoint such as "/status". It has a number of clients connected
// to it, and works together with an EndpointHandler to listen for the data to
// send to its clients.
type Endpoint interface {
addClient(client *wsClient)
deleteClient(client *wsClient)
Expand Down
2 changes: 2 additions & 0 deletions pkg/crc/api/websocket/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"io"
)

// An EndpointHandler tells a set of listeners when they should be generating
// data for sending to clients.
type EndpointHandler struct {
listeners []ConnectionListener
dataSender io.Writer
Expand Down
2 changes: 2 additions & 0 deletions pkg/crc/api/websocket/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (

type genData func() (interface{}, error)

// A data generator for a websocket endpoint. It will fetch data at regular intervals, and
// send it to all clients connected to the endpoint.
type TickListener struct {
done chan bool
generator genData
Expand Down

0 comments on commit ebccd16

Please sign in to comment.