Documentation ¶
Overview ¶
Package meta provides control over meta data for InfluxDB, such as controlling databases, retention policies, users, etc.
Index ¶
- Constants
- Variables
- func ErrInvalidSubscriptionURL(url string) error
- func MarshalTime(t time.Time) int64
- func NewShardOwner(s ShardInfo, ownerFreqs map[int]int) (uint64, error)
- func UnmarshalTime(v int64) time.Time
- func ValidName(name string) bool
- type Client
- func (c *Client) AcquireLease(name string) (*Lease, error)
- func (c *Client) AdminUserExists() bool
- func (c *Client) Authenticate(username, password string) (*UserInfo, error)
- func (c *Client) Close() error
- func (c *Client) ClusterID() uint64
- func (c *Client) CreateContinuousQuery(database, name, query string) error
- func (c *Client) CreateDatabase(name string) (*DatabaseInfo, error)
- func (c *Client) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionPolicySpec) (*DatabaseInfo, error)
- func (c *Client) CreateRetentionPolicy(database string, spec *RetentionPolicySpec, makeDefault bool) (*RetentionPolicyInfo, error)
- func (c *Client) CreateShardGroup(database, policy string, timestamp time.Time) (*ShardGroupInfo, error)
- func (c *Client) CreateSubscription(database, rp, name, mode string, destinations []string) error
- func (c *Client) CreateUser(name, password string, admin bool) (*UserInfo, error)
- func (c *Client) Data() Data
- func (c *Client) Database(name string) *DatabaseInfo
- func (c *Client) Databases() []DatabaseInfo
- 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) Open() error
- func (c *Client) PrecreateShardGroups(from, to time.Time) error
- func (c *Client) PruneShardGroups() error
- func (c *Client) RetentionPolicy(database, name string) (rpi *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) ShardGroupsByTimeRange(database, policy string, min, max time.Time) (a []ShardGroupInfo, err error)
- func (c *Client) ShardIDs() []uint64
- func (c *Client) ShardOwner(shardID uint64) (database, policy string, sgi *ShardGroupInfo)
- func (c *Client) ShardsByTimeRange(sources influxql.Sources, tmin, tmax time.Time) (a []ShardInfo, err error)
- func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
- func (c *Client) UpdateUser(name, password string) error
- func (c *Client) User(name string) (*UserInfo, 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() []UserInfo
- func (c *Client) WaitForDataChanged() chan struct{}
- func (c *Client) WithLogger(log zap.Logger)
- type Config
- type ContinuousQueryInfo
- type Data
- func (data *Data) Clone() *Data
- func (data *Data) CloneDatabases() []DatabaseInfo
- func (data *Data) CloneUsers() []UserInfo
- func (data *Data) CreateContinuousQuery(database, name, query string) error
- func (data *Data) CreateDatabase(name string) error
- func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo, makeDefault bool) error
- func (data *Data) CreateShardGroup(database, policy string, timestamp time.Time) error
- func (data *Data) CreateSubscription(database, rp, name, mode string, destinations []string) error
- func (data *Data) CreateUser(name, hash string, admin bool) error
- func (data *Data) Database(name string) *DatabaseInfo
- 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) DropShard(id uint64)
- func (data *Data) DropSubscription(database, rp, name string) error
- func (data *Data) DropUser(name string) error
- func (data *Data) MarshalBinary() ([]byte, error)
- func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)
- func (data *Data) SetAdminPrivilege(name string, admin bool) 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) ShardGroupsByTimeRange(database, policy string, tmin, tmax time.Time) ([]ShardGroupInfo, error)
- func (data *Data) UnmarshalBinary(buf []byte) error
- func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
- func (data *Data) UpdateUser(name, hash string) error
- func (data *Data) User(username string) *UserInfo
- func (data *Data) UserPrivilege(name, database string) (*influxql.Privilege, error)
- func (data *Data) UserPrivileges(name string) (map[string]influxql.Privilege, error)
- type DatabaseInfo
- type ErrAuthorize
- type Lease
- type Leases
- type NodeInfo
- type NodeInfos
- type QueryAuthorizer
- type RetentionPolicyInfo
- func (rpi *RetentionPolicyInfo) Apply(spec *RetentionPolicySpec) *RetentionPolicyInfo
- func (rpi *RetentionPolicyInfo) DeletedShardGroups() []*ShardGroupInfo
- func (rpi *RetentionPolicyInfo) ExpiredShardGroups(t time.Time) []*ShardGroupInfo
- func (rpi *RetentionPolicyInfo) MarshalBinary() ([]byte, error)
- func (rpi *RetentionPolicyInfo) ShardGroupByTimestamp(timestamp time.Time) *ShardGroupInfo
- func (rpi *RetentionPolicyInfo) UnmarshalBinary(data []byte) error
- type RetentionPolicySpec
- type RetentionPolicyUpdate
- type ShardGroupInfo
- type ShardGroupInfos
- type ShardInfo
- type ShardOwner
- type SubscriptionInfo
- type UserInfo
- type WriteAuthorizer
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 )
const ( // DefaultRetentionPolicyReplicaN is the default value of RetentionPolicyInfo.ReplicaN. DefaultRetentionPolicyReplicaN = 1 // DefaultRetentionPolicyDuration is the default value of RetentionPolicyInfo.Duration. DefaultRetentionPolicyDuration = time.Duration(0) // DefaultRetentionPolicyName is the default name for auto generated retention policies. DefaultRetentionPolicyName = "autogen" // MinRetentionPolicyDuration represents the minimum duration for a policy. MinRetentionPolicyDuration = time.Hour )
Variables ¶
var ( errors.New("meta service unavailable") // ErrService is returned when the meta service returns an error. ErrService = errors.New("meta service error") )ErrServiceUnavailable =
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 ( // ErrDatabaseExists is returned when creating an already existing database. ErrDatabaseExists = errors.New("database already exists") // ErrDatabaseNotExists is returned when operating on a not existing database. ErrDatabaseNotExists = errors.New("database does not exist") // ErrDatabaseNameRequired is returned when creating a database without a name. ErrDatabaseNameRequired = errors.New("database name required") // ErrInvalidName is returned when attempting to create a database or retention policy with an invalid name ErrInvalidName = errors.New("invalid name") )
var ( // ErrRetentionPolicyExists is returned when creating an already existing policy. ErrRetentionPolicyExists = errors.New("retention policy already exists") // ErrRetentionPolicyNotFound is returned when an expected policy wasn't found. ErrRetentionPolicyNotFound = errors.New("retention policy not found") // ErrRetentionPolicyDefault is returned when attempting a prohibited operation // on a default retention policy. ErrRetentionPolicyDefault = errors.New("retention policy is default") // ErrRetentionPolicyRequired is returned when a retention policy is required // by an operation, but a nil policy was passed. ErrRetentionPolicyRequired = errors.New("retention policy required") // 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 = fmt.Errorf("retention policy duration must be at least %s", MinRetentionPolicyDuration) // ErrRetentionPolicyConflict is returned when creating a retention policy conflicts // with an existing policy. ErrRetentionPolicyConflict = errors.New("retention policy conflicts with an existing policy") // ErrIncompatibleDurations is returned when creating or updating a // retention policy that has a duration lower than the current shard // duration. ErrIncompatibleDurations = errors.New("retention policy duration must be greater than the shard duration") // ErrReplicationFactorTooLow is returned when the replication factor is not in an // acceptable range. ErrReplicationFactorTooLow = errors.New("replication factor must be greater than 0") )
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") // ErrShardNotReplicated is returned if the node requested to be dropped has // the last copy of a shard present and the force keyword was not used ErrShardNotReplicated = errors.New("shard not replicated") )
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 ( // ErrSubscriptionExists is returned when creating an already existing subscription. ErrSubscriptionExists = errors.New("subscription already exists") // ErrSubscriptionNotFound is returned when removing a subscription that doesn't exist. ErrSubscriptionNotFound = errors.New("subscription 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") // ErrAuthenticate is returned when authentication fails. ErrAuthenticate = errors.New("authentication failed") )
Functions ¶
func ErrInvalidSubscriptionURL ¶ added in v1.2.1
ErrInvalidSubscriptionURL is returned when the subscription's destination URL is invalid.
func MarshalTime ¶
MarshalTime converts t to nanoseconds since epoch. A zero time returns 0.
func NewShardOwner ¶ added in v0.12.0
NewShardOwner sets the owner of the provided shard to the data node that currently owns the fewest number of shards. If multiple nodes own the same (fewest) number of shards, then one of those nodes becomes the new shard owner.
func UnmarshalTime ¶
UnmarshalTime converts nanoseconds since epoch to time. A zero value returns a zero time.
Types ¶
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) AcquireLease ¶
AcquireLease attempts to acquire the specified lease. TODO corylanou remove this for single node
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) CreateDatabase ¶
func (c *Client) CreateDatabase(name string) (*DatabaseInfo, error)
CreateDatabase creates a database or returns it if it already exists.
func (*Client) CreateDatabaseWithRetentionPolicy ¶
func (c *Client) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionPolicySpec) (*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 *RetentionPolicySpec, makeDefault bool) (*RetentionPolicyInfo, error)
CreateRetentionPolicy creates a retention policy on the specified database.
func (*Client) CreateShardGroup ¶
func (c *Client) CreateShardGroup(database, policy string, timestamp time.Time) (*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) Data ¶ added in v0.12.2
Data returns a clone of the underlying data in the meta store.
func (*Client) Database ¶
func (c *Client) Database(name string) *DatabaseInfo
Database returns info for the requested database.
func (*Client) Databases ¶
func (c *Client) Databases() []DatabaseInfo
Databases returns a list of all database infos.
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) 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 ¶ added in v1.2.1
PruneShardGroups remove deleted shard groups from the data store.
func (*Client) RetentionPolicy ¶
func (c *Client) RetentionPolicy(database, name string) (rpi *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) ShardGroupsByTimeRange ¶
func (c *Client) ShardGroupsByTimeRange(database, policy string, min, max time.Time) (a []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 *ShardGroupInfo)
ShardOwner returns the owning shard group info for a specific shard.
func (*Client) ShardsByTimeRange ¶ added in v0.11.0
func (c *Client) ShardsByTimeRange(sources influxql.Sources, tmin, tmax time.Time) (a []ShardInfo, err error)
ShardsByTimeRange returns a slice of shards that may contain data in the time range.
func (*Client) UpdateRetentionPolicy ¶
func (c *Client) UpdateRetentionPolicy(database, name string, rpu *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 ¶ added in v1.2.1
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.
type ContinuousQueryInfo ¶
ContinuousQueryInfo represents metadata about a continuous query.
type Data ¶
type Data struct { Term uint64 // associated raft term Index uint64 // associated raft index ClusterID uint64 Databases []DatabaseInfo Users []UserInfo MaxShardGroupID uint64 MaxShardID uint64 }
Data represents the top level collection of all metadata.
func (*Data) CloneDatabases ¶
func (data *Data) CloneDatabases() []DatabaseInfo
CloneDatabases returns a copy of the DatabaseInfo.
func (*Data) CloneUsers ¶ added in v0.12.0
CloneUsers returns a copy of the user infos.
func (*Data) CreateContinuousQuery ¶
CreateContinuousQuery adds a named continuous query to a database.
func (*Data) CreateDatabase ¶
CreateDatabase creates a new database. It returns an error if name is blank or if a database with the same name already exists.
func (*Data) CreateRetentionPolicy ¶
func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo, makeDefault bool) error
CreateRetentionPolicy creates a new retention policy on a database. It returns an error if name is blank or if the database does not exist.
func (*Data) CreateShardGroup ¶
CreateShardGroup creates a shard group on a database and policy for a given timestamp.
func (*Data) CreateSubscription ¶
CreateSubscription adds a named subscription to a database and retention policy.
func (*Data) CreateUser ¶
CreateUser creates a new user.
func (*Data) Database ¶
func (data *Data) Database(name string) *DatabaseInfo
Database returns a DatabaseInfo by the database name.
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. It does not return an error if the database cannot be found.
func (*Data) DropRetentionPolicy ¶
DropRetentionPolicy removes a retention policy from a database by name.
func (*Data) DropShard ¶ added in v0.12.0
DropShard removes a shard by ID.
DropShard won't return an error if the shard can't be found, which allows the command to be re-run in the case that the meta store succeeds but a data node fails.
func (*Data) DropSubscription ¶
DropSubscription removes a subscription.
func (*Data) MarshalBinary ¶
MarshalBinary encodes the metadata to a binary format.
func (*Data) RetentionPolicy ¶
func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)
RetentionPolicy returns a retention policy for a database by name.
func (*Data) SetAdminPrivilege ¶
SetAdminPrivilege sets the admin privilege for a user.
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)
ShardGroups returns a list of all shard groups on a database and retention policy.
func (*Data) ShardGroupsByTimeRange ¶
func (data *Data) ShardGroupsByTimeRange(database, policy string, tmin, tmax time.Time) ([]ShardGroupInfo, 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 (*Data) UnmarshalBinary ¶
UnmarshalBinary decodes the object from a binary format.
func (*Data) UpdateRetentionPolicy ¶
func (data *Data) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
UpdateRetentionPolicy updates an existing retention policy.
func (*Data) UpdateUser ¶
UpdateUser updates the password hash of an existing user.
func (*Data) UserPrivilege ¶
UserPrivilege gets the privilege for a user on a database.
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.
func (DatabaseInfo) ShardInfos ¶
func (di DatabaseInfo) ShardInfos() []ShardInfo
ShardInfos returns a list of all shards' info for the database.
type ErrAuthorize ¶ added in v0.11.0
ErrAuthorize represents an authorization error.
func (ErrAuthorize) Error ¶ added in v0.11.0
func (e ErrAuthorize) Error() string
Error returns the text of the error.
type Lease ¶
type Lease struct { Name string `json:"name"` Expiration time.Time `json:"expiration"` Owner uint64 `json:"owner"` }
Lease represents a lease held on a resource.
type Leases ¶
type Leases struct {
// contains filtered or unexported fields
}
Leases is a concurrency-safe collection of leases keyed by name.
func (*Leases) Acquire ¶
Acquire acquires a lease with the given name for the given nodeID. If the lease doesn't exist or exists but is expired, a valid lease is returned. If nodeID already owns the named and unexpired lease, the lease expiration is extended. If a different node owns the lease, an error is returned.
type QueryAuthorizer ¶ added in v0.11.0
type QueryAuthorizer struct {
Client *Client
}
QueryAuthorizer determines whether a user is authorized to execute a given query.
func NewQueryAuthorizer ¶ added in v0.11.0
func NewQueryAuthorizer(c *Client) *QueryAuthorizer
NewQueryAuthorizer returns a new instance of QueryAuthorizer.
func (*QueryAuthorizer) AuthorizeQuery ¶ added in v0.11.0
AuthorizeQuery authorizes u to execute q on database. Database can be "" for queries that do not require a database. If no user is provided it will return an error unless the query's first statement is to create a root user.
type RetentionPolicyInfo ¶
type RetentionPolicyInfo struct { Name string ReplicaN int Duration time.Duration ShardGroupDuration time.Duration ShardGroups []ShardGroupInfo Subscriptions []SubscriptionInfo }
RetentionPolicyInfo represents metadata about a retention policy.
func DefaultRetentionPolicyInfo ¶ added in v1.0.0
func DefaultRetentionPolicyInfo() *RetentionPolicyInfo
DefaultRetentionPolicyInfo returns a new instance of RetentionPolicyInfo with default name, replication, and duration.
func NewRetentionPolicyInfo ¶
func NewRetentionPolicyInfo(name string) *RetentionPolicyInfo
NewRetentionPolicyInfo returns a new instance of RetentionPolicyInfo with default replication and duration.
func (*RetentionPolicyInfo) Apply ¶ added in v1.0.0
func (rpi *RetentionPolicyInfo) Apply(spec *RetentionPolicySpec) *RetentionPolicyInfo
Apply applies a specification to the retention policy info.
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) MarshalBinary ¶ added in v0.12.0
func (rpi *RetentionPolicyInfo) MarshalBinary() ([]byte, error)
MarshalBinary encodes rpi to a binary format.
func (*RetentionPolicyInfo) ShardGroupByTimestamp ¶
func (rpi *RetentionPolicyInfo) ShardGroupByTimestamp(timestamp time.Time) *ShardGroupInfo
ShardGroupByTimestamp returns the shard group in the policy that contains the timestamp, or nil if no shard group matches.
func (*RetentionPolicyInfo) UnmarshalBinary ¶ added in v0.12.0
func (rpi *RetentionPolicyInfo) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes rpi from a binary format.
type RetentionPolicySpec ¶ added in v1.0.0
type RetentionPolicySpec struct { Name string ReplicaN *int Duration *time.Duration ShardGroupDuration time.Duration }
RetentionPolicySpec represents the specification for a new retention policy.
func (*RetentionPolicySpec) MarshalBinary ¶ added in v1.0.0
func (s *RetentionPolicySpec) MarshalBinary() ([]byte, error)
MarshalBinary encodes RetentionPolicySpec to a binary format.
func (*RetentionPolicySpec) Matches ¶ added in v1.0.0
func (s *RetentionPolicySpec) Matches(rpi *RetentionPolicyInfo) bool
Matches checks if this retention policy specification matches an existing retention policy.
func (*RetentionPolicySpec) NewRetentionPolicyInfo ¶ added in v1.0.0
func (s *RetentionPolicySpec) NewRetentionPolicyInfo() *RetentionPolicyInfo
NewRetentionPolicyInfo creates a new retention policy info from the specification.
func (*RetentionPolicySpec) UnmarshalBinary ¶ added in v1.0.0
func (s *RetentionPolicySpec) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes RetentionPolicySpec from a binary format.
type RetentionPolicyUpdate ¶
type RetentionPolicyUpdate struct { Name *string Duration *time.Duration ReplicaN *int ShardGroupDuration *time.Duration }
RetentionPolicyUpdate represents retention policy fields to be updated.
func (*RetentionPolicyUpdate) SetDuration ¶
func (rpu *RetentionPolicyUpdate) SetDuration(v time.Duration)
SetDuration sets the RetentionPolicyUpdate.Duration.
func (*RetentionPolicyUpdate) SetName ¶
func (rpu *RetentionPolicyUpdate) SetName(v string)
SetName sets the RetentionPolicyUpdate.Name.
func (*RetentionPolicyUpdate) SetReplicaN ¶
func (rpu *RetentionPolicyUpdate) SetReplicaN(v int)
SetReplicaN sets the RetentionPolicyUpdate.ReplicaN.
func (*RetentionPolicyUpdate) SetShardGroupDuration ¶ added in v0.12.0
func (rpu *RetentionPolicyUpdate) SetShardGroupDuration(v time.Duration)
SetShardGroupDuration sets the RetentionPolicyUpdate.ShardGroupDuration.
type ShardGroupInfo ¶
type ShardGroupInfo struct { ID uint64 StartTime time.Time EndTime time.Time DeletedAt time.Time Shards []ShardInfo TruncatedAt 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 returns 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 returns whether the shard group contains data for the time range between min and max
func (*ShardGroupInfo) ShardFor ¶
func (sgi *ShardGroupInfo) ShardFor(hash uint64) ShardInfo
ShardFor returns the ShardInfo for a Point hash.
func (*ShardGroupInfo) Truncated ¶ added in v1.0.0
func (sgi *ShardGroupInfo) Truncated() bool
Truncated returns true if this ShardGroup has been truncated (no new writes).
type ShardGroupInfos ¶
type ShardGroupInfos []ShardGroupInfo
ShardGroupInfos implements sort.Interface on []ShardGroupInfo, based on the StartTime field.
func (ShardGroupInfos) Less ¶
func (a ShardGroupInfos) Less(i, j int) bool
Less implements sort.Interface.
func (ShardGroupInfos) Swap ¶
func (a ShardGroupInfos) Swap(i, j int)
Swap implements sort.Interface.
type ShardInfo ¶
type ShardInfo struct { ID uint64 Owners []ShardOwner }
ShardInfo represents metadata about a shard.
func (*ShardInfo) UnmarshalBinary ¶
UnmarshalBinary decodes the object from a binary format.
type ShardOwner ¶
type ShardOwner struct {
NodeID uint64
}
ShardOwner represents a node that owns a shard.
type SubscriptionInfo ¶
SubscriptionInfo holds the subscription information.
type UserInfo ¶
type UserInfo struct { Name string Hash string Admin bool Privileges map[string]influxql.Privilege }
UserInfo represents metadata about a user in the system.
type WriteAuthorizer ¶ added in v1.0.0
type WriteAuthorizer struct {
Client *Client
}
WriteAuthorizer determines whether a user is authorized to write to a given database.
func NewWriteAuthorizer ¶ added in v1.0.0
func NewWriteAuthorizer(c *Client) *WriteAuthorizer
NewWriteAuthorizer returns a new instance of WriteAuthorizer.
func (WriteAuthorizer) AuthorizeWrite ¶ added in v1.0.0
func (a WriteAuthorizer) AuthorizeWrite(username, database string) error
AuthorizeWrite returns nil if the user has permission to write to the database.