client

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultServerURL = "http://localhost:8090/kafkacruisecontrol"
	DefaultUserAgent = "go-cruise-control"
)
View Source
const (
	ServerURLEnvKey   = prefix + "SERVER_URL"
	AuthTypeEnvKey    = prefix + "AUTH_TYPE"
	UsernameEnvKey    = prefix + "USERNAME"
	PasswordEnvKey    = prefix + "PASSWORD"
	AccessTokenEnvKey = prefix + "ACCESS_TOKEN"
	UserAgentEnvKey   = prefix + "USER_AGENT"
)
View Source
const (
	HTTPHeaderUserAgent   = "User-Agent"
	HTTPHeaderAccept      = "Accept"
	HTTPHeaderContentType = "Content-Type"
	MIMETypeJSON          = "application/json"
	ChartSetUTF8          = "utf-8"
	JSONQueryParam        = "json"
	ReasonQueryParam      = "reason"
)
View Source
const (
	HTTPHeaderAuthorization = "Authorization"
)

Variables

This section is empty.

Functions

func ContextWithReason added in v0.5.0

func ContextWithReason(ctx context.Context, reason string) context.Context

func MarshalRequest

func MarshalRequest(v interface{}) (*http.Request, error)

func ReasonFromContext added in v0.5.0

func ReasonFromContext(ctx context.Context) (string, bool)

Types

type AccessTokenAuth

type AccessTokenAuth struct {
	// contains filtered or unexported fields
}

func (AccessTokenAuth) Apply

func (a AccessTokenAuth) Apply(r *http.Request) error

type AuthInfo

type AuthInfo interface {
	Apply(r *http.Request) error
}

type AuthType

type AuthType int8
const (
	AuthTypeNone AuthType = iota
	AuthTypeBasic
	AuthTypeAccessToken
)

func AuthTypeFromString

func AuthTypeFromString(s string) AuthType

func (AuthType) String

func (t AuthType) String() string

type BasicAuth

type BasicAuth struct {
	// contains filtered or unexported fields
}

func (BasicAuth) Apply

func (a BasicAuth) Apply(r *http.Request) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts *Config) (*Client, error)

NewClient returns a new API client with the provided configuration. It returns an error if the configuration is invalid.

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient return a new API client with default configuration. It returns an error if the configuration is invalid.

func (*Client) AddBroker

func (*Client) Admin

func (c *Client) Admin(ctx context.Context, r *api.AdminRequest) (*api.AdminResponse, error)

func (*Client) Bootstrap

func (*Client) DemoteBroker

func (*Client) FixOfflineReplicas

func (*Client) KafkaClusterLoad

func (*Client) KafkaClusterState

func (*Client) KafkaPartitionLoad

func (*Client) PauseSampling

func (*Client) Proposals

func (*Client) Rebalance

func (*Client) RemoveBroker

func (*Client) ResumeSampling

func (*Client) Review

func (c *Client) Review(ctx context.Context, r *api.ReviewRequest) (*api.ReviewResponse, error)

func (*Client) ReviewBoard

ReviewBoard returns a list of Cruise Control requests with their review state.

func (*Client) Rightsize

Rightsize allows manually invoke provisioner rightsizing of the cluster.

func (*Client) State

func (c *Client) State(ctx context.Context, r *api.StateRequest) (*api.StateResponse, error)

State reports back the Cruise Control state.

func (*Client) StopProposalExecution

StopProposalExecution invoke stopping of ongoing proposal execution in Cruise Control.

func (Client) String

func (c Client) String() string

func (*Client) TopicConfiguration

TopicConfiguration allows changing Kafka topic configuration using Cruise Control.

func (*Client) Train

func (c *Client) Train(ctx context.Context, r *api.TrainRequest) (*api.TrainResponse, error)

Train Cruise Control to better model broker cpu usage.

func (*Client) UserTasks

UserTasks returns the list of recent tasks performed by Cruise Control.

type Config

type Config struct {
	ServerURL   string
	AuthType    AuthType
	Username    string
	Password    string
	AccessToken string
	UserAgent   string

	HTTPClient *http.Client
}

Config contains the configuration parameters for the API Client

func (*Config) ReadFromEnvironment

func (c *Config) ReadFromEnvironment()

type ContentType

type ContentType struct {
	MIMEType string
	ChartSet string
	Boundary string
}

type RequestMarshaler

type RequestMarshaler interface {
	MarshalRequest() (*http.Request, error)
}

RequestMarshaler is the interface implemented by types that can marshal themselves into valid http.Request

type RequestOptionApplier added in v0.4.0

type RequestOptionApplier func(*http.Request) error

func WithAcceptJSON

func WithAcceptJSON() RequestOptionApplier

func WithAuthInfo

func WithAuthInfo(a AuthInfo) RequestOptionApplier

func WithContentTypeJSON

func WithContentTypeJSON() RequestOptionApplier

func WithContext

func WithContext(ctx context.Context) RequestOptionApplier

func WithEndpoint

func WithEndpoint(endpoint types.APIEndpoint) RequestOptionApplier

func WithHeader

func WithHeader(h string, v string) RequestOptionApplier

func WithJSONQuery

func WithJSONQuery() RequestOptionApplier

func WithMethod

func WithMethod(m string) RequestOptionApplier

func WithQuery added in v0.5.0

func WithQuery(k, v string) RequestOptionApplier

func WithReasonFromContext added in v0.5.0

func WithReasonFromContext(ctx context.Context) RequestOptionApplier

func WithServerURL

func WithServerURL(u *url.URL) RequestOptionApplier

func WithUserAgent

func WithUserAgent(agent string) RequestOptionApplier

type RequestOptions

type RequestOptions interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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