Documentation ¶
Index ¶
- Constants
- type FauxRequest
- type Relay
- func (r *Relay) AddrAllowed(addr net.Addr) bool
- func (r *Relay) Close()
- func (r *Relay) Connect()
- func (r *Relay) HandleFunc(path string, f func(http.ResponseWriter, *http.Request)) *mux.Route
- func (r *Relay) Init() error
- func (r *Relay) LastPingTime() time.Time
- func (r *Relay) Listen() error
- func (r *Relay) RelayHandler(w http.ResponseWriter, req *http.Request)
- func (r *Relay) SetCheckInterval(duration time.Duration)
- func (r *Relay) SetDebug(b bool)
- func (r *Relay) Status() RelayStatus
- type RelayMode
- type RelayStatus
- type Relayer
- type Response
Constants ¶
const ( // OFF if the relay is created but not used OFF = RelayMode("") // PassThrough describes the mode in which, requests are accepted and forwarded on to a handler relay PassThrough = RelayMode("passthrough") // Handler mode is when the relay is accepting requests and processing the requests as if they came in from an HTTP server Handler = RelayMode("handle") )
const RelayerPing = "Relayer.Ping"
Rpc call handle
const RelayerRelayRequest = "Relayer.RelayRequest"
Rpc call handle
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FauxRequest ¶
type FauxRequest struct { Method string URL *url.URL Proto string // "HTTP/1.0" ProtoMajor int // 1 ProtoMinor int // 0 Header http.Header Body []byte // io.ReadCloser ContentLength int64 TransferEncoding []string Host string Form url.Values }
FauxRequest is the same as an http.Request, but since we can't send an io.Reader The body is a pre-read byte array
func CreateFauxRequest ¶
func CreateFauxRequest(req *http.Request, body []byte) *FauxRequest
func (*FauxRequest) Request ¶
func (f *FauxRequest) Request() *http.Request
Request turns the FauxRequest into an *http.Request
type Relay ¶
type Relay struct { Host string Port int WhiteList *regexp.Regexp Mode RelayMode Debug bool // contains filtered or unexported fields }
Relay
func (*Relay) AddrAllowed ¶
AddrAllowed takes an address and returns whether that address is allowed by Relay's whitelist Only invoked when the relay is in Passthrough mode, and discards the port
func (*Relay) Connect ¶
func (r *Relay) Connect()
Connect makes an outgoing request to connected to a listening Relay
func (*Relay) HandleFunc ¶
HandleFunc should be used in place of *Router.HandleFunc, to register handlers to accept relayed events.
func (*Relay) LastPingTime ¶
func (*Relay) Listen ¶
Listen opens the configured port and accepts a single tcp connection, if the connection drops this will start listening again for another connection.
func (*Relay) RelayHandler ¶
func (r *Relay) RelayHandler(w http.ResponseWriter, req *http.Request)
RelayHandler takes the place of an actual handler to glue an existing http server to the Relay invoking this handler will forward the request directly to a relay in handle mode
func (*Relay) SetCheckInterval ¶
func (*Relay) Status ¶
func (r *Relay) Status() RelayStatus
Status create and return a RelayStatus for the current status
type RelayStatus ¶
type RelayStatus struct { Health health.State `json:"health"` Mode string `json:"mode"` LastPingTime int64 `json:"lastPingTime,omitempty"` Connected bool `json:"isConnected"` ConnectTime int64 `json:"connectTime,omitempty"` ConnectCount int64 `json:"connectCount,omitempty"` RpcCount int64 `json:"rpcCount,omitempty"` RpcsCounter interface{} `json:"rpcsCounter,omitempty"` ConnectCounter interface{} `json:"connectCounter,omitempty"` RpcLatencySecs interface{} `json:"rpcLatencySecs,omitempty"` PingLatencySecs interface{} `json:"pingLatencySecs,omitempty"` }
RelayStatus describes the health of the relay
type Relayer ¶
type Relayer struct {
// contains filtered or unexported fields
}
Relayer is an internal object specifically for relaying requests via rpc. it must be exported to enable registering as an rpc
func (*Relayer) RelayRequest ¶
func (r *Relayer) RelayRequest(req FauxRequest, response *Response) error
RelayRequest calls a local handler with a relayed request, this should only be called by the RelayHandler, the method signature should not change as it is required to satisfy the rpc.Register receiver input
type Response ¶
Response is a container that encapsulates a response from a relayed request