v1.0.0
This commit is contained in:
@@ -7,25 +7,69 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Request struct for update backend
|
||||
type BackendUpdateRequest struct {
|
||||
LBID uint64 `url:"lbId"`
|
||||
// ID of the load balancer instance to backendCreate
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId"`
|
||||
|
||||
// Must be unique among all backends of this load balancer - name of the new backend to create
|
||||
// Required: true
|
||||
BackendName string `url:"backendName"`
|
||||
Algorithm string `url:"algorithm,omitempty"`
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
Rise uint `url:"rise,omitempty"`
|
||||
Fall uint `url:"fall,omitempty"`
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
MaxConn uint `url:"maxconn,omitempty"`
|
||||
MaxQueue uint `url:"maxqueue,omitempty"`
|
||||
Weight uint `url:"weight,omitempty"`
|
||||
|
||||
// Algorithm
|
||||
// Should be one of:
|
||||
// - roundrobin
|
||||
// - static-rr
|
||||
// - leastconn
|
||||
// Required: false
|
||||
Algorithm string `url:"algorithm,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive availability
|
||||
// checks of the server that is considered available
|
||||
// Required: false
|
||||
Inter uint64 `url:"inter,omitempty"`
|
||||
|
||||
// Interval in milliseconds between two consecutive checks to
|
||||
// restore the availability of a server that is currently considered unavailable
|
||||
// Required: false
|
||||
DownInter uint64 `url:"downinter,omitempty"`
|
||||
|
||||
// Number of checks that the server must pass in order to get the available status
|
||||
// and be included in the balancing scheme again
|
||||
// Required: false
|
||||
Rise uint64 `url:"rise,omitempty"`
|
||||
|
||||
// Number of consecutive failed availability checks,
|
||||
// after which the previously considered available server receives the status of
|
||||
// unavailable and is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
Fall uint64 `url:"fall,omitempty"`
|
||||
|
||||
// Interval in milliseconds from the moment the server receives the available status,
|
||||
// after which the number of actually allowed connections to this server will be returned to 100% of the set limit
|
||||
// Required: false
|
||||
SlowStart uint64 `url:"slowstart,omitempty"`
|
||||
|
||||
// Limit of simultaneous connections to the server. When this limit is reached,
|
||||
// the server is temporarily excluded from the balancing scheme
|
||||
// Required: false
|
||||
MaxConn uint64 `url:"maxconn,omitempty"`
|
||||
|
||||
// Limit of connections waiting in the queue.
|
||||
// When this limit is reached, all subsequent connections will be forwarded to other servers
|
||||
// Required: false
|
||||
MaxQueue uint64 `url:"maxqueue,omitempty"`
|
||||
|
||||
// Server weight for use in weight balancing algorithms
|
||||
// Required: false
|
||||
Weight uint64 `url:"weight,omitempty"`
|
||||
}
|
||||
|
||||
func (lbrq BackendUpdateRequest) Validate() error {
|
||||
func (lbrq BackendUpdateRequest) validate() error {
|
||||
if lbrq.LBID == 0 {
|
||||
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
if lbrq.BackendName == "" {
|
||||
return errors.New("validation-error: field BackendName can not be empty")
|
||||
}
|
||||
@@ -33,8 +77,9 @@ func (lbrq BackendUpdateRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BackendUpdate updates existing backend on the specified load balancer. Note that backend name cannot be changed
|
||||
func (l LB) BackendUpdate(ctx context.Context, req BackendUpdateRequest) (bool, error) {
|
||||
err := req.Validate()
|
||||
err := req.validate()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user