Documentation ¶
Index ¶
- Constants
- func AddTrustStoreEntry(ctx context.Context, c *Client, args types.ClusterMemberLocal) error
- func DeleteTrustStoreEntry(ctx context.Context, c *Client, name string) error
- func IsForwardedRequest(r *http.Request) bool
- func TLSClientConfig(clientCert *shared.CertInfo, remoteCert *x509.Certificate) (*tls.Config, error)
- type Client
- func (c *Client) AddClusterMember(ctx context.Context, args types.ClusterMember) (*types.TokenResponse, error)
- func (c *Client) CheckReady(ctx context.Context) error
- func (c *Client) ControlDaemon(ctx context.Context, args types.Control) error
- func (c *Client) DeleteClusterMember(ctx context.Context, name string, force bool) error
- func (c *Client) DeleteTokenRecord(ctx context.Context, name string) error
- func (c *Client) GetClusterMembers(ctx context.Context) ([]types.ClusterMember, error)
- func (c *Client) GetSQL(ctx context.Context, schema bool) (*types.SQLDump, error)
- func (c *Client) GetTokenRecords(ctx context.Context) ([]types.TokenRecord, error)
- func (c *Client) Heartbeat(ctx context.Context, hbInfo types.HeartbeatInfo) error
- func (c *Client) MakeRequest(r *http.Request) (*api.Response, error)
- func (c *Client) PostSQL(ctx context.Context, query types.SQLQuery) (*types.SQLBatch, error)
- func (c *Client) QueryStruct(ctx context.Context, method string, endpointType EndpointType, ...) error
- func (c *Client) RequestToken(ctx context.Context, name string) (string, error)
- func (c *Client) ResetClusterMember(ctx context.Context, name string, force bool) error
- func (c *Client) SetClusterNotification()
- func (c *Client) ShutdownDaemon(ctx context.Context) error
- func (c *Client) URL() api.URL
- func (c *Client) UpdateClusterCertificate(ctx context.Context, args apiTypes.ClusterCertificatePut) error
- func (c *Client) UseTarget(name string) *Client
- type EndpointType
Constants ¶
const HeartbeatTimeout = 30
HeartbeatTimeout is the maximum request timeout for a heartbeat request.
Variables ¶
This section is empty.
Functions ¶
func AddTrustStoreEntry ¶
AddTrustStoreEntry adds a new record to the truststore on all cluster members.
func DeleteTrustStoreEntry ¶
DeleteTrustStoreEntry deletes the record corresponding to the given cluster member from the trust store.
func IsForwardedRequest ¶
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 ¶
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 ¶
CheckReady returns once the daemon has signalled to the ready channel that it is done setting up.
func (*Client) ControlDaemon ¶
ControlDaemon posts control data to the daemon.
func (*Client) DeleteClusterMember ¶
DeleteClusterMember deletes the cluster member with the given name.
func (*Client) DeleteTokenRecord ¶
DeleteTokenRecord deletes the toekn record.
func (*Client) GetClusterMembers ¶
GetClusterMembers returns the database record of cluster members.
func (*Client) GetTokenRecords ¶
GetTokenRecords returns the token records.
func (*Client) MakeRequest ¶
MakeRequest performs a request and parses the response into an api.Response.
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 ¶
RequestToken requests a join token with the given name.
func (*Client) ResetClusterMember ¶
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 ¶
ShutdownDaemon begins the daemon shutdown sequence.
func (*Client) UpdateClusterCertificate ¶
func (c *Client) UpdateClusterCertificate(ctx context.Context, args apiTypes.ClusterCertificatePut) error
UpdateClusterCertificate sets a new cluster keypair and CA.
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" )