Documentation
¶
Index ¶
- func AddClusterMember(ctx context.Context, c types.Client, args types.ClusterMember) (*types.TokenResponse, error)
- func AddTrustStoreEntry(ctx context.Context, c types.Client, args types.ClusterMemberLocal) error
- func CheckReady(ctx context.Context, c types.Client) error
- func ControlDaemon(ctx context.Context, c types.Client, args types.Control) error
- func DeleteClusterMember(ctx context.Context, c types.Client, name string, address string, force bool) error
- func DeleteTokenRecord(ctx context.Context, c types.Client, name string) error
- func DeleteTrustStoreEntry(ctx context.Context, c types.Client, name string) error
- func GetClusterMembers(ctx context.Context, c types.Client) ([]types.ClusterMember, error)
- func GetSQL(ctx context.Context, c types.Client, schema bool) (*types.SQLDump, error)
- func GetTokenRecords(ctx context.Context, c types.Client) ([]types.TokenRecord, error)
- func IsForwardedRequest(r *http.Request) bool
- func PostSQL(ctx context.Context, c types.Client, query types.SQLQuery) (*types.SQLBatch, error)
- func RequestToken(ctx context.Context, c types.Client, name string, expireAfter time.Duration) (string, error)
- func ResetClusterMember(ctx context.Context, c types.Client, name string, force bool) error
- func RunNewMemberHook(ctx context.Context, c types.Client, config types.HookNewMemberOptions) error
- func RunOnDaemonConfigUpdateHook(ctx context.Context, c types.Client, config *types.DaemonConfig) error
- func RunPostRemoveHook(ctx context.Context, c types.Client, config types.HookRemoveMemberOptions) error
- func RunPreRemoveHook(ctx context.Context, c types.Client, config types.HookRemoveMemberOptions) error
- func ShutdownDaemon(ctx context.Context, c types.Client) error
- func TLSClientConfig(clientCert *shared.CertInfo, remoteCert *x509.Certificate) (*tls.Config, error)
- func UpdateCertificate(ctx context.Context, c types.Client, name types.CertificateName, ...) error
- func UpdateServers(ctx context.Context, c types.Client, config map[string]types.ServerConfig) error
- type Client
- func (c *Client) HTTP() *http.Client
- func (c *Client) MakeRequest(r *http.Request) (*api.Response, error)
- func (c *Client) Query(ctx context.Context, method string, endpointType types.EndpointPrefix, ...) error
- func (c *Client) QueryRaw(ctx context.Context, method string, prefix types.EndpointPrefix, path *url.URL, ...) (*http.Response, error)
- func (c *Client) QueryStructRaw(ctx context.Context, method string, endpointType types.EndpointPrefix, ...) (*http.Response, error)
- func (c *Client) RawWebsocket(ctx context.Context, endpointType types.EndpointPrefix, endpoint *url.URL) (*websocket.Conn, error)
- func (c *Client) SetClusterNotification()
- func (c *Client) URL() *url.URL
- func (c *Client) UseTarget(name string) types.Client
- func (c *Client) Websocket(ctx context.Context, prefix types.EndpointPrefix, path *url.URL) (*websocket.Conn, error)
- type CtxKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddClusterMember ¶
func AddClusterMember(ctx context.Context, c types.Client, args types.ClusterMember) (*types.TokenResponse, error)
AddClusterMember records a new cluster member in the trust store of each current cluster member.
func AddTrustStoreEntry ¶
AddTrustStoreEntry adds a new record to the truststore on all cluster members.
func CheckReady ¶
CheckReady returns once the daemon has signalled to the ready channel that it is done setting up.
func ControlDaemon ¶
ControlDaemon posts control data to the daemon.
func DeleteClusterMember ¶
func DeleteClusterMember(ctx context.Context, c types.Client, name string, address string, force bool) error
DeleteClusterMember deletes the cluster member with the given name. If `address` is non-empty it is sent as a query parameter to target dqlite removal by address when the truststore cannot map name to address. Dqlite does not track names, so this is useful when the name is no longer resolvable.
func DeleteTokenRecord ¶
DeleteTokenRecord deletes the token record.
func DeleteTrustStoreEntry ¶
DeleteTrustStoreEntry deletes the record corresponding to the given cluster member from the trust store.
func GetClusterMembers ¶
GetClusterMembers returns the database record of cluster members.
func GetTokenRecords ¶
GetTokenRecords returns the token records.
func IsForwardedRequest ¶
IsForwardedRequest determines if this request has been forwarded from another cluster member.
func RequestToken ¶
func RequestToken(ctx context.Context, c types.Client, name string, expireAfter time.Duration) (string, error)
RequestToken requests a join token with the given name.
func ResetClusterMember ¶
ResetClusterMember clears the state directory of the cluster member, and re-execs its daemon.
func RunNewMemberHook ¶
RunNewMemberHook executes the OnNewMember hook with the given configuration on the cluster member targeted by this client.
func RunOnDaemonConfigUpdateHook ¶
func RunOnDaemonConfigUpdateHook(ctx context.Context, c types.Client, config *types.DaemonConfig) error
RunOnDaemonConfigUpdateHook executes the OnDaemonConfigUpdate hook with the given configuration on the cluster member targeted by this client.
func RunPostRemoveHook ¶
func RunPostRemoveHook(ctx context.Context, c types.Client, config types.HookRemoveMemberOptions) error
RunPostRemoveHook executes the PostRemove hook with the given configuration on the cluster member targeted by this client.
func RunPreRemoveHook ¶
func RunPreRemoveHook(ctx context.Context, c types.Client, config types.HookRemoveMemberOptions) error
RunPreRemoveHook executes the PreRemove hook with the given configuration on the cluster member targeted by this client.
func ShutdownDaemon ¶
ShutdownDaemon begins the daemon shutdown sequence.
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.
func UpdateCertificate ¶
func UpdateCertificate(ctx context.Context, c types.Client, name types.CertificateName, args types.KeyPair) error
UpdateCertificate sets a new keypair and CA.
func UpdateServers ¶
UpdateServers updates the additional servers config.
Types ¶
type Client ¶
Client is a rest client for the daemon.
func New ¶
func New(url *url.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) MakeRequest ¶
MakeRequest performs a request and parses the response into an api.Response. This function can be used instead of the QueryStruct if custom settings have to be applied to the request struct.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, method string, endpointType types.EndpointPrefix, endpoint *url.URL, data any, target any) error
Query 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) QueryRaw ¶
func (c *Client) QueryRaw(ctx context.Context, method string, prefix types.EndpointPrefix, path *url.URL, in any) (*http.Response, error)
QueryRaw is a helper for initiating a request on any endpoints defined external to microcluster. Unlike Query it returns the raw HTTP response.
func (*Client) QueryStructRaw ¶
func (c *Client) QueryStructRaw(ctx context.Context, method string, endpointType types.EndpointPrefix, endpoint *url.URL, data any) (*http.Response, error)
QueryStructRaw sends a request of the specified method to the provided endpoint (optional) on the API matching the endpointType. The raw response is returned. 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) RawWebsocket ¶
func (c *Client) RawWebsocket(ctx context.Context, endpointType types.EndpointPrefix, endpoint *url.URL) (*websocket.Conn, error)
RawWebsocket dials the provided endpoint and tries to upgrade the connection.
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) SetClusterNotification ¶
func (c *Client) SetClusterNotification()
SetClusterNotification sets the client's proxy to apply the forwarding headers to a request.
func (*Client) Websocket ¶
func (c *Client) Websocket(ctx context.Context, prefix types.EndpointPrefix, path *url.URL) (*websocket.Conn, error)
Websocket is a helper for upgrading a request to websocket on any endpoints defined external to microcluster. This function should be used for all client methods defined externally from microcluster.