Documentation ¶
Overview ¶
Package meta provides a client to the meta node to allow Kapacitor to perform auth. The real home of the meta client is in the InfluxDB Enterprise repo, however kapacitor's current dependency in influxdb is stuck on 1.1. This package allows kapacitor to use the newest meta client API but avoid having to upgrade kapacitor's dependency on influxdb which is now a couple years behind.
Index ¶
Constants ¶
const ( // DefaultTimeout is the duration that the client will continue to // retry a failed operation. DefaultTimeout = 10 * time.Second // DefaultBackoffCap is the maximum duration a backoff value can // have. DefaultBackoffCap = DefaultTimeout / 3 // MaxClientRedirects is the maximum number of redirects the Client will // attempt to follow for a single request, before failing. MaxClientRedirects = 5 )
Variables ¶
var ( // ErrAddressMissing is returned when a required addr parameter is // missing. ErrAddressMissing = errors.New("addr value is empty") // ErrHTTPAddressMissing is returned when a required httpAddr // parameter is missing. ErrHTTPAddressMissing = errors.New("httpAddr value is empty") // ErrTCPAddressMissing is returned when a required tcpAddr // parameter is missing. ErrTCPAddressMissing = errors.New("tcpAddr value is empty") // ErrLeaseNameMissing is returned when a required lease name is // missing. ErrLeaseNameMissing = errors.New("lease name is empty") // ErrLeaseConflict is returned when there is a conflict while // attempting to require a lease. ErrLeaseConflict = errors.New("another node owns the lease") // ErrMaximumRedirectsReached is returned when a Client has been // redirected too many times for a single request. ErrMaximumRedirectsReached = errors.New("too many redirects") // ErrNotMetaNode is returned when attempting to add a non-meta node // as a meta node in the cluster. ErrNotMetaNode = errors.New("not a meta node") // ErrEmptyCluster is returned when there are no nodes known to the // cluster. ErrEmptyCluster = errors.New("cluster is empty") ErrEmptyStatus = errors.New("status is empty") // ErrAntiEntropyDisabled is returned when the anti-entropy service // returns a 501 Not Implemented HTTP status. ErrAntiEntropyDisabled = errors.New("anti-entropy service is not enabled") )
var UseAuth = func(t AuthType, username, password, secret string) ClientOption { return func(c *Client) { c.authType = t c.username = username c.password = password c.secret = secret } }
UseAuth sets the authentication type and credentials that will be used.
var WithTLS = func(tlsConfig *tls.Config, useTLS bool, skip bool) ClientOption { return func(c *Client) { c.useTLS = useTLS if skip { c.skipTLS = true c.tls = &tls.Config{ InsecureSkipVerify: true, } } else if useTLS { c.tls = tlsConfig } if t, ok := c.client.Transport.(*http.Transport); ok { t.TLSClientConfig = c.tls } else { c.client.Transport = &http.Transport{ TLSClientConfig: c.tls, } } } }
WithTLS specifies if communication to the meta node uses the specified TLS config if any and if we skip verifying certificates, allowing for self-signed certificates.
var WithTimeout = func(d time.Duration) ClientOption { return func(c *Client) { c.timeout = d c.backoffCap = c.timeout / 3 if t, ok := c.client.Transport.(*http.Transport); ok { t.ResponseHeaderTimeout = d } else { c.client.Transport = &http.Transport{ ResponseHeaderTimeout: d, } } } }
WithTimeout specifies the duration the client will continue to retry failed operations before giving up.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the HTTP API exposed by a Plutonium Meta node.
func NewClient ¶
func NewClient(addr string, options ...ClientOption) *Client
NewClient returns a new Client, which will make requests to the Meta node listening on addr. New accepts zero or more functional options for configuring aspects of the returned Client.
By default, a Client does not send communications over a TLS connection. TLS can be enforced using the WithTLS option. Output and errors are logged to stdout and stderr, respectively; use the appropriate options to set those outputs.
type ClientHTTPOption ¶ added in v1.6.6
type ClientOption ¶
type ClientOption func(c *Client)
ClientOption is a functional option for a Client.
func WithHTTPOption ¶ added in v1.6.6
func WithHTTPOption(opt ClientHTTPOption) ClientOption
type FatalError ¶
type FatalError struct {
Context error
}
A FatalError is returned when an operation on the meta node API was not successful and retrying the operation would always result in the same error being returned.
FatalError makes the last underlying error available in the Context field.
func (FatalError) Error ¶
func (e FatalError) Error() string
type Permission ¶
type Permission int
Permission type NOTE: Keep this type up-to-date with the corresponding type in meta/data.go The type cannot be imported as it creates an import cycle.
const ( NoPermissions Permission = 0 ViewAdminPermission Permission = 1 ViewChronografPermission Permission = 2 CreateDatabasePermission Permission = 3 CreateUserAndRolePermission Permission = 4 AddRemoveNodePermission Permission = 5 DropDatabasePermission Permission = 6 DropDataPermission Permission = 7 ReadDataPermission Permission = 8 WriteDataPermission Permission = 9 RebalancePermission Permission = 10 ManageShardPermission Permission = 11 ManageContinuousQueryPermission Permission = 12 ManageQueryPermission Permission = 13 ManageSubscriptionPermission Permission = 14 MonitorPermission Permission = 15 CopyShardPermission Permission = 16 KapacitorAPIPermission Permission = 17 KapacitorConfigAPIPermission Permission = 18 )
func (Permission) MarshalText ¶
func (p Permission) MarshalText() ([]byte, error)
MarshalText converts a Permission into a textual represenation.
func (*Permission) UnmarshalText ¶
func (p *Permission) UnmarshalText(t []byte) error
UnmarshalText sets the permission based on the textual represenation.
type TimeoutError ¶
type TimeoutError struct {
Context error
}
A TimeoutError is returned when an operation on the meta node API was not successful, and repeated attempts to succeed have failed.
TimeoutError makes the last underlying error available in the Context field.
func (TimeoutError) Error ¶
func (e TimeoutError) Error() string