websockets

package
v0.25.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultWebsocketUpgrader = websocket.Upgrader{
	ReadBufferSize:  1024,
	WriteBufferSize: 1024,
	CheckOrigin: func(r *http.Request) bool {
		host, _, err := net.SplitHostPort(r.RemoteAddr)
		if err != nil {
			return false
		}

		return internalAPI.ShouldAllowHost(host, internalAPI.AcceptedHosts())
	},
}

Functions

func CreateAlertUpdate

func CreateAlertUpdate(alert action.Alert) event.Event

CreateAlertUpdate creates an alert update event.

func CreateFiltersUpdate

func CreateFiltersUpdate(filters []octant.Filter) event.Event

CreateFiltersUpdate creates a filters update event.

Types

type WebsocketClient

type WebsocketClient struct {
	// contains filtered or unexported fields
}

WebsocketClient manages websocket clients.

func NewTemporaryWebsocketClient

func NewTemporaryWebsocketClient(ctx context.Context, conn *websocket.Conn, manager api.ClientManager, actionDispatcher api.ActionDispatcher, id uuid.UUID) *WebsocketClient

NewTemporaryWebsocketClient creates an instance of WebsocketClient

func NewWebsocketClient

func NewWebsocketClient(ctx context.Context, conn *websocket.Conn, manager api.ClientManager, dashConfig config.Dash, actionDispatcher api.ActionDispatcher, id uuid.UUID) *WebsocketClient

NewWebsocketClient creates an instance of WebsocketClient.

func (*WebsocketClient) Handlers

func (c *WebsocketClient) Handlers() map[string][]octant.ClientRequestHandler

func (*WebsocketClient) ID

func (c *WebsocketClient) ID() string

ID returns the ID of the websocket client.

func (*WebsocketClient) Receive

func (c *WebsocketClient) Receive() (api.StreamRequest, error)

func (*WebsocketClient) RegisterHandler

func (c *WebsocketClient) RegisterHandler(handler octant.ClientRequestHandler)

func (*WebsocketClient) Send

func (c *WebsocketClient) Send(ev event.Event)

func (*WebsocketClient) State

func (c *WebsocketClient) State() octant.State

func (*WebsocketClient) StopCh

func (c *WebsocketClient) StopCh() <-chan struct{}

StopCh returns the client's stop channel. It will be closed when the WebsocketClient is closed.

type WebsocketConnectionFactory

type WebsocketConnectionFactory struct {
	// contains filtered or unexported fields
}

func NewWebsocketConnectionFactory

func NewWebsocketConnectionFactory() *WebsocketConnectionFactory

func (*WebsocketConnectionFactory) NewConnection

func (*WebsocketConnectionFactory) NewTemporaryConnection

type WebsocketState

type WebsocketState struct {
	// contains filtered or unexported fields
}

WebsocketState manages state for a websocket client.

func NewTemporaryWebsocketState

func NewTemporaryWebsocketState(actionDispatcher api.ActionDispatcher, wsClient api.OctantClient, options ...WebsocketStateOption) *WebsocketState

func NewWebsocketState

func NewWebsocketState(dashConfig config.Dash, actionDispatcher api.ActionDispatcher, wsClient api.OctantClient, options ...WebsocketStateOption) *WebsocketState

NewWebsocketState creates an instance of WebsocketState.

func (*WebsocketState) AddFilter

func (c *WebsocketState) AddFilter(filter octant.Filter)

AddFilter adds a content filter.

func (*WebsocketState) Dispatch

func (c *WebsocketState) Dispatch(ctx context.Context, actionName string, payload action.Payload) error

Dispatch dispatches a message.

func (*WebsocketState) GetClientID

func (c *WebsocketState) GetClientID() string

func (*WebsocketState) GetContentPath

func (c *WebsocketState) GetContentPath() string

GetContentPath returns the content path.

func (*WebsocketState) GetFilters

func (c *WebsocketState) GetFilters() []octant.Filter

GetFilters returns all filters.

func (*WebsocketState) GetNamespace

func (c *WebsocketState) GetNamespace() string

GetNamespace gets the namespace.

func (*WebsocketState) GetQueryParams

func (c *WebsocketState) GetQueryParams() map[string][]string

func (*WebsocketState) Handlers

func (c *WebsocketState) Handlers() []octant.ClientRequestHandler

Handlers returns all the handlers for WebsocketState.

func (*WebsocketState) OnContentPathUpdate

OnContentPathUpdate registers a function that will be called when the content path changes.

func (*WebsocketState) OnNamespaceUpdate

OnNamespaceUpdate registers a function that will be run when the namespace changes.

func (*WebsocketState) RemoveFilter

func (c *WebsocketState) RemoveFilter(filter octant.Filter)

RemoveFilter removes a content filter.

func (*WebsocketState) SendAlert

func (c *WebsocketState) SendAlert(alert action.Alert)

SendAlert sends an alert to the websocket client.

func (*WebsocketState) SetContentPath

func (c *WebsocketState) SetContentPath(contentPath string)

SetContentPath sets the content path.

func (*WebsocketState) SetContext

func (c *WebsocketState) SetContext(requestedContext string)

SetContext sets the Kubernetes context.

func (*WebsocketState) SetFilters

func (c *WebsocketState) SetFilters(filters []octant.Filter)

func (*WebsocketState) SetNamespace

func (c *WebsocketState) SetNamespace(namespace string)

SetNamespace sets the namespace.

func (*WebsocketState) Start

func (c *WebsocketState) Start(ctx context.Context)

Start starts WebsocketState by starting all associated StateManagers.

type WebsocketStateOption

type WebsocketStateOption func(w *WebsocketState)

WebsocketStateOption is an option for configuring WebsocketState.

func WebsocketStateManagers

func WebsocketStateManagers(managers []api.StateManager) WebsocketStateOption

WebsocketStateManagers configures WebsocketState's state managers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL