client

package
v0.18.9-preview-1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerTypeCoordinator = ServerType("coordinator")
	ServerTypeDBServer    = ServerType("dbserver")
	ServerTypeAgent       = ServerType("agent")
	ServerTypeSingle      = ServerType("single")
	ServerTypeSyncMaster  = ServerType("syncmaster")
	ServerTypeSyncWorker  = ServerType("syncworker")
)

Variables

View Source
var (

	// ServiceUnavailableError indicates that right now the service is not available, please retry later.
	ServiceUnavailableError = StatusError{StatusCode: http.StatusServiceUnavailable, /* contains filtered or unexported fields */}
	// BadRequestError indicates invalid arguments.
	BadRequestError = StatusError{StatusCode: http.StatusBadRequest, /* contains filtered or unexported fields */}
	// PreconditionFailedError indicates that the state of the system is such that the request cannot be executed.
	PreconditionFailedError = StatusError{StatusCode: http.StatusPreconditionFailed, /* contains filtered or unexported fields */}
	// InternalServerError indicates an unspecified error inside the server, perhaps a bug.
	InternalServerError = StatusError{StatusCode: http.StatusInternalServerError, /* contains filtered or unexported fields */}
)

Functions

func DefaultHTTPClient

func DefaultHTTPClient() *http.Client

DefaultHTTPClient creates a new HTTP client configured for accessing a starter.

func IsBadRequest

func IsBadRequest(err error) bool

IsBadRequest returns true if the given error is caused by a BadRequestError.

func IsInternalServer

func IsInternalServer(err error) bool

IsInternalServer returns true if the given error is caused by a InternalServerError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the given error is caused by a NotFoundError.

func IsPreconditionFailed

func IsPreconditionFailed(err error) bool

IsPreconditionFailed returns true if the given error is caused by a PreconditionFailedError.

func IsServiceUnavailable

func IsServiceUnavailable(err error) bool

IsServiceUnavailable returns true if the given error is caused by a ServiceUnavailableError.

func IsStatusError

func IsStatusError(err error) (int, bool)

IsStatusError returns the status code and true if the given error is caused by a StatusError.

func IsStatusErrorWithCode

func IsStatusErrorWithCode(err error, code int) bool

IsStatusErrorWithCode returns true if the given error is caused by a StatusError with given code.

func NewBadRequestError

func NewBadRequestError(msg string) error

NewBadRequestError creates a bad request error with given message.

func NewInternalServerError

func NewInternalServerError(msg string) error

NewInternalServerError creates a internal server error with given message.

func NewNotFoundError

func NewNotFoundError(msg string) error

NewNotFoundError creates a not found error with given message.

func NewPreconditionFailedError

func NewPreconditionFailedError(msg string) error

NewPreconditionFailedError creates a precondition failed error with given message.

func NewServiceUnavailableError

func NewServiceUnavailableError(msg string) error

NewServiceUnavailableError creates a service unavailable error with given message.

func ParseResponseError

func ParseResponseError(r *http.Response, body []byte) error

ParseResponseError returns an error from given response. It tries to parse the body (if given body is nil, will be read from response) for ErrorResponse.

Types

type API

type API interface {
	// ID requests the starters ID.
	ID(ctx context.Context) (IDInfo, error)

	// Version requests the starter version.
	Version(ctx context.Context) (VersionInfo, error)

	// DatabaseVersion returns the version of the `arangod` binary that is being
	// used by this starter.
	DatabaseVersion(ctx context.Context) (driver.Version, error)

	// Processes loads information of all the database server processes launched by the starter.
	Processes(ctx context.Context) (ProcessList, error)

	// Endpoints loads the URL's needed to reach all starters, agents & coordinators in the cluster.
	Endpoints(ctx context.Context) (EndpointList, error)

	// Shutdown will shutdown a starter (and all its started database servers).
	// With goodbye set, it will remove the peer slot for the starter.
	Shutdown(ctx context.Context, goodbye bool) error

	// RemovePeer removes a peer with given ID from the starter cluster.
	// The removal tries to cleanout & properly shutdown servers first.
	// If that does not succeed, the operation returns an error,
	// unless force is set to true.
	RemovePeer(ctx context.Context, id string, force bool) error

	// StartDatabaseUpgrade is called to start the upgrade process
	StartDatabaseUpgrade(ctx context.Context, forceMinorUpgrade bool) error

	// RetryDatabaseUpgrade resets a failure mark in the existing upgrade plan
	// such that the starters will retry the upgrade once more.
	RetryDatabaseUpgrade(ctx context.Context) error

	// AbortDatabaseUpgrade removes the existing upgrade plan.
	// Note that Starters working on an entry of the upgrade
	// will finish that entry.
	// If there is no plan, a NotFoundError will be returned.
	AbortDatabaseUpgrade(ctx context.Context) error

	// Status returns the status of any upgrade plan
	UpgradeStatus(context.Context) (UpgradeStatus, error)

	Inventory(ctx context.Context) (api.Inventory, error)

	ClusterInventory(ctx context.Context) (api.ClusterInventory, error)

	AdminJWTRefresh(ctx context.Context) (api.Empty, error)

	AdminJWTActivate(ctx context.Context, token string) (api.Empty, error)
}

API is the interface implemented by the starter's HTTP API's.

func NewArangoStarterClient

func NewArangoStarterClient(endpoint url.URL) (API, error)

NewArangoStarterClient creates a new client implementation.

type DatabaseVersionResponse

type DatabaseVersionResponse struct {
	Version driver.Version `json:"version"`
}

DatabaseVersionResponse is the JSON response of a `/database-version` request.

type EndpointList

type EndpointList struct {
	Starters     []string `json:"starters,omitempty"`     // List of URL's to all starter APIs
	Agents       []string `json:"agents,omitempty"`       // List of URL's to all agents (database servers) in the cluster
	Coordinators []string `json:"coordinators,omitempty"` // List of URL's to all coordinators (database servers) in the cluster
}

EndpointList is the JSON response of a `/endpoints` request. It contains URL's of all starters, agents & coordinators in the cluster.

type ErrorResponse

type ErrorResponse struct {
	Error string
}

ErrorResponse is the JSON structure returned in an API error.

type GoodbyeRequest

type GoodbyeRequest struct {
	SlaveID string // Unique ID of the slave that should be removed.
}

GoodbyeRequest is the JSON structure send in the request to /goodbye.

type IDInfo

type IDInfo struct {
	ID string `json:"id"`
}

IDInfo contains the ID of the starter

type ProcessList

type ProcessList struct {
	ServersStarted bool            `json:"servers-started,omitempty"` // True if the server have all been started
	Servers        []ServerProcess `json:"servers,omitempty"`         // List of servers started by the starter
}

ProcessList is the JSON response of a `/process` request.

func (ProcessList) ServerByType

func (list ProcessList) ServerByType(serverType ServerType) (ServerProcess, bool)

ServerByType returns the server of given type. If no such server process is found, false is returned.

type ServerProcess

type ServerProcess struct {
	Type        ServerType `json:"type"`                   // agent | coordinator | dbserver
	IP          string     `json:"ip"`                     // IP address needed to reach the server
	Port        int        `json:"port"`                   // Port needed to reach the server
	ProcessID   int        `json:"pid,omitempty"`          // PID of the process (0 when running in docker)
	ContainerID string     `json:"container-id,omitempty"` // ID of docker container running the server
	ContainerIP string     `json:"container-ip,omitempty"` // IP address of docker container running the server
	IsSecure    bool       `json:"is-secure,omitempty"`    // If set, this server is using an SSL connection
}

ServerProcess holds all information of a single server started by the starter.

func (*ServerProcess) GetEndpoint

func (s *ServerProcess) GetEndpoint() string

GetEndpoint return address endpoint to the server.

type ServerType

type ServerType string

ServerType holds a type of (arangod) server

type StatusError

type StatusError struct {
	StatusCode int
	// contains filtered or unexported fields
}

StatusError is an error with a given HTTP status code.

func (StatusError) Error

func (e StatusError) Error() string

type UpgradeStatus

type UpgradeStatus struct {
	// Ready is set to true when the entire upgrade has been finished succesfully.
	Ready bool `json:"ready"`
	// Failed is set to true when the upgrade process has yielded an error
	Failed bool `json:"failed"`
	// Reasons contains a human readable description of the state
	Reason string `json:"reason,omitempty"`
	// FromVersions contains all database versions found that will be upgraded.
	FromVersions []driver.Version `json:"from_versions"`
	// ToVersion contains the database version that will be upgraded to.
	ToVersion driver.Version `json:"to_version"`
	// ServersUpgraded contains the servers that have been upgraded
	ServersUpgraded []UpgradeStatusServer `json:"servers_upgraded"`
	// ServersRemaining contains the servers that have not yet been upgraded
	ServersRemaining []UpgradeStatusServer `json:"servers_remaining"`
}

UpgradeStatus is the JSON structure returns from a `GET /database-auto-upgrade` request.

type UpgradeStatusServer

type UpgradeStatusServer struct {
	// Type of the server
	Type ServerType `json:"type"`
	// Port the server is listening on
	Port int `json:"port"`
	// Address of the server (IP or hostname)
	Address string `json:"address"`
}

UpgradeStatusServer is the nested JSON structure returns from a `GET /database-auto-upgrade` request.

type VersionInfo

type VersionInfo struct {
	Version string `json:"version"`
	Build   string `json:"build"`
}

VersionInfo is the JSON response of a `/version` request.

Jump to

Keyboard shortcuts

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