client

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (

	// UnixScheme is a scheme for unix.
	UnixScheme = "unix"

	// TCPScheme is a scheme for TCP.
	TCPScheme = "tcp"

	// HTTPScheme is a scheme for HTTP.
	HTTPScheme = "http"

	// HTTPSScheme is a scheme for HTTPS.
	HTTPSScheme = "https"
)

Variables

This section is empty.

Functions

func GenTLSConfig

func GenTLSConfig(key, cert, ca string) (*tls.Config, error)

GenTLSConfig returns a TLS config object according to inputting parameters.

func NewHTTPClient

func NewHTTPClient(u *url.URL, tlsConfig *tls.Config, dialTimeout time.Duration) *http.Client

NewHTTPClient creates a http client using url and tlsconfig.

func ParseHost

func ParseHost(host string) (*url.URL, string, string, error)

ParseHost inputs a host address string, and output four type: url.URL, basePath, address without scheme and an error.

Types

type APIClient

type APIClient struct {
	HTTPCli *http.Client
	// contains filtered or unexported fields
}

APIClient is an API client that performs all operations. against a server

func (*APIClient) BaseURL

func (client *APIClient) BaseURL() string

BaseURL returns the base URL of APIClient.

func (*APIClient) GetAPIPath

func (client *APIClient) GetAPIPath(path string, query url.Values) string

GetAPIPath returns the versioned request path to call the api. It appends the query parameters to the path if they are not empty.

func (*APIClient) PeerCreate

func (client *APIClient) PeerCreate(ctx context.Context, request *types.PeerCreateRequest) (peerCreateResponse *types.PeerCreateResponse, err error)

PeerCreate creates a peer node in supernode.

func (*APIClient) PeerDelete

func (client *APIClient) PeerDelete(ctx context.Context, id string) error

PeerDelete deletes the specified peer in supernode.

func (*APIClient) PeerInfo

func (client *APIClient) PeerInfo(ctx context.Context, id string) (peerInfoResponse *types.PeerInfo, err error)

PeerInfo gets detailed information of a peer in supernode.

func (*APIClient) PeerList

func (client *APIClient) PeerList(ctx context.Context, id string) (peersInfoResponse []*types.PeerInfo, err error)

PeerList lists detailed information of all peers in supernode.

func (*APIClient) Ping

func (client *APIClient) Ping(ctx context.Context) (string, error)

Ping sends a _ping request to supernode to see if it's working.

func (*APIClient) PreheatCreate

func (client *APIClient) PreheatCreate(ctx context.Context, config *types.PreheatCreateRequest) (preheatCreateResponse *types.PreheatCreateResponse, err error)

PreheatCreate creates a preheat task.

func (*APIClient) PreheatInfo

func (client *APIClient) PreheatInfo(ctx context.Context, id string) (preheatInfoResponse *types.PreheatInfo, err error)

PreheatInfo gets detailed information of a preheat task.

func (*APIClient) PreheatList

func (client *APIClient) PreheatList(ctx context.Context, id string) ([]*types.PreheatInfo, error)

PreheatList lists detailed information of preheat tasks.

func (*APIClient) TaskCreate added in v1.0.0

func (client *APIClient) TaskCreate(ctx context.Context, request *types.TaskCreateRequest) (taskCreateResponse *types.TaskCreateResponse, err error)

TaskCreate creates a task in supernode.

func (*APIClient) TaskDelete added in v0.4.3

func (client *APIClient) TaskDelete(ctx context.Context, id string) error

TaskDelete deletes the specified task in supernode.

func (*APIClient) TaskInfo added in v0.4.3

func (client *APIClient) TaskInfo(ctx context.Context, id string) (taskInfoResponse *types.TaskInfo, err error)

TaskInfo gets detailed information of a task in supernode.

func (*APIClient) TaskUpdate added in v0.4.3

func (client *APIClient) TaskUpdate(ctx context.Context, id string, config *types.TaskUpdateRequest) error

TaskUpdate updates a task in supernode.

func (*APIClient) UpdateClientVersion

func (client *APIClient) UpdateClientVersion(v string)

UpdateClientVersion sets client version new value.

type CommonAPIClient

type CommonAPIClient interface {
	PreheatAPIClient
	PeerAPIClient
	TaskAPIClient
}

CommonAPIClient defines common methods of api client.

func NewAPIClient

func NewAPIClient(host string, tls TLSConfig) (CommonAPIClient, error)

NewAPIClient initializes a new API client for the given host.

type PeerAPIClient added in v1.0.1

type PeerAPIClient interface {
	PeerCreate(ctx context.Context, request *types.PeerCreateRequest) (peerCreateResponse *types.PeerCreateResponse, err error)
	PeerDelete(ctx context.Context, id string) error
	PeerInfo(ctx context.Context, id string) (peerInfoResponse *types.PeerInfo, err error)
	PeerList(ctx context.Context, id string) (peersInfoResponse []*types.PeerInfo, err error)
}

PeerAPIClient defines methods of peer related client.

type PreheatAPIClient

type PreheatAPIClient interface {
	PreheatCreate(ctx context.Context, request *types.PreheatCreateRequest) (preheatCreateResponse *types.PreheatCreateResponse, err error)
	PreheatInfo(ctx context.Context, id string) (preheatInfoResponse *types.PreheatInfo, err error)
}

PreheatAPIClient defines methods of Container client.

type RespError

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

RespError defines the response error.

func (RespError) Code

func (e RespError) Code() int

Code returns the response code.

func (RespError) Error

func (e RespError) Error() string

Error implements the error interface.

type Response

type Response struct {
	StatusCode int
	Status     string
	Body       io.ReadCloser
}

Response wraps the http.Response and other states.

type TLSConfig

type TLSConfig struct {
	CA               string `json:"tlscacert,omitempty"`
	Cert             string `json:"tlscert,omitempty"`
	Key              string `json:"tlskey,omitempty"`
	VerifyRemote     bool   `json:"tlsverify,omitempty"`
	ManagerWhiteList string `json:"manager-whitelist,omitempty"`
}

TLSConfig contains information of TLS which users can specify.

type TaskAPIClient added in v1.0.1

type TaskAPIClient interface {
	TaskCreate(ctx context.Context, request *types.TaskCreateRequest) (taskCreateResponse *types.TaskCreateResponse, err error)
	TaskDelete(ctx context.Context, id string) error
	TaskInfo(ctx context.Context, id string) (taskInfoResponse *types.TaskInfo, err error)
	TaskUpdate(ctx context.Context, id string, config *types.TaskUpdateRequest) error
}

TaskAPIClient defines methods of task related client.

Jump to

Keyboard shortcuts

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