Documentation
¶
Overview ¶
Package meta provides control over meta data for InfluxDB, such as controlling databases, retention policies, users, etc.
Index ¶
- Constants
- Variables
- type Authorizer
- type Client
- func (c *Client) AddShardOwner(shardID uint64, nodeID uint64) error
- func (c *Client) AdminUserExists() bool
- func (c *Client) Authenticate(username, password string) (meta.User, error)
- func (c *Client) Close() error
- func (c *Client) ClusterID() uint64
- func (c *Client) CreateContinuousQuery(database, name, query string) error
- func (c *Client) CreateDataNode(httpAddr, tcpAddr string) (*meta.NodeInfo, error)
- func (c *Client) CreateDatabase(name string) (*meta.DatabaseInfo, error)
- func (c *Client) CreateDatabaseWithRetentionPolicy(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error)
- func (c *Client) CreateRetentionPolicy(database string, spec *meta.RetentionPolicySpec, makeDefault bool) (*meta.RetentionPolicyInfo, error)
- func (c *Client) CreateShardGroup(database, policy string, timestamp time.Time) (*meta.ShardGroupInfo, error)
- func (c *Client) CreateSubscription(database, rp, name, mode string, destinations []string) error
- func (c *Client) CreateUser(name, password string, admin bool) (meta.User, error)
- func (c *Client) Data() Data
- func (c *Client) DataIndex() uint64
- func (c *Client) DataNode(id uint64) (*meta.NodeInfo, error)
- func (c *Client) DataNodeByHTTPHost(httpAddr string) (*meta.NodeInfo, error)
- func (c *Client) DataNodeByTCPHost(tcpAddr string) (*meta.NodeInfo, error)
- func (c *Client) DataNodes() ([]meta.NodeInfo, error)
- func (c *Client) Database(name string) *meta.DatabaseInfo
- func (c *Client) Databases() []meta.DatabaseInfo
- func (c *Client) DeleteDataNode(id uint64) error
- func (c *Client) DeleteShardGroup(database, policy string, id uint64) error
- func (c *Client) DropContinuousQuery(database, name string) error
- func (c *Client) DropDatabase(name string) error
- func (c *Client) DropRetentionPolicy(database, name string) error
- func (c *Client) DropShard(id uint64) error
- func (c *Client) DropSubscription(database, rp, name string) error
- func (c *Client) DropUser(name string) error
- func (c *Client) Load() error
- func (c *Client) MarshalBinary() ([]byte, error)
- func (c *Client) MetaNodeByAddr(addr string) *meta.NodeInfo
- func (c *Client) MetaNodes() ([]meta.NodeInfo, error)
- func (c *Client) Open() error
- func (c *Client) PrecreateShardGroups(from, to time.Time) error
- func (c *Client) Print()
- func (c *Client) PruneShardGroups() error
- func (c *Client) RemoveShardOwner(shardID uint64, nodeID uint64) error
- func (c *Client) ReplaceData(data *Data) error
- func (c *Client) RetentionPolicy(database, name string) (rpi *meta.RetentionPolicyInfo, err error)
- func (c *Client) SetAdminPrivilege(username string, admin bool) error
- func (c *Client) SetData(data *Data) error
- func (c *Client) SetPrivilege(username, database string, p influxql.Privilege) error
- func (c *Client) ShardGroupByTimestamp(database, policy string, timestamp time.Time) *meta.ShardGroupInfo
- func (c *Client) ShardGroupsByTimeRange(database, policy string, min, max time.Time) (a []meta.ShardGroupInfo, err error)
- func (c *Client) ShardIDs() []uint64
- func (c *Client) ShardOwner(shardID uint64) (database, policy string, sgi *meta.ShardGroupInfo)
- func (c *Client) ShardsByTimeRange(sources influxql.Sources, tmin, tmax time.Time) (a []meta.ShardInfo, err error)
- func (c *Client) TruncateShardGroups(t time.Time) error
- func (c *Client) UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error
- func (c *Client) UpdateUser(name, password string) error
- func (c *Client) User(name string) (meta.User, error)
- func (c *Client) UserCount() int
- func (c *Client) UserPrivilege(username, database string) (*influxql.Privilege, error)
- func (c *Client) UserPrivileges(username string) (map[string]influxql.Privilege, error)
- func (c *Client) Users() []meta.UserInfo
- func (c *Client) WaitForDataChanged() chan struct{}
- func (c *Client) WithLogger(log *zap.Logger)
- type Config
- type Data
- func (data *Data) AddShardOwner(id, nodeID uint64)
- func (data *Data) Clone() *Data
- func (data *Data) CloneNodes(src []meta.NodeInfo) []meta.NodeInfo
- func (data *Data) CreateDataNode(host, tcpHost string) error
- func (data *Data) CreateMetaNode(httpAddr, tcpAddr string) error
- func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time) error
- func (data *Data) DataNode(id uint64) *meta.NodeInfo
- func (data *Data) DeleteDataNode(id uint64) error
- func (data *Data) DeleteMetaNode(id uint64) error
- func (data *Data) MarshalBinary() ([]byte, error)
- func (data *Data) MetaNode(id uint64) *meta.NodeInfo
- func (data *Data) RemoveShardOwner(id, nodeID uint64)
- func (data *Data) UnmarshalBinary(buf []byte) error
- type DataJson
Constants ¶
const ( // SaltBytes is the number of bytes used for salts. SaltBytes = 32 // ShardGroupDeletedExpiration is the amount of time before a shard group info will be removed from cached // data after it has been marked deleted (2 weeks). ShardGroupDeletedExpiration = -2 * 7 * 24 * time.Hour )
const ( // DefaultLeaseDuration is the default duration for leases. DefaultLeaseDuration = 60 * time.Second // DefaultLoggingEnabled determines if log messages are printed for the meta service. DefaultLoggingEnabled = true )
Variables ¶
var ( // ErrNodeExists is returned when creating an already existing node. ErrNodeExists = errors.New("node already exists") // ErrNodeNotFound is returned when mutating a node that doesn't exist. ErrNodeNotFound = errors.New("node not found") // ErrNodesRequired is returned when at least one node is required for an operation. // This occurs when creating a shard group. ErrNodesRequired = errors.New("at least one node required") // ErrNodeIDRequired is returned when using a zero node id. ErrNodeIDRequired = errors.New("node id must be greater than 0") // ErrNodeUnableToDropFinalNode is returned if the node being dropped is the last // node in the cluster ErrNodeUnableToDropFinalNode = errors.New("unable to drop the final node in a cluster") )
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer struct { }
func (*Authorizer) AuthorizeDatabase ¶
func (*Authorizer) AuthorizeQuery ¶
func (*Authorizer) AuthorizeWrite ¶
func (a *Authorizer) AuthorizeWrite(username, database string) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to execute commands on and read data from a meta service cluster.
func (*Client) AdminUserExists ¶
AdminUserExists returns true if any user has admin privilege.
func (*Client) Authenticate ¶
Authenticate returns a UserInfo if the username and password match an existing entry.
func (*Client) CreateContinuousQuery ¶
CreateContinuousQuery saves a continuous query with the given name for the given database.
func (*Client) CreateDataNode ¶
CreateDataNode will create a new data node in the metastore
func (*Client) CreateDatabase ¶
func (c *Client) CreateDatabase(name string) (*meta.DatabaseInfo, error)
CreateDatabase creates a database or returns it if it already exists.
func (*Client) CreateDatabaseWithRetentionPolicy ¶
func (c *Client) CreateDatabaseWithRetentionPolicy(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error)
CreateDatabaseWithRetentionPolicy creates a database with the specified retention policy.
When creating a database with a retention policy, the retention policy will always be set to default. Therefore if the caller provides a retention policy that already exists on the database, but that retention policy is not the default one, an error will be returned.
This call is only idempotent when the caller provides the exact same retention policy, and that retention policy is already the default for the database.
func (*Client) CreateRetentionPolicy ¶
func (c *Client) CreateRetentionPolicy(database string, spec *meta.RetentionPolicySpec, makeDefault bool) (*meta.RetentionPolicyInfo, error)
CreateRetentionPolicy creates a retention policy on the specified database.
func (*Client) CreateShardGroup ¶
func (c *Client) CreateShardGroup(database, policy string, timestamp time.Time) (*meta.ShardGroupInfo, error)
CreateShardGroup creates a shard group on a database and policy for a given timestamp.
func (*Client) CreateSubscription ¶
CreateSubscription creates a subscription against the given database and retention policy.
func (*Client) CreateUser ¶
CreateUser adds a user with the given name and password and admin status.
func (*Client) DataNodeByHTTPHost ¶
DataNodeByHTTPHost returns the data node with the give http bind address
func (*Client) DataNodeByTCPHost ¶
DataNodeByTCPHost returns the data node with the give http bind address
func (*Client) Database ¶
func (c *Client) Database(name string) *meta.DatabaseInfo
Database returns info for the requested database.
func (*Client) Databases ¶
func (c *Client) Databases() []meta.DatabaseInfo
Databases returns a list of all database infos.
func (*Client) DeleteDataNode ¶
DeleteDataNode deletes a data node from the cluster.
func (*Client) DeleteShardGroup ¶
DeleteShardGroup removes a shard group from a database and retention policy by id.
func (*Client) DropContinuousQuery ¶
DropContinuousQuery removes the continuous query with the given name on the given database.
func (*Client) DropDatabase ¶
DropDatabase deletes a database.
func (*Client) DropRetentionPolicy ¶
DropRetentionPolicy drops a retention policy from a database.
func (*Client) DropSubscription ¶
DropSubscription removes the named subscription from the given database and retention policy.
func (*Client) MarshalBinary ¶
MarshalBinary returns a binary representation of the underlying data.
func (*Client) MetaNodeByAddr ¶
MetaNodeByAddr returns the meta node's info.
func (*Client) PrecreateShardGroups ¶
PrecreateShardGroups creates shard groups whose endtime is before the 'to' time passed in, but is yet to expire before 'from'. This is to avoid the need for these shards to be created when data for the corresponding time range arrives. Shard creation involves Raft consensus, and precreation avoids taking the hit at write-time.
func (*Client) PruneShardGroups ¶
PruneShardGroups remove deleted shard groups from the data store.
func (*Client) RemoveShardOwner ¶
func (*Client) ReplaceData ¶
func (*Client) RetentionPolicy ¶
func (c *Client) RetentionPolicy(database, name string) (rpi *meta.RetentionPolicyInfo, err error)
RetentionPolicy returns the requested retention policy info.
func (*Client) SetAdminPrivilege ¶
SetAdminPrivilege sets or unsets admin privilege to the given username.
func (*Client) SetPrivilege ¶
SetPrivilege sets a privilege for the given user on the given database.
func (*Client) ShardGroupByTimestamp ¶
func (*Client) ShardGroupsByTimeRange ¶
func (c *Client) ShardGroupsByTimeRange(database, policy string, min, max time.Time) (a []meta.ShardGroupInfo, err error)
ShardGroupsByTimeRange returns a list of all shard groups on a database and policy that may contain data for the specified time range. Shard groups are sorted by start time.
func (*Client) ShardOwner ¶
func (c *Client) ShardOwner(shardID uint64) (database, policy string, sgi *meta.ShardGroupInfo)
ShardOwner returns the owning shard group info for a specific shard.
func (*Client) ShardsByTimeRange ¶
func (c *Client) ShardsByTimeRange(sources influxql.Sources, tmin, tmax time.Time) (a []meta.ShardInfo, err error)
ShardsByTimeRange returns a slice of shards that may contain data in the time range.
func (*Client) TruncateShardGroups ¶
TruncateShardGroups truncates any shard group that could contain timestamps beyond t.
func (*Client) UpdateRetentionPolicy ¶
func (c *Client) UpdateRetentionPolicy(database, name string, rpu *meta.RetentionPolicyUpdate, makeDefault bool) error
UpdateRetentionPolicy updates a retention policy.
func (*Client) UpdateUser ¶
UpdateUser updates the password of an existing user.
func (*Client) UserPrivilege ¶
UserPrivilege returns the privilege for the given user on the given database.
func (*Client) UserPrivileges ¶
UserPrivileges returns the privileges for a user mapped by database name.
func (*Client) WaitForDataChanged ¶
func (c *Client) WaitForDataChanged() chan struct{}
WaitForDataChanged returns a channel that will get closed when the metastore data has changed.
func (*Client) WithLogger ¶
WithLogger sets the logger for the client.
type Config ¶
type Config struct { Dir string `toml:"dir"` RetentionAutoCreate bool `toml:"retention-autocreate"` LoggingEnabled bool `toml:"logging-enabled"` }
Config represents the meta configuration.
func (*Config) Diagnostics ¶
func (c *Config) Diagnostics() (*diagnostics.Diagnostics, error)
Diagnostics returns a diagnostics representation of a subset of the Config.
type Data ¶
Data represents the top level collection of all metadata.
func (*Data) AddShardOwner ¶
func (*Data) CreateDataNode ¶
CreateDataNode adds a node to the metadata.
func (*Data) CreateMetaNode ¶
CreateMetaNode will add a new meta node to the metastore
func (*Data) CreateShardGroup ¶
CreateShardGroup creates a shard group on a database and policy for a given timestamp.
func (*Data) DeleteDataNode ¶
DeleteDataNode removes a node from the Meta store.
If necessary, DeleteDataNode reassigns ownership of any shards that would otherwise become orphaned by the removal of the node from the cluster.
func (*Data) DeleteMetaNode ¶
DeleteMetaNode will remove the meta node from the store
func (*Data) MarshalBinary ¶
MarshalBinary encodes the metadata to a binary format.
func (*Data) RemoveShardOwner ¶
func (*Data) UnmarshalBinary ¶
UnmarshalBinary decodes the object from a binary format.