Documentation ¶
Index ¶
- Constants
- Variables
- type AuthError
- type Config
- type ContinuousQueryInfo
- type Data
- func (data *Data) Clone() *Data
- func (data *Data) CreateContinuousQuery(database, name, query string) error
- func (data *Data) CreateDatabase(name string) error
- func (data *Data) CreateNode(host string) error
- func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) error
- func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time) error
- func (data *Data) CreateUser(name, hash string, admin bool) error
- func (data *Data) Database(name string) *DatabaseInfo
- func (data *Data) DeleteNode(id uint64) error
- func (data *Data) DeleteShardGroup(database, policy string, id uint64) error
- func (data *Data) DropContinuousQuery(database, name string) error
- func (data *Data) DropDatabase(name string) error
- func (data *Data) DropRetentionPolicy(database, name string) error
- func (data *Data) DropUser(name string) error
- func (data *Data) Node(id uint64) *NodeInfo
- func (data *Data) NodeByHost(host string) *NodeInfo
- func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)
- func (data *Data) SetDefaultRetentionPolicy(database, name string) error
- func (data *Data) SetPrivilege(name, database string, p influxql.Privilege) error
- func (data *Data) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (data *Data) ShardGroups(database, policy string) ([]ShardGroupInfo, error)
- func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
- func (data *Data) UpdateUser(name, hash string) error
- func (data *Data) User(username string) *UserInfo
- type DatabaseInfo
- type NodeInfo
- type RetentionPolicyInfo
- type RetentionPolicyUpdate
- type ShardGroupInfo
- type ShardGroupPrecreator
- type ShardInfo
- type StatementExecutor
- type Store
- func (s *Store) AdminUserExists() (exists bool, err error)
- func (s *Store) Authenticate(username, password string) (ui *UserInfo, err error)
- func (s *Store) Close() error
- func (s *Store) CreateContinuousQuery(database, name, query string) error
- func (s *Store) CreateDatabase(name string) (*DatabaseInfo, error)
- func (s *Store) CreateDatabaseIfNotExists(name string) (*DatabaseInfo, error)
- func (s *Store) CreateNode(host string) (*NodeInfo, error)
- func (s *Store) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
- func (s *Store) CreateRetentionPolicyIfNotExists(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
- func (s *Store) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (s *Store) CreateShardGroupIfNotExists(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (s *Store) CreateUser(name, password string, admin bool) (*UserInfo, error)
- func (s *Store) Database(name string) (di *DatabaseInfo, err error)
- func (s *Store) Databases() (dis []DatabaseInfo, err error)
- func (s *Store) DefaultRetentionPolicy(database string) (rpi *RetentionPolicyInfo, err error)
- func (s *Store) DeleteNode(id uint64) error
- func (s *Store) DeleteShardGroup(database, policy string, id uint64) error
- func (s *Store) DropContinuousQuery(database, name string) error
- func (s *Store) DropDatabase(name string) error
- func (s *Store) DropRetentionPolicy(database, name string) error
- func (s *Store) DropUser(name string) error
- func (s *Store) Err() <-chan error
- func (s *Store) IDPath() string
- func (s *Store) IsLeader() bool
- func (s *Store) LeaderCh() <-chan bool
- func (s *Store) Node(id uint64) (ni *NodeInfo, err error)
- func (s *Store) NodeByHost(host string) (ni *NodeInfo, err error)
- func (s *Store) NodeID() uint64
- func (s *Store) Nodes() (a []NodeInfo, err error)
- func (s *Store) Open() error
- func (s *Store) Path() string
- func (s *Store) Ready() <-chan struct{}
- func (s *Store) RetentionPolicies(database string) (a []RetentionPolicyInfo, err error)
- func (s *Store) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error)
- func (s *Store) SetDefaultRetentionPolicy(database, name string) error
- func (s *Store) SetPeers(addrs []string) error
- func (s *Store) SetPrivilege(username, database string, p influxql.Privilege) error
- func (s *Store) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (sgi *ShardGroupInfo, err error)
- func (s *Store) ShardGroups(database, policy string) (a []ShardGroupInfo, err error)
- func (s *Store) ShardOwner(shardID uint64) (database, policy string, sgi *ShardGroupInfo)
- func (s *Store) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
- func (s *Store) UpdateUser(name, password string) error
- func (s *Store) User(name string) (ui *UserInfo, err error)
- func (s *Store) UserCount() (count int, err error)
- func (s *Store) Users() (a []UserInfo, err error)
- func (s *Store) VisitRetentionPolicies(f func(d DatabaseInfo, r RetentionPolicyInfo))
- type UserInfo
Constants ¶
const ( // DefaultHostname is the default hostname if one is not provided. DefaultHostname = "localhost" // DefaultBindAddress is the default address to bind to. DefaultBindAddress = ":8088" // DefaultHeartbeatTimeout is the default heartbeat timeout for the store. DefaultHeartbeatTimeout = 1000 * time.Millisecond // DefaultElectionTimeout is the default election timeout for the store. DefaultElectionTimeout = 1000 * time.Millisecond // DefaultLeaderLeaseTimeout is the default leader lease for the store. DefaultLeaderLeaseTimeout = 500 * time.Millisecond // DefaultCommitTimeout is the default commit timeout for the store. DefaultCommitTimeout = 50 * time.Millisecond )
const ( // DefaultRetentionPolicyReplicaN is the default value of RetentionPolicyInfo.ReplicaN. DefaultRetentionPolicyReplicaN = 1 // DefaultRetentionPolicyDuration is the default value of RetentionPolicyInfo.Duration. DefaultRetentionPolicyDuration = 7 * (24 * time.Hour) // MinRetentionPolicyDuration represents the minimum duration for a policy. MinRetentionPolicyDuration = time.Hour )
const ( MuxRaftHeader = 0 MuxExecHeader = 1 )
tcp.Mux header bytes.
const ( AutoCreateRetentionPolicyName = "default" AutoCreateRetentionPolicyReplicaN = 1 )
Retention policy auto-create settings.
const ExecMagic = "EXEC"
ExecMagic is the first 4 bytes sent to a remote exec connection to verify that it is coming from a remote exec client connection.
Variables ¶
var ( // ErrStoreOpen is returned when opening an already open store. ErrStoreOpen = errors.New("store already open") // ErrStoreClosed is returned when closing an already closed store. ErrStoreClosed = errors.New("raft store already closed") )
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") )
var ( // ErrDatabaseExists is returned when creating an already existing database. ErrDatabaseExists = errors.New("database already exists") // ErrDatabaseNotFound is returned when mutating a database that doesn't exist. ErrDatabaseNotFound = errors.New("database not found") // ErrDatabaseNameRequired is returned when creating a database without a name. ErrDatabaseNameRequired = errors.New("database name required") )
var ( // ErrRetentionPolicyExists is returned when creating an already existing policy. ErrRetentionPolicyExists = errors.New("retention policy already exists") // ErrRetentionPolicyNotFound is returned when mutating a policy that doesn't exist. ErrRetentionPolicyNotFound = errors.New("retention policy not found") // ErrRetentionPolicyNameRequired is returned when creating a policy without a name. ErrRetentionPolicyNameRequired = errors.New("retention policy name required") // ErrRetentionPolicyNameExists is returned when renaming a policy to // the same name as another existing policy. ErrRetentionPolicyNameExists = errors.New("retention policy name already exists") // ErrRetentionPolicyDurationTooLow is returned when updating a retention // policy that has a duration lower than the allowed minimum. ErrRetentionPolicyDurationTooLow = errors.New("retention policy duration too low") )
var ( // ErrShardGroupExists is returned when creating an already existing shard group. ErrShardGroupExists = errors.New("shard group already exists") // ErrShardGroupNotFound is returned when mutating a shard group that doesn't exist. ErrShardGroupNotFound = errors.New("shard group not found") )
var ( // ErrContinuousQueryExists is returned when creating an already existing continuous query. ErrContinuousQueryExists = errors.New("continuous query already exists") // ErrContinuousQueryNotFound is returned when removing a continuous query that doesn't exist. ErrContinuousQueryNotFound = errors.New("continuous query not found") )
var ( // ErrUserExists is returned when creating an already existing user. ErrUserExists = errors.New("user already exists") // ErrUserNotFound is returned when mutating a user that doesn't exist. ErrUserNotFound = errors.New("user not found") // ErrUsernameRequired is returned when creating a user without a username. ErrUsernameRequired = errors.New("username required") )
var BcryptCost = 10
BcryptCost is the cost associated with generating password with Bcrypt. This setting is lowered during testing to improve test suite performance.
var HashPassword = func(password string) ([]byte, error) { return bcrypt.GenerateFromPassword([]byte(password), BcryptCost) }
HashPassword generates a cryptographically secure hash for password. Returns an error if the password is invalid or a hash cannot be generated.
Functions ¶
This section is empty.
Types ¶
type AuthError ¶
type AuthError struct {
// contains filtered or unexported fields
}
AuthError represents an authorization error.
func NewAuthError ¶
NewAuthError returns a new instance of AuthError.
type Config ¶
type Config struct { Dir string `toml:"dir"` Hostname string `toml:"hostname"` BindAddress string `toml:"bind-address"` Peers []string `toml:"peers"` RetentionAutoCreate bool `toml:"retention-autocreate"` ElectionTimeout toml.Duration `toml:"election-timeout"` HeartbeatTimeout toml.Duration `toml:"heartbeat-timeout"` LeaderLeaseTimeout toml.Duration `toml:"leader-lease-timeout"` CommitTimeout toml.Duration `toml:"commit-timeout"` }
Config represents the meta configuration.
type ContinuousQueryInfo ¶
ContinuousQueryInfo represents metadata about a continuous query.
type Data ¶
type Data struct { Term uint64 // associated raft term Index uint64 // associated raft index Nodes []NodeInfo Databases []DatabaseInfo Users []UserInfo MaxNodeID uint64 MaxShardGroupID uint64 MaxShardID uint64 }
Data represents the top level collection of all metadata.
func (*Data) CreateContinuousQuery ¶
CreateContinuousQuery adds a named continuous query to a database.
func (*Data) CreateDatabase ¶
CreateDatabase creates a new database. Returns an error if name is blank or if a database with the same name already exists.
func (*Data) CreateNode ¶
CreateNode adds a node to the metadata.
func (*Data) CreateRetentionPolicy ¶
func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) error
CreateRetentionPolicy creates a new retention policy on a database. Returns an error if name is blank or if a database does not exist.
func (*Data) CreateShardGroup ¶
CreateShardGroup creates a shard group on a database and policy for a given timestamp.
func (*Data) CreateUser ¶
CreateUser creates a new user.
func (*Data) Database ¶
func (data *Data) Database(name string) *DatabaseInfo
Database returns a database by name.
func (*Data) DeleteNode ¶
DeleteNode removes a node from the metadata.
func (*Data) DeleteShardGroup ¶
DeleteShardGroup removes a shard group from a database and retention policy by id.
func (*Data) DropContinuousQuery ¶
DropContinuousQuery removes a continuous query.
func (*Data) DropDatabase ¶
DropDatabase removes a database by name.
func (*Data) DropRetentionPolicy ¶
DropRetentionPolicy removes a retention policy from a database by name.
func (*Data) NodeByHost ¶
NodeByHost returns a node by hostname.
func (*Data) RetentionPolicy ¶
func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)
RetentionPolicy returns a retention policy for a database by name.
func (*Data) SetDefaultRetentionPolicy ¶
SetDefaultRetentionPolicy sets the default retention policy for a database.
func (*Data) SetPrivilege ¶
SetPrivilege sets a privilege for a user on a database.
func (*Data) ShardGroupByTimestamp ¶
func (data *Data) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
ShardGroupByTimestamp returns the shard group on a database and policy for a given timestamp.
func (*Data) ShardGroups ¶
func (data *Data) ShardGroups(database, policy string) ([]ShardGroupInfo, error)
ShardGroup returns a list of all shard groups on a database and policy.
func (*Data) UpdateRetentionPolicy ¶
func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
UpdateRetentionPolicy updates an existing retention policy.
func (*Data) UpdateUser ¶
UpdateUser updates the password hash of an existing user.
type DatabaseInfo ¶
type DatabaseInfo struct { Name string DefaultRetentionPolicy string RetentionPolicies []RetentionPolicyInfo ContinuousQueries []ContinuousQueryInfo }
DatabaseInfo represents information about a database in the system.
func (DatabaseInfo) RetentionPolicy ¶
func (di DatabaseInfo) RetentionPolicy(name string) *RetentionPolicyInfo
RetentionPolicy returns a retention policy by name.
type NodeInfo ¶
NodeInfo represents information about a single node in the cluster.
func (*NodeInfo) MarshalBinary ¶
MarshalBinary encodes the object to a binary format.
func (*NodeInfo) UnmarshalBinary ¶
MarshalBinary decodes the object from a binary format.
type RetentionPolicyInfo ¶
type RetentionPolicyInfo struct { Name string ReplicaN int Duration time.Duration ShardGroupDuration time.Duration ShardGroups []ShardGroupInfo }
RetentionPolicyInfo represents metadata about a retention policy.
func NewRetentionPolicyInfo ¶
func NewRetentionPolicyInfo(name string) *RetentionPolicyInfo
NewRetentionPolicyInfo returns a new instance of RetentionPolicyInfo with defaults set.
func (*RetentionPolicyInfo) DeletedShardGroups ¶
func (rpi *RetentionPolicyInfo) DeletedShardGroups() []*ShardGroupInfo
DeletedShardGroups returns the Shard Groups which are marked as deleted.
func (*RetentionPolicyInfo) ExpiredShardGroups ¶
func (rpi *RetentionPolicyInfo) ExpiredShardGroups(t time.Time) []*ShardGroupInfo
ExpiredShardGroups returns the Shard Groups which are considered expired, for the given time.
func (*RetentionPolicyInfo) ShardGroupByTimestamp ¶
func (rpi *RetentionPolicyInfo) ShardGroupByTimestamp(timestamp time.Time) *ShardGroupInfo
ShardGroupByTimestamp returns the shard group in the policy that contains the timestamp.
type RetentionPolicyUpdate ¶
RetentionPolicyUpdate represents retention policy fields to be updated.
func (*RetentionPolicyUpdate) SetDuration ¶
func (rpu *RetentionPolicyUpdate) SetDuration(v time.Duration)
func (*RetentionPolicyUpdate) SetName ¶
func (rpu *RetentionPolicyUpdate) SetName(v string)
func (*RetentionPolicyUpdate) SetReplicaN ¶
func (rpu *RetentionPolicyUpdate) SetReplicaN(v int)
type ShardGroupInfo ¶
type ShardGroupInfo struct { ID uint64 StartTime time.Time EndTime time.Time Shards []ShardInfo DeletedAt time.Time }
ShardGroupInfo represents metadata about a shard group. The DeletedAt field is important because it makes it clear that a ShardGroup has been marked as deleted, and allow the system to be sure that a ShardGroup is not simply missing. If the DeletedAt is set, the system can safely delete any associated shards.
func (*ShardGroupInfo) Contains ¶
func (sgi *ShardGroupInfo) Contains(timestamp time.Time) bool
Contains return true if the shard group contains data for the timestamp.
func (*ShardGroupInfo) Deleted ¶
func (sgi *ShardGroupInfo) Deleted() bool
Deleted returns whether this ShardGroup has been deleted.
func (*ShardGroupInfo) Overlaps ¶
func (sgi *ShardGroupInfo) Overlaps(min, max time.Time) bool
Overlaps return whether the shard group contains data for the time range between min and max
func (*ShardGroupInfo) ShardFor ¶
func (s *ShardGroupInfo) ShardFor(hash uint64) ShardInfo
ShardFor returns the ShardInfo for a Point hash
type ShardGroupPrecreator ¶
type ShardGroupPrecreator struct{}
type StatementExecutor ¶
type StatementExecutor struct { Store interface { Nodes() ([]NodeInfo, error) Database(name string) (*DatabaseInfo, error) Databases() ([]DatabaseInfo, error) CreateDatabase(name string) (*DatabaseInfo, error) DropDatabase(name string) error DefaultRetentionPolicy(database string) (*RetentionPolicyInfo, error) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error SetDefaultRetentionPolicy(database, name string) error DropRetentionPolicy(database, name string) error Users() ([]UserInfo, error) CreateUser(name, password string, admin bool) (*UserInfo, error) UpdateUser(name, password string) error DropUser(name string) error SetPrivilege(username, database string, p influxql.Privilege) error CreateContinuousQuery(database, name, query string) error DropContinuousQuery(database, name string) error } }
StatementExecutor translates InfluxQL queries to meta store methods.
func (*StatementExecutor) ExecuteStatement ¶
func (e *StatementExecutor) ExecuteStatement(stmt influxql.Statement) *influxql.Result
ExecuteStatement executes stmt against the meta store as user.
type Store ¶
type Store struct { // The listeners to accept raft and remote exec connections from. RaftListener net.Listener ExecListener net.Listener // The advertised hostname of the store. Addr net.Addr // The amount of time before a follower starts a new election. HeartbeatTimeout time.Duration // The amount of time before a candidate starts a new election. ElectionTimeout time.Duration // The amount of time without communication to the cluster before a // leader steps down to a follower state. LeaderLeaseTimeout time.Duration // The amount of time without an apply before sending a heartbeat. CommitTimeout time.Duration Logger *log.Logger // contains filtered or unexported fields }
Store represents a raft-backed metastore.
func (*Store) AdminUserExists ¶
AdminUserExists returns true if an admin user exists on the system.
func (*Store) Authenticate ¶
Authenticate retrieves a user with a matching username and password.
func (*Store) CreateContinuousQuery ¶
CreateContinuousQuery creates a new continuous query on the store.
func (*Store) CreateDatabase ¶
func (s *Store) CreateDatabase(name string) (*DatabaseInfo, error)
CreateDatabase creates a new database in the store.
func (*Store) CreateDatabaseIfNotExists ¶
func (s *Store) CreateDatabaseIfNotExists(name string) (*DatabaseInfo, error)
CreateDatabaseIfNotExists creates a new database in the store if it doesn't already exist.
func (*Store) CreateNode ¶
CreateNode creates a new node in the store.
func (*Store) CreateRetentionPolicy ¶
func (s *Store) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
CreateRetentionPolicy creates a new retention policy for a database.
func (*Store) CreateRetentionPolicyIfNotExists ¶
func (s *Store) CreateRetentionPolicyIfNotExists(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error)
CreateRetentionPolicyIfNotExists creates a new policy in the store if it doesn't already exist.
func (*Store) CreateShardGroup ¶
func (s *Store) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
CreateShardGroup creates a new shard group in a retention policy for a given time.
func (*Store) CreateShardGroupIfNotExists ¶
func (s *Store) CreateShardGroupIfNotExists(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
CreateShardGroupIfNotExists creates a new shard group if one doesn't already exist.
func (*Store) CreateUser ¶
CreateUser creates a new user in the store.
func (*Store) Database ¶
func (s *Store) Database(name string) (di *DatabaseInfo, err error)
Database returns a database by name.
func (*Store) Databases ¶
func (s *Store) Databases() (dis []DatabaseInfo, err error)
Databases returns a list of all databases.
func (*Store) DefaultRetentionPolicy ¶
func (s *Store) DefaultRetentionPolicy(database string) (rpi *RetentionPolicyInfo, err error)
DefaultRetentionPolicy returns the default retention policy for a database.
func (*Store) DeleteNode ¶
DeleteNode removes a node from the metastore by id.
func (*Store) DeleteShardGroup ¶
DeleteShardGroup removes an existing shard group from a policy by ID.
func (*Store) DropContinuousQuery ¶
DropContinuousQuery removes a continuous query from the store.
func (*Store) DropDatabase ¶
DropDatabase removes a database from the metastore by name.
func (*Store) DropRetentionPolicy ¶
DropRetentionPolicy removes a policy from a database by name.
func (*Store) LeaderCh ¶
LeaderCh returns a channel that notifies on leadership change. Panics when the store has not been opened yet.
func (*Store) NodeByHost ¶
NodeByHost returns a node by hostname.
func (*Store) NodeID ¶
NodeID returns the identifier for the local node. Panics if the node has not joined the cluster.
func (*Store) Path ¶
Path returns the root path when open. Returns an empty string when the store is closed.
func (*Store) Ready ¶
func (s *Store) Ready() <-chan struct{}
Ready returns a channel that is closed once the store is initialized.
func (*Store) RetentionPolicies ¶
func (s *Store) RetentionPolicies(database string) (a []RetentionPolicyInfo, err error)
RetentionPolicies returns a list of all retention policies for a database.
func (*Store) RetentionPolicy ¶
func (s *Store) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error)
RetentionPolicy returns a retention policy for a database by name.
func (*Store) SetDefaultRetentionPolicy ¶
SetDefaultRetentionPolicy sets the default retention policy for a database.
func (*Store) SetPrivilege ¶
SetPrivilege sets a privilege for a user on a database.
func (*Store) ShardGroupByTimestamp ¶
func (s *Store) ShardGroupByTimestamp(database, policy string, timestamp time.Time) (sgi *ShardGroupInfo, err error)
ShardGroupByTimestamp returns a shard group for a policy by timestamp.
func (*Store) ShardGroups ¶
func (s *Store) ShardGroups(database, policy string) (a []ShardGroupInfo, err error)
ShardGroups returns a list of all shard groups for a policy by timestamp.
func (*Store) ShardOwner ¶
func (s *Store) ShardOwner(shardID uint64) (database, policy string, sgi *ShardGroupInfo)
func (*Store) UpdateRetentionPolicy ¶
func (s *Store) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate) error
UpdateRetentionPolicy updates an existing retention policy.
func (*Store) UpdateUser ¶
UpdateUser updates an existing user in the store.
func (*Store) VisitRetentionPolicies ¶
func (s *Store) VisitRetentionPolicies(f func(d DatabaseInfo, r RetentionPolicyInfo))
VisitRetentionPolicies calls the given function with full retention policy details.