Making the Proxy.Definintion support balancing
@@ -12,7 +12,9 @@ import (
type Definition struct {
PreserveHost bool `bson:"preserve_host" json:"preserve_host" mapstructure:"preserve_host"`
ListenPath string `bson:"listen_path" json:"listen_path" mapstructure:"listen_path" valid:"required,urlpath"`
- UpstreamURL string `bson:"upstream_url" json:"upstream_url" mapstructure:"upstream_url" valid:"url,required"`
+ // Deprecated: Use Upstreams instead.
+ UpstreamURL string `bson:"upstream_url" json:"upstream_url" valid:"url"`
+ Upstreams *Upstreams `bson:"upstreams" json:"upstreams" mapstructure:"upstreams"`
InsecureSkipVerify bool `bson:"insecure_skip_verify" json:"insecure_skip_verify" mapstructure:"insecure_skip_verify"`
StripPath bool `bson:"strip_path" json:"strip_path" mapstructure:"strip_path"`
AppendPath bool `bson:"append_path" json:"append_path" mapstructure:"append_path"`
@@ -21,6 +23,18 @@ type Definition struct {
Hosts []string `bson:"hosts" json:"hosts"`
}
+// Upstreams represents a collection of targets where the requests will go to
+type Upstreams struct {
+ Balancing string `bson:"balancing" json:"balancing"`
+ Targets []*Target `bson:"targets" json:"targets"`
+}
+
+// Target is an ip address/hostname with a port that identifies an instance of a backend service
+type Target struct {
+ Target string `bson:"target" json:"target" valid:"url,required"`
+ Weight int `bson:"weight" json:"weight"`
+}
+
// NewDefinition creates a new Proxy Definition with default values
func NewDefinition() *Definition {
return &Definition{
