Documentation ¶
Overview ¶
Package pyproxy facilities migrating traffic from Python to Go.
Index ¶
- type Proxy
- func (m *Proxy) DefaultOverride(route string, rw http.ResponseWriter, req *http.Request) bool
- func (m *Proxy) PickRouteBasedOnHeaders(ctx context.Context, req *http.Request) string
- func (m *Proxy) RandomizedOverride(ctx context.Context, route string, rw http.ResponseWriter, req *http.Request) bool
- func (m *Proxy) RouteToPython(rw http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy can proxy a portion of requests to Python.
func NewProxy ¶
NewProxy sets up a proxy that send a portion of traffic to the Python host.
Requests that hit the Go server are either handled by it or get proxied to the Python server, based on `traffic_migration` table in settings.cfg.
func (*Proxy) DefaultOverride ¶
DefaultOverride implements the default routing rule.
It routes the request based on "X-Route-To" header (if present) or randomly with a configured probability (if the headers is absent).
Returns true of the request was routed to Python and was already processed. Returns false if the request should be processed by Go.
func (*Proxy) PickRouteBasedOnHeaders ¶
PickRouteBasedOnHeaders picks a backend based on the request headers.
Returns either "go", "py" or "" (if headers indicate no preference). Logs the choice.
func (*Proxy) RandomizedOverride ¶
func (m *Proxy) RandomizedOverride(ctx context.Context, route string, rw http.ResponseWriter, req *http.Request) bool
RandomizedOverride routes the request either to Python or Go based only on a random number generator (ignoring any headers).
Returns true of the request was routed to Python and was already processed. Returns false if the request should be processed by Go.
func (*Proxy) RouteToPython ¶
func (m *Proxy) RouteToPython(rw http.ResponseWriter, req *http.Request)
RouteToPython sends the request to the Python server for handling.