client

package
v0.0.0-...-87fa518 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const HeartbeatTimeout = 30

HeartbeatTimeout is the maximum request timeout for a heartbeat request.

Variables

This section is empty.

Functions

func AddTrustStoreEntry

func AddTrustStoreEntry(ctx context.Context, c *Client, args types.ClusterMemberLocal) error

AddTrustStoreEntry adds a new record to the truststore on all cluster members.

func DeleteTrustStoreEntry

func DeleteTrustStoreEntry(ctx context.Context, c *Client, name string) error

DeleteTrustStoreEntry deletes the record corresponding to the given cluster member from the trust store.

func IsForwardedRequest

func IsForwardedRequest(r *http.Request) bool

IsForwardedRequest determines if this request has been forwarded from another cluster member.

func TLSClientConfig

func TLSClientConfig(clientCert *shared.CertInfo, remoteCert *x509.Certificate) (*tls.Config, error)

TLSClientConfig returns a TLS configuration suitable for establishing horizontal and vertical connections. clientCert contains the private key pair for the client. remoteCert is the public key of the server we are connecting to.

Types

type Client

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

Client is a rest client for the daemon.

func New

func New(url api.URL, clientCert *shared.CertInfo, remoteCert *x509.Certificate, forwarding bool) (*Client, error)

New returns a new client configured with the given url and certificates.

func (*Client) AddClusterMember

func (c *Client) AddClusterMember(ctx context.Context, args types.ClusterMember) (*types.TokenResponse, error)

AddClusterMember records a new cluster member in the trust store of each current cluster member.

func (*Client) CheckReady

func (c *Client) CheckReady(ctx context.Context) error

CheckReady returns once the daemon has signalled to the ready channel that it is done setting up.

func (*Client) ControlDaemon

func (c *Client) ControlDaemon(ctx context.Context, args types.Control) error

ControlDaemon posts control data to the daemon.

func (*Client) DeleteClusterMember

func (c *Client) DeleteClusterMember(ctx context.Context, name string, force bool) error

DeleteClusterMember deletes the cluster member with the given name.

func (*Client) DeleteTokenRecord

func (c *Client) DeleteTokenRecord(ctx context.Context, name string) error

DeleteTokenRecord deletes the toekn record.

func (*Client) GetClusterMembers

func (c *Client) GetClusterMembers(ctx context.Context) ([]types.ClusterMember, error)

GetClusterMembers returns the database record of cluster members.

func (*Client) GetSQL

func (c *Client) GetSQL(ctx context.Context, schema bool) (*types.SQLDump, error)

GetSQL gets a SQL dump of the database.

func (*Client) GetTokenRecords

func (c *Client) GetTokenRecords(ctx context.Context) ([]types.TokenRecord, error)

GetTokenRecords returns the token records.

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context, hbInfo types.HeartbeatInfo) error

Heartbeat initiates a new heartbeat sequence if this is a leader node.

func (*Client) MakeRequest

func (c *Client) MakeRequest(r *http.Request) (*api.Response, error)

MakeRequest performs a request and parses the response into an api.Response.

func (*Client) PostSQL

func (c *Client) PostSQL(ctx context.Context, query types.SQLQuery) (*types.SQLBatch, error)

PostSQL executes a SQL query against the database.

func (*Client) QueryStruct

func (c *Client) QueryStruct(ctx context.Context, method string, endpointType EndpointType, endpoint *api.URL, data any, target any) error

QueryStruct sends a request of the specified method to the provided endpoint (optional) on the API matching the endpointType. The response gets unpacked into the target struct. POST requests can optionally provide raw data to be sent through.

The final URL is that provided as the endpoint combined with the applicable prefix for the endpointType and the scheme and host from the client.

func (*Client) RequestToken

func (c *Client) RequestToken(ctx context.Context, name string) (string, error)

RequestToken requests a join token with the given name.

func (*Client) ResetClusterMember

func (c *Client) ResetClusterMember(ctx context.Context, name string, force bool) error

ResetClusterMember clears the state directory of the cluster member, and re-execs its daemon.

func (*Client) SetClusterNotification

func (c *Client) SetClusterNotification()

SetClusterNotification sets the client's proxy to apply the forwarding headers to a request.

func (*Client) ShutdownDaemon

func (c *Client) ShutdownDaemon(ctx context.Context) error

ShutdownDaemon begins the daemon shutdown sequence.

func (*Client) URL

func (c *Client) URL() api.URL

URL returns the address used for the client.

func (*Client) UpdateClusterCertificate

func (c *Client) UpdateClusterCertificate(ctx context.Context, args apiTypes.ClusterCertificatePut) error

UpdateClusterCertificate sets a new cluster keypair and CA.

func (*Client) UseTarget

func (c *Client) UseTarget(name string) *Client

UseTarget returns a new client with the query "?target=name" set.

type EndpointType

type EndpointType string

EndpointType is a type specifying the endpoint on with the resource exists.

const (
	// ExtendedEndpoint - All endpoints added managed by external usage of MicroCluster.
	ExtendedEndpoint EndpointType = "1.0"

	// PublicEndpoint - Internally managed APIs available without authentication.
	PublicEndpoint EndpointType = "cluster/1.0"

	// InternalEndpoint - all endpoints restricted to trusted servers.
	InternalEndpoint EndpointType = "cluster/internal"

	// ControlEndpoint - all endpoints available on the local unix socket.
	ControlEndpoint EndpointType = "cluster/control"
)

Jump to

Keyboard shortcuts

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