handler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgFormatError = "message format not correct"
)

constants for error message

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandle

type EventHandle struct {
	KeepaliveInterval int
	WriteTimeout      int
	Nodes             sync.Map

	EventQueue *channelq.ChannelEventQueue
	Context    *context.Context
	Handlers   []HandleFunc
	// contains filtered or unexported fields
}

EventHandle processes events between cloud and edge

func (*EventHandle) CancelNode

func (eh *EventHandle) CancelNode(hi hubio.CloudHubIO, info *emodel.HubInfo, code ExitCode)

func (*EventHandle) EnrollNode

func (eh *EventHandle) EnrollNode(hi hubio.CloudHubIO, info *emodel.HubInfo) error

EnrollNode enroll node for the incoming connection

func (*EventHandle) GetNodeCount

func (eh *EventHandle) GetNodeCount() int

GetNodeCount returns the number of connected Nodes

func (*EventHandle) GetWorkload

func (eh *EventHandle) GetWorkload() (float64, error)

GetWorkload returns the workload of the event queue

func (*EventHandle) Pub2Controller

func (eh *EventHandle) Pub2Controller(info *emodel.HubInfo, msg *model.Message) error

func (*EventHandle) ServeConn

func (eh *EventHandle) ServeConn(hi hubio.CloudHubIO, info *emodel.HubInfo)

ServeConn starts serving the incoming connection

type ExitCode

type ExitCode int

ExitCode exit code

type HandleFunc

type HandleFunc func(hi hubio.CloudHubIO, info *emodel.HubInfo, stop chan ExitCode)

type QuicHandle

type QuicHandle struct {
	EventHandler     *EventHandle
	NodeLimit        int
	KeepaliveChannel chan struct{}
}

QuicHandle access handler

var QuicHandler *QuicHandle

QuicHandler handle all request from quic

func (*QuicHandle) EventWriteLoop

func (qh *QuicHandle) EventWriteLoop(hi hubio.CloudHubIO, info *emodel.HubInfo, stop chan ExitCode)

EventWriteLoop loop write cloud msg to edge

func (*QuicHandle) HandleServer

func (qh *QuicHandle) HandleServer(container *mux.MessageContainer, writer mux.ResponseWriter)

HandleServer handle all the request from quic

func (*QuicHandle) KeepaliveCheckLoop

func (qh *QuicHandle) KeepaliveCheckLoop(hi hubio.CloudHubIO, info *emodel.HubInfo, stop chan ExitCode)

KeepaliveCheckLoop checks whether the edge node is still alive

func (*QuicHandle) OnRegister

func (qh *QuicHandle) OnRegister(connection conn.Connection)

OnRegister regist node on first connection

type WebsocketHandle

type WebsocketHandle struct {
	EventHandler *EventHandle
	NodeLimit    int
}

WebsocketHandle access handler

var WebSocketHandler *WebsocketHandle

WebSocketHandler handle all request from websocket

func (*WebsocketHandle) EventReadLoop

func (wh *WebsocketHandle) EventReadLoop(hi hubio.CloudHubIO, info *emodel.HubInfo, stop chan ExitCode)

EventReadLoop processes all read requests

func (*WebsocketHandle) EventWriteLoop

func (wh *WebsocketHandle) EventWriteLoop(hi hubio.CloudHubIO, info *emodel.HubInfo, stop chan ExitCode)

EventWriteLoop processes all write requests

func (*WebsocketHandle) ServeEvent

func (wh *WebsocketHandle) ServeEvent(w http.ResponseWriter, r *http.Request)

ServeEvent handle the event coming from websocket

func (*WebsocketHandle) ServeQueueWorkload

func (wh *WebsocketHandle) ServeQueueWorkload(w http.ResponseWriter, r *http.Request)

ServeQueueWorkload handle workload from queue

Jump to

Keyboard shortcuts

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