Documentation ¶
Index ¶
Constants ¶
const ( RelayerHost = "X-Relayer-Host" RelayerProtocol = "X-Relayer-Protocol" RelayerTraceID = "X-Relayer-Traceid" )
Constants names of the header fields used by Rush
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer struct { //Channel for getting petitions GetFrom <-chan *Petition //Configuration object Cfg *config.Config //Session seed for mongo SessionSeed *mgo.Session //http.Client for making requests to target host Client http.Client // contains filtered or unexported fields }
Consumer is in charge of taking up petitions from the "GetFrom" channel and making the actual request to the target host, saving the answer and deleting the petition after that.
type Listener ¶
type Listener struct { //Channel for sending petitions SendTo chan<- *Petition //Configuration object Cfg *config.Config //Session seed for mongo SessionSeed *mgo.Session // contains filtered or unexported fields }
Listener is responsible for receiving requests and storing them in PetitionStore. It then passes a reference to the object Petition which wraps the original HTTP request through the channel Sendto, where the Consumer should collected it for further processing
type Petition ¶
type Petition struct { ID string `json:"id"` TraceID string `json:"traceid"` TargetHost string `json:"targethost"` TargetScheme string `json:"targetscheme"` Method string `json:"method"` // GET, POST, PUT, etc. URL *url.URL `json:"-"` URLString string `json:"urlstring"` Proto string `json:"proto"` // "HTTP/1.0" Header http.Header `json:"header"` Trailer http.Header `json:"trailer"` Body []byte `json:"body"` RemoteAddr string `json:"remoteaddr"` RequestURI string `json:"requesturi"` Host string `json:"host"` Created time.Time `json:"created"` Session *mgo.Session `json:,omit` }
Petition is a representation from the request received. Header fields are cooked to represent the final request meant to be sent to the target host. The relayer's own fields are removed
type Recoverer ¶
type Recoverer struct { SendTo chan<- *Petition //Configuration object Cfg *config.Config //Session seed for mongo SessionSeed *mgo.Session }
Recoverer takes the petitions stored in PetitionStore and enqueues them again into SendTo.
func (*Recoverer) Recover ¶
Recover gets all the petitions stored and sends them to a channel for processing by a consumer. It returns when all of them are re-enqueued or when an error happens. It should be run before starting a listener (with the same PetitionStore) or new petitions could be enqueued twice. Listeners with a different PetitionStore should not be a problem. A Consumer can be started before with the same PetitionStore to avoid overflowing the queue.
type Reply ¶
type Reply struct { //Reply id. Currently the same as the petition id ID string `json:"id"` TraceID string `json:"traceid"` //Possible error in making the request. Could be "" Error string `json:"error"` StatusCode int `json:"statuscode"` // e.g. 200 Proto string `json:"proto"` // e.g. "HTTP/1.0" Header http.Header `json:"header"` Trailer http.Header `json:"trailer"` Body []byte `json:"body"` //Petition that Petition *Petition `json:"petition"` //Beginning of the request Created time.Time `json:"created"` //Time when response was received Done time.Time `json:"done"` }
Reply represents the response from the target host
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package config provides types and a function for getting grush configuration.
|
Package config provides types and a function for getting grush configuration. |
Executable of grush grush.ini contains configuration data read when starting at run-time
|
Executable of grush grush.ini contains configuration data read when starting at run-time |