Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartMainServer ¶
startMainServer (public) starts the pre-forking FastHTTP server binding to the set address of `mainHost`
func StartWorkerServer ¶
func StartWorkerServer(workerManager process_manager.ExternalWorkers) error
startWorkerServer is internal server that is reserved just for worker processes, and the only entry point is via `ws://127.0.0.1:workerPort/workers` anything else is ignored and returns a 403 or method not allowed.
Invokes:
- authorizeAndUpgrade()
Types ¶
type IncomingMetadata ¶
type IncomingMetadata struct {
ResponseType string `json:"meta_response_type"`
}
Represents internal metadata, used for optimising requests, small bodies aren't work sending as a separate thing so instead we just send it in one go.
This can be represented by the following:
- partial: signals the the request is in chunks - complete: signals that all content is in the one request.
type IncomingResponse ¶
type IncomingResponse struct { Op int `json:"op"` Meta IncomingMetadata `json:"meta_data"` RequestId uint64 `json:"request_id"` Type string `json:"type"` Status int `json:"status"` Headers [][]string `json:"headers"` Body string `json:"body"` MoreBody bool `json:"more_body"` }
The main struct representing a incoming WS response, this wraps the `IncomingMetadata` struct to and all data is fed back into the external http request excluding, RequestId, Meta and Op Values.
type OutgoingRequest ¶
type OutgoingRequest struct { Op int `json:"op"` RequestId uint64 `json:"request_id"` Method string `json:"method"` Remote string `json:"remote"` Path string `json:"path"` Headers [][]string `json:"headers"` Version string `json:"version"` Body string `json:"body"` Query string `json:"query"` }
Represents a client request (minus the body) this contains anything needed for the workers to use, the body is dedicated code to support cross process body streams without making everything else over complicated.
type RequestPack ¶
type RequestPack struct { ReqId uint64 ShardId uint64 RecvChannel chan IncomingResponse ModRequest OutgoingRequest }
RequestPack acts like a zip up of required vars like Request id, receiver channel, outgoing request.
This is used heavily for recycling variables to reduce the load on the gc to aid performance, every little helps.
type Shard ¶
type Shard struct { ShardId uint64 OutgoingChannel chan *OutgoingRequest RecvCache *hashmap.HashMap // contains filtered or unexported fields }
This struct represents a individual shard, containing it's shard id, any applicable locks or in this cache thread safe maps, websocket connection and sending channel. All interactions to the websocket and shard should go through here.
func (*Shard) Start ¶
func (s *Shard) Start()
A simple function that starts a thread and then handles writes blocking the current goroutine, this keep all lifetimes in check.
func (*Shard) SubmitRequest ¶
func (s *Shard) SubmitRequest(request *OutgoingRequest, recv chan IncomingResponse)
takes a given request and a channel, sends the request to the WS handler channel (`OutgoingChannel`) and then Inserts the recv channel if it doesnt already exist.
type ShardManager ¶
The master controller per proc that controls all shard related IO and control.
func (*ShardManager) AddShard ¶
func (sm *ShardManager) AddShard(shard *Shard)
Used to add a shard type to the manager, allowing for easy access and control later on down the line of development.
func (*ShardManager) RemoveShard ¶
func (sm *ShardManager) RemoveShard(shardId uint64)
Used to remove a shard type of a given id from the manager and therefore removing it from the web server's usage.
func (*ShardManager) SubmitToShard ¶
func (sm *ShardManager) SubmitToShard(shardId uint64, out *OutgoingRequest, recv chan IncomingResponse) bool
Use this for submitting requests to the server, it handles getting the shard from the hashmap and then submitting it to the shard, returning a bool to signal if the shard exists and has been sent the data or not.