autoscale

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: BSD-3-Clause Imports: 12 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) (*CreateResponseItem, error)

	// GetConfigurationByName returns the current state and the configuration of
	// an autoscale configuration
	GetConfigurationByName(ctx context.Context, name string) (*GetResponseItem, error)

	// GetConfigurationByUUID returns the current state and the configuration of
	// an autoscale configuration
	GetConfigurationByUUID(ctx context.Context, uuid string) (*GetResponseItem, error)

	// DeleteConfigurationByUUID deletes an autoscale configuration given its
	// UUID.
	DeleteConfigurationByUUID(ctx context.Context, uuid string) (*DeleteResponseItem, error)

	// DeleteConfigurationByName deletes an autoscale configuration given its
	// name.
	DeleteConfigurationByName(ctx context.Context, name string) (*DeleteResponseItem, error)

	// AddPolicy adds a new autoscale policy to an autoscale configuration.
	AddPolicy(ctx context.Context, uuid string, req Policy) (*AddPolicyResponseItem, error)

	// GetPolicyByName returns the current state and configuration of an
	// autoscale policy.
	GetPolicyByName(ctx context.Context, uuid, name string) (*GetPolicyResponseItem, error)

	// DeletePolicyByName deletes an autoscale policy given its name.
	DeletePolicyByName(ctx context.Context, uuid, name string) (*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"` // mutually exclusive with name
	Name           *string             `json:"name"` // mutually exclusive with uuid
	MinSize        *int                `json:"min_size"`
	MaxSize        *int                `json:"max_size"`
	WarmupTimeMs   *int                `json:"warmup_time_ms"`
	CooldownTimeMs *int                `json:"cooldown_time_ms"`
	Master         CreateRequestMaster `json:"master"`
	Policies       []Policy            `json:"policies"`
}

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"` // mutually exclusive with name
	Name *string `json:"name"` // 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