Documentation
¶
Index ¶
- Constants
- Variables
- func CollectGarbage() *store.Command
- func ContextWithBackend(ctx context.Context, backend *Backend) context.Context
- func ContextWithBackends(ctx context.Context, backends []*Backend) context.Context
- func ContextWithFrontend(ctx context.Context, frontend *Frontend) context.Context
- func DecommissionBackend(req *DecommissionBackendRequest) *store.Command
- func EndAllMeetings(req *EndAllMeetingsRequest) *store.Command
- func NewRequestContext() context.Context
- func UpdateMeetingState(req *UpdateMeetingStateRequest) *store.Command
- func UpdateNodeState(req *UpdateNodeStateRequest) *store.Command
- type Backend
- func BackendFromContext(ctx context.Context) *Backend
- func BackendsFromContext(ctx context.Context) []*Backend
- func GetBackend(ctx context.Context, q sq.SelectBuilder) (*Backend, error)
- func GetBackends(ctx context.Context, q sq.SelectBuilder) ([]*Backend, error)
- func NewBackend(state *store.BackendState) *Backend
- func (b *Backend) Create(ctx context.Context, req *bbb.Request) (*bbb.CreateResponse, error)
- func (b *Backend) End(ctx context.Context, req *bbb.Request) (*bbb.EndResponse, error)
- func (b *Backend) GetDefaultConfigXML(ctx context.Context, req *bbb.Request) (*bbb.GetDefaultConfigXMLResponse, error)
- func (b *Backend) GetMeetingInfo(ctx context.Context, req *bbb.Request) (*bbb.GetMeetingInfoResponse, error)
- func (b *Backend) GetMeetings(ctx context.Context, req *bbb.Request) (*bbb.GetMeetingsResponse, error)
- func (b *Backend) GetRecordingTextTracks(ctx context.Context, req *bbb.Request) (*bbb.GetRecordingTextTracksResponse, error)
- func (b *Backend) HasTag(tag string) bool
- func (b *Backend) HasTags(tags []string) bool
- func (b *Backend) Host() string
- func (b *Backend) ID() string
- func (b *Backend) IsMeetingRunning(ctx context.Context, req *bbb.Request) (*bbb.IsMeetingRunningResponse, error)
- func (b *Backend) Join(ctx context.Context, req *bbb.Request) (*bbb.JoinResponse, error)
- func (b *Backend) JoinProxy(ctx context.Context, req *bbb.Request) (*bbb.JoinResponse, error)
- func (b *Backend) PutRecordingTextTrack(ctx context.Context, req *bbb.Request) (*bbb.PutRecordingTextTrackResponse, error)
- func (b *Backend) SetConfigXML(ctx context.Context, req *bbb.Request) (*bbb.SetConfigXMLResponse, error)
- func (b *Backend) Stress() float64
- func (b *Backend) String() string
- func (b *Backend) Tags() []string
- type Controller
- type DecommissionBackendRequest
- type EndAllMeetingsRequest
- type Frontend
- type Gateway
- type GatewayOptions
- type RequestHandler
- type RequestMiddleware
- type Router
- func (r *Router) LookupBackend(ctx context.Context, req *bbb.Request) (*Backend, error)
- func (r *Router) LookupBackendForRecordID(ctx context.Context, recordID string) (*Backend, error)
- func (r *Router) SelectBackend(ctx context.Context, req *bbb.Request) (*Backend, error)
- func (r *Router) Use(middleware RouterMiddleware)
- type RouterHandler
- type RouterMiddleware
- type Schema
- type UpdateMeetingStateRequest
- type UpdateNodeStateRequest
Constants ¶
const ( BackendStateInit = "init" BackendStateReady = "ready" BackendStateError = "error" BackendStateStopped = "stopped" BackendStateDecommissioned = "decommissioned" )
BackendStates: The state of the cluster backend node.
const ( // Backend CmdUpdateNodeState = "update_node_state" CmdDecommissionBackend = "decommission_backend" // Meetings CmdUpdateMeetingState = "update_meeting_state" CmdEndAllMeetings = "end_all_meetings" // Maintenance CmdCollectGarbage = "collect_garbage" )
Commands that can be handled by the controller
const ( // MeetingSyncInterval is the amount of time after a // meeting state is considered stale and should be refreshed. MeetingSyncInterval = 15 * time.Second // NodeSyncInterval is the amount of time after a backend // node is considered stale and should be refreshed. NodeSyncInterval = 20 * time.Second )
Variables ¶
var ( // ErrNoBackendInContext will be returned when no backends // could be associated with the request. ErrNoBackendInContext = errors.New("no backend in context") // ErrNoFrontendInContext will be returned when no frontend // is associated with the request. ErrNoFrontendInContext = errors.New("no frontend in context") // ErrBackendNotReady will only occur when the routing // selected a backend that can not accept any requests ErrBackendNotReady = errors.New("backend not ready") )
Errors
var ( // ErrNoBackendForMeeting indicates, that there is a backend // expected to be associated with a meeting, yet the meeting // is unknown to the cluster. ErrNoBackendForMeeting = errors.New("no backends associated with meeting") // ErrNoBackendAvailable indicates that there is no backend // available for creating a meeting. ErrNoBackendAvailable = errors.New("no free backend available for meeting") // ErrMeetingIDMissing indicates that there is a meetingID // expected to be in the requests params, but it is missing. ErrMeetingIDMissing = errors.New("meetingID missing from request") )
Routing errors
var ( // ErrRecordingNotFound indicates, that the recording // state could not retrieved. ErrRecordingNotFound = errors.New("recording could not be found") )
var ( // ErrUnknownCommand indicates, that the command was not // understood by the controller. ErrUnknownCommand = errors.New("command unknown") )
Functions ¶
func CollectGarbage ¶
CollectGarbage requests removing stale states.
func ContextWithBackend ¶
ContextWithBackend create a new context with a backend
func ContextWithBackends ¶
ContextWithBackends creates a new context from the parent context with a copy of the backends.
func ContextWithFrontend ¶
ContextWithFrontend creates a context with a frontend
func DecommissionBackend ¶
func DecommissionBackend(req *DecommissionBackendRequest) *store.Command
DecommissionBackend will remove a given cluster backend from the state.
func EndAllMeetings ¶
func EndAllMeetings(req *EndAllMeetingsRequest) *store.Command
EndAllMeetings will send end meeting api requests to all running meetings on a backend. This can be usefull to force decommissioning.
func NewRequestContext ¶
NewRequestContext create a new context
func UpdateMeetingState ¶
func UpdateMeetingState( req *UpdateMeetingStateRequest, ) *store.Command
UpdateMeetingState makes a new meeting refresh command
func UpdateNodeState ¶
func UpdateNodeState(req *UpdateNodeStateRequest) *store.Command
UpdateNodeState creates a update status command
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
A Backend is a BigBlueButton instance in the cluster.
It has a bbb.backend secret for request authentication, stored in the backend state. The state is shared across all instances.
func BackendFromContext ¶
BackendFromContext retrieves a backend from a context
func BackendsFromContext ¶
BackendsFromContext retrieves backends from a context
func GetBackend ¶
GetBackend retrievs a single backend by query criteria
func GetBackends ¶
GetBackends retrievs all backends from the store, filterable with a query.
func NewBackend ¶
func NewBackend(state *store.BackendState) *Backend
NewBackend creates a new backend instance with a fresh bbb client.
func (*Backend) GetDefaultConfigXML ¶
func (b *Backend) GetDefaultConfigXML( ctx context.Context, req *bbb.Request, ) (*bbb.GetDefaultConfigXMLResponse, error)
GetDefaultConfigXML retrieves the default config xml
func (*Backend) GetMeetingInfo ¶
func (b *Backend) GetMeetingInfo( ctx context.Context, req *bbb.Request, ) (*bbb.GetMeetingInfoResponse, error)
GetMeetingInfo gets the meeting details
func (*Backend) GetMeetings ¶
func (b *Backend) GetMeetings( ctx context.Context, req *bbb.Request, ) (*bbb.GetMeetingsResponse, error)
GetMeetings retrieves a list of meetings
func (*Backend) GetRecordingTextTracks ¶
func (b *Backend) GetRecordingTextTracks( ctx context.Context, req *bbb.Request, ) (*bbb.GetRecordingTextTracksResponse, error)
GetRecordingTextTracks retrieves the text tracks from a recording
func (*Backend) IsMeetingRunning ¶
func (b *Backend) IsMeetingRunning( ctx context.Context, req *bbb.Request, ) (*bbb.IsMeetingRunningResponse, error)
IsMeetingRunning returns the is meeting running state
func (*Backend) Join ¶
Join via redirect: The client will receive a redirect to the BBB backend and will join there directly.
func (*Backend) JoinProxy ¶
JoinProxy makes a request on behalf of the client. A reverse proxy needs to pass all subsequent requests to the BBB backend.
func (*Backend) PutRecordingTextTrack ¶
func (b *Backend) PutRecordingTextTrack( ctx context.Context, req *bbb.Request, ) (*bbb.PutRecordingTextTrackResponse, error)
PutRecordingTextTrack adds a text track
func (*Backend) SetConfigXML ¶
func (b *Backend) SetConfigXML( ctx context.Context, req *bbb.Request, ) (*bbb.SetConfigXMLResponse, error)
SetConfigXML sets the? config xml
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
The Controller interfaces with the state of the cluster providing methods for retrieving cluster backends and frontends.
The controller subscribes to commands.
func NewController ¶
func NewController() *Controller
NewController will initialize the cluster controller with a database connection. A BBB client will be created which will be used by the backend instances.
func (*Controller) StartBackground ¶
func (c *Controller) StartBackground()
StartBackground will be run periodically triggered by requests and should only add tasks to the command queue. These tasks will take care of syncing the backends with our state by refreshing nodes and meetings.
type DecommissionBackendRequest ¶
type DecommissionBackendRequest struct {
ID string `json:"id"`
}
DecommissionBackendRequest declares the removal of a backend node from the cluster state.
type EndAllMeetingsRequest ¶
type EndAllMeetingsRequest struct {
BackendID string
}
EndAllMeetingsRequest contains parameters for the end all meetings command.
type Frontend ¶
type Frontend struct {
// contains filtered or unexported fields
}
A Frontend is a consumer like Greenlight. Each frontend has it's own secret for authentication.
func FrontendFromContext ¶
FrontendFromContext retrieves a frontend from a context
func GetFrontend ¶
GetFrontend fetches a frontend with a state from the store
func GetFrontends ¶
GetFrontends retrieves all frontends from the store matching a query
func NewFrontend ¶
func NewFrontend(state *store.FrontendState) *Frontend
NewFrontend initializes a frontend with the provided config and assigns the ID.
func (*Frontend) Settings ¶
func (f *Frontend) Settings() *store.FrontendSettings
Settings gets the state settings
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
The Gateway accepts bbb cluster requests and dispatches it to the cluster nodes.
func NewGateway ¶
func NewGateway(ctrl *Controller, opts *GatewayOptions) *Gateway
NewGateway sets up a new cluster router instance.
func (*Gateway) Dispatch ¶
func (gw *Gateway) Dispatch( ctx context.Context, conn *pgxpool.Conn, req *bbb.Request, ) bbb.Response
Dispatch taks a cluster request and starts the middleware chain. We will always return a bbb response. Any error occoring during routing or dispatching will be encoded as an BBB XML Response.
func (*Gateway) Use ¶
func (gw *Gateway) Use(middleware RequestMiddleware)
Use registers a middleware function
type GatewayOptions ¶
type GatewayOptions struct { }
GatewayOptions have flags for customizing the gateway behavior.
type RequestHandler ¶
RequestHandler accepts a bbb request and state. It produces a bbb response or an error.
type RequestMiddleware ¶
type RequestMiddleware func(next RequestHandler) RequestHandler
RequestMiddleware is a plain middleware without a state
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
The Router provides a requets middleware for routing requests to backends. The routing middleware stack selects backends.
func NewRouter ¶
func NewRouter(ctrl *Controller) *Router
NewRouter creates a new router middleware selecting a list of backends from the cluster state.
The request will be initialized with a list of all backends available in the the cluster state
The middleware chain should only subtract backends.
func (*Router) LookupBackend ¶
LookupBackend will retrieve a backend or will fail if the backend could not be found. Primary identifier is the MeetingID of the request. When no backend is found, this will not fail, however the backend will be nil and this case needs to be handled.
func (*Router) LookupBackendForRecordID ¶
func (r *Router) LookupBackendForRecordID( ctx context.Context, recordID string, ) (*Backend, error)
LookupBackendForRecordID uses the recordID to identify a backend via the recordings state table.
func (*Router) SelectBackend ¶
SelectBackend will apply the routing middleware chain to a given request with all ready nodes in the cluster where the admin state is also ready. Selecting a backend will fail if no backends are available as routing targets.
func (*Router) Use ¶
func (r *Router) Use(middleware RouterMiddleware)
Use will insert a middleware into the chain
type RouterHandler ¶
RouterHandler accepts a bbb request and a list of backends and returns a filtered or sorted list of backends.
type RouterMiddleware ¶
type RouterMiddleware func(next RouterHandler) RouterHandler
A RouterMiddleware accepts a handler function and returns a decorated handler function.
type UpdateMeetingStateRequest ¶
type UpdateMeetingStateRequest struct {
ID string // the meeting ID
}
UpdateMeetingStateRequest requests the refresh of a meeting
type UpdateNodeStateRequest ¶
type UpdateNodeStateRequest struct {
ID string // the backend state id
}
UpdateNodeStateRequest requests a status update from a backend identified by ID