autoscale

package
v0.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Endpoint is the public path for the autoscale service.
	Endpoint = "/services/autoscale"

	// AutoscaleEndpoint is the public path for the autoscale service.
	AutoscaleEndpoint = "/autoscale"

	// AutoscalePolicyEndpoint is the public path for the autoscale policy service.
	AutoscalePolicyEndpoint = "/policies"
)
View Source
const (
	// PolicyMetricCPU is the CPU autoscale policy metric.
	PolicyMetricCPU = "cpu"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddPolicyResponseItem added in v0.5.0

type AddPolicyResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

AddPolicyResponseItem is a data item from a response to a POST /services/<uuid>/autoscale/policies request. https://docs.kraft.cloud/api/v1/autoscale/#adding-an-autoscale-policy

type AdjustmentType added in v0.5.0

type AdjustmentType string

AdjustmentType is the autoscale adjustment type.

const (
	// AdjustmentTypePercent is the percent autoscale adjustment type.
	AdjustmentTypePercent AdjustmentType = "percent"
	// AdjustmentTypeAbsolute is the absolute autoscale adjustment type.
	AdjustmentTypeAbsolute AdjustmentType = "absolute"
	// AdjustmentTypeChange is the change autoscale adjustment type.
	AdjustmentTypeChange AdjustmentType = "change"
)

type AutoscaleService

type AutoscaleService interface {
	kcclient.ServiceClient[AutoscaleService]

	// CreateConfiguration creates a new autoscale configuration.
	CreateConfiguration(ctx context.Context, req CreateRequest) (*kcclient.ServiceResponse[CreateResponseItem], error)

	// GetConfigurations returns the current states and configurations of
	// autoscale configurations.
	GetConfigurations(ctx context.Context, ids ...string) (*kcclient.ServiceResponse[GetResponseItem], error)

	// DeleteConfigurations deletes autoscale configurations.
	DeleteConfigurations(ctx context.Context, ids ...string) (*kcclient.ServiceResponse[DeleteResponseItem], error)

	// AddPolicy adds a new autoscale policy to an autoscale configuration.
	AddPolicy(ctx context.Context, autoscaleUUID string, req Policy) (*kcclient.ServiceResponse[AddPolicyResponseItem], error)

	// GetPolicy returns the current state and configuration of an autoscale policy.
	GetPolicy(ctx context.Context, autoscaleUUID, name string) (*kcclient.ServiceResponse[GetPolicyResponseItem], error)

	// DeletePolicy deletes an autoscale policy.
	DeletePolicy(ctx context.Context, autoscaleUUID, name string) (*kcclient.ServiceResponse[DeletePolicyResponseItem], error)
}

func NewAutoscaleClientFromOptions

func NewAutoscaleClientFromOptions(opts *options.Options) AutoscaleService

NewAutoscaleClientFromOptions instantiates a new autoscale services client based on the provided pre-existing options.

type CreateRequest added in v0.5.0

type CreateRequest struct {
	UUID           *string             `json:"uuid,omitempty"` // mutually exclusive with name
	Name           *string             `json:"name,omitempty"` // mutually exclusive with uuid
	MinSize        *int                `json:"min_size,omitempty"`
	MaxSize        *int                `json:"max_size,omitempty"`
	WarmupTimeMs   *int                `json:"warmup_time_ms,omitempty"`
	CooldownTimeMs *int                `json:"cooldown_time_ms,omitempty"`
	Master         CreateRequestMaster `json:"master"`
	Policies       []Policy            `json:"policies,omitempty"`
}

CreateRequest is the payload for a POST /services/<uuid>/autoscale request. https://docs.kraft.cloud/api/v1/autoscale/#creating-an-autoscale-configuration

type CreateRequestMaster added in v0.5.0

type CreateRequestMaster struct {
	UUID *string `json:"uuid,omitempty"` // mutually exclusive with name
	Name *string `json:"name,omitempty"` // mutually exclusive with uuid
}

type CreateResponseItem added in v0.5.0

type CreateResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

CreateResponseItem is a data item from a response to a POST /services/<uuid>/autoscale request. https://docs.kraft.cloud/api/v1/autoscale/#creating-an-autoscale-configuration

type DeletePolicyResponseItem added in v0.5.0

type DeletePolicyResponseItem struct {
	Status string `json:"status"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

DeletePolicyResponseItem is a data item from a response to a DELETE /services/<uuid>/autoscale/policies request. https://docs.kraft.cloud/api/v1/autoscale/#deleting-an-autoscale-policy

type DeleteResponseItem added in v0.5.0

type DeleteResponseItem struct {
	Status string `json:"status"`
	UUID   string `json:"uuid"`
	Name   string `json:"name"`

	kcclient.APIResponseCommon
}

DeleteResponseItem is a data item from a response to a DELETE /services/<uuid>/autoscale request. https://docs.kraft.cloud/api/v1/autoscale/#deleting-an-autoscale-configuration

type GetPolicyResponseItem added in v0.5.0

type GetPolicyResponseItem struct {
	Status  string
	Enabled bool
	Details Policy

	kcclient.APIResponseCommon
}

GetPolicyResponseItem is a data item from a response to a GET /services/<uuid>/autoscale/policies request. https://docs.kraft.cloud/api/v1/autoscale/#getting-the-configuration-of-an-autoscale-policy

func (*GetPolicyResponseItem) UnmarshalJSON added in v0.5.0

func (i *GetPolicyResponseItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type GetResponseItem added in v0.5.0

type GetResponseItem struct {
	Status         string             `json:"status"`
	UUID           string             `json:"uuid"`
	Name           string             `json:"name"`
	Enabled        bool               `json:"enabled"`
	MinSize        *int               `json:"min_size"`         // only if enabled
	MaxSize        *int               `json:"max_size"`         // only if enabled
	WarmupTimeMs   *int               `json:"warmup_time_ms"`   // only if enabled
	CooldownTimeMs *int               `json:"cooldown_time_ms"` // only if enabled
	Master         *GetResponseMaster `json:"master"`           // only if enabled
	Policies       []Policy           `json:"policies"`

	kcclient.APIResponseCommon
}

GetResponseItem is a data item from a response to a GET /services/<uuid>/autoscale request. https://docs.kraft.cloud/api/v1/autoscale/#getting-an-existing-autoscale-configuration

func (*GetResponseItem) UnmarshalJSON added in v0.5.0

func (i *GetResponseItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type GetResponseMaster added in v0.5.0

type GetResponseMaster struct {
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

type Policy added in v0.5.0

type Policy interface {
	Type() PolicyType
}

Policy is implemented by all types that represent an autoscale policy.

type PolicyMetric added in v0.5.0

type PolicyMetric string

PolicyMetric is the autoscale policy metric.

type PolicyType added in v0.5.0

type PolicyType string

PolicyType is the type of the autoscale policy.

const PolicyTypeStep PolicyType = "step"

type Step added in v0.5.0

type Step struct {
	Adjustment int
	LowerBound *int
	UpperBound *int
}

Step is a step in a StepPolicy.

func (Step) MarshalJSON added in v0.5.0

func (s Step) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type StepPolicy added in v0.5.0

type StepPolicy struct {
	Name           string
	Metric         PolicyMetric
	AdjustmentType AdjustmentType
	Steps          []Step
}

StepPolicy is a Step autoscale policy. https://docs.kraft.cloud/api/v1/autoscale/#step-policy

func (StepPolicy) MarshalJSON added in v0.5.0

func (p StepPolicy) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (StepPolicy) Type added in v0.5.0

func (p StepPolicy) Type() PolicyType

Type implements Policy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL