server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

graphql websocket http handler implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeAST

func MakeAST(query string, schema *graphql.Schema) (*ast.Document, *graphql.Result)

helper function to parse request into graphql AST

Types

type Connection

type Connection struct {
	Server        *Server
	Subscriptions map[interface{}]*Subscription
	Context       mutcontext.MutableContext
	Outgoing      chan *proto.Message
	Events        chan Event
	TickCloser    *TickCloser
	Stopcounter   int32
}

base Connection state

func (*Connection) EventLoop

func (conn *Connection) EventLoop()

Event reactor

func (*Connection) ReadLoop

func (conn *Connection) ReadLoop(ws *websocket.Conn)

reading bytes from websocket to messages, posting events

func (*Connection) WriteLoop

func (conn *Connection) WriteLoop(ws *websocket.Conn)

writes messages to websocket

type Event

type Event interface{}

internal Event base

type EventConnectionInit

type EventConnectionInit struct {
	Parameters interface{}
}

posted when Connection negotiation commences

type EventConnectionReadClosed

type EventConnectionReadClosed struct {
}

posted when Connection read was closed

type EventConnectionTerminate

type EventConnectionTerminate struct {
}

posted when Connection termination requested

type EventConnectionTimerClosed

type EventConnectionTimerClosed struct {
}

posted when Connection timer was closed

type EventConnectionWriteClosed

type EventConnectionWriteClosed struct {
}

posted when Connection write was closed

type EventOperationComplete

type EventOperationComplete struct {
	Id interface{}
}

posted when operation completed

type EventOperationStart

type EventOperationStart struct {
	Id      interface{}
	Payload *proto.PayloadOperation
}

posted when new operation requested

type EventOperationStop

type EventOperationStop struct {
	Id interface{}
}

posted when operation interruption requested

type Server

type Server struct {
	Upgrader        *websocket.Upgrader
	Schema          *graphql.Schema
	OnConnect       common.FuncConnectCallback
	OnOperation     common.FuncOperationCallback
	OnOperationDone common.FuncOperationDoneCallback
	OnDisconnect    common.FuncDisconnectCallback
	OnPlainInit     common.FuncPlainInit
	OnPlainFail     common.FuncPlainFail
	IgnorePlainHttp bool
	KeepAlive       time.Duration
}

the Server itself

func (*Server) ServeHTTP

func (server *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

http.Handler entrypoint

func (*Server) ServePlainHTTP

func (server *Server) ServePlainHTTP(ctx mutcontext.MutableContext, w http.ResponseWriter, r *http.Request)

serve plain http request

func (*Server) ServeWebsocketHTTP

func (server *Server) ServeWebsocketHTTP(ctx mutcontext.MutableContext, w http.ResponseWriter, r *http.Request)

serve websocket http request

type Subscription

type Subscription struct {
	Id      interface{}
	Payload *proto.PayloadOperation
	Context mutcontext.MutableContext
}

base operation/Subscription state

type TickCloser

type TickCloser struct {
	Ticker  *time.Ticker
	Stopped chan bool
}

ticker that also closes on stop

func (*TickCloser) Stop

func (tc *TickCloser) Stop()

stop also closes

Jump to

Keyboard shortcuts

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