apiserver

package
v0.0.0-...-3270118 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

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

APIServer handles HTTP/WebSocket requests/connections defined for kontex-atn

func NewAPIServer

func NewAPIServer(hub *Hub, conf *Config, taskMaster TaskMaster, cacheRootPath string) *APIServer

NewAPIServer creates a properly initialized instance of APIServer

func (*APIServer) Start

func (s *APIServer) Start()

Start starts the server and blocks until it is closed.

func (*APIServer) Stop

func (s *APIServer) Stop()

Stop gracefully stops the server

type ConcStatusResponse

type ConcStatusResponse struct {
	FullSize            int      `json:"fullsize"`
	ConcSize            int      `json:"concsize"`
	RelConcSize         float32  `json:"relconcsize"`
	ConcPersistenceOpID string   `json:"conc_persistence_op_id"`
	Messages            []string `json:"messages"`
	UserOwnsConc        bool     `json:"user_owns_conc"`
	Q                   []string `json:"Q"`
	Finished            bool     `json:"finished"`
	ARF                 float32  `json:"arf"`
}

ConcStatusResponse specifies a conc. calculation status as required by KonText client.

func NewConcStatusResponse

func NewConcStatusResponse(evt *kcache.ConcCacheEvent) *ConcStatusResponse

NewConcStatusResponse creates a properly initialized ConcStatusResponse

type Config

type Config struct {
	Address        string   `json:"address"`
	URLPathRoot    string   `json:"urlPathRoot"`
	AllowedOrigins []string `json:"allowedOrigins"`
	SSLCertFile    string   `json:"sslCertFile"`
	SSLKeyFile     string   `json:"sslKeyFile"`
	StaticFilesDir string   `json:"staticFilesDir"`
}

Config defines a configuration required by konserver to run the embedded WebSocket server.

type Hub

type Hub struct {
	Register   chan *WSClient
	Unregister chan *WSClient
	// contains filtered or unexported fields
}

Hub controls the communication between calculation watchdogs and WebSocket clients.

func NewHub

func NewHub(cacheDB *taskdb.ConcCacheDB) *Hub

NewHub creates a proper instance of the Hub with all the channels initialized

func (*Hub) Start

func (h *Hub) Start()

Start starts listen on all the channels. This must run in a goroutine.

func (*Hub) Stop

func (h *Hub) Stop()

Stop stops the Hub instance by sending a respective value to Hub's 'stop' channel. The Hub instance will finish currently processed actions.

type InfoPageData

type InfoPageData struct {
	Date       string
	MasterInfo *workpool.MasterInfo
}

type TaskMaster

type TaskMaster interface {
	Info() *workpool.MasterInfo
	GetTask(taskID string) *workpool.Task
	SendTask(name string, jsonArgs []byte) *workpool.Task
	Start()
	Stop()
}

TaskMaster represents a general task queue as seen from the APIServer perspective.

type WSClient

type WSClient struct {
	Incoming chan *kcache.ConcCacheEvent
	// contains filtered or unexported fields
}

WSClient keeps connection with actual remote client (= browser) and sends data it recieves from a respective channel.

func NewWSClient

func NewWSClient(cacheIdent *kcache.CacheIdent, hub *Hub, conn *websocket.Conn) *WSClient

NewWSClient creates a proper instance of Client with all the channels initialized.

func (*WSClient) CacheIdent

func (c *WSClient) CacheIdent() *kcache.CacheIdent

CacheIdent returns a complete concordance cache identification based on how KonText works.

func (*WSClient) Run

func (c *WSClient) Run()

Run starts to listen on all the channels. This method must be used within a goroutine.

func (*WSClient) Stop

func (c *WSClient) Stop()

Stop asynchronously stops the client by sending 'true' to a respective channel.

func (*WSClient) String

func (c *WSClient) String() string

type Watcher

type Watcher interface {
	Start()
	Stop()
}

Watcher represents an autonomous object watching for changes in concordance calculation. Here we're interested only in how to start and stop the object.

Jump to

Keyboard shortcuts

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