This repository has been archived by the owner on Dec 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
66 lines (58 loc) · 1.92 KB
/
structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package server
/*
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 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"`
}
/*
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 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"`
}
/*
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 IncomingMetadata struct {
ResponseType string `json:"meta_response_type"`
}
/*
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 RequestPack struct {
ReqId uint64
ShardId uint64
RecvChannel chan IncomingResponse
ModRequest OutgoingRequest
}