Documentation ¶
Overview ¶
Package meta provides control over meta data for CnosDB, such as controlling databases, retention policies, users, etc.
Index ¶
- Constants
- Variables
- func DefaultHost(hostname, addr string) (string, error)
- func ErrInvalidSubscriptionURL(url string) error
- func MarshalTime(t time.Time) int64
- func NewContextWithUser(ctx context.Context, user User) context.Context
- func UnmarshalTime(v int64) time.Time
- func ValidName(name string) bool
- func WrapWithGzipResponseWriter(inner http.Handler) http.Handler
- func WrapWithRecovery(inner http.Handler, name string) http.Handler
- func WrapWithRequestID(inner http.Handler) http.Handler
- func WrapWithVersionHeader(inner http.Handler, version string) http.Handler
- type Client
- func (c *Client) AcquireLease(name string) (*Lease, error)
- func (c *Client) AdminUserExists() bool
- func (c *Client) Authenticate(username, password string) (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) (*NodeInfo, error)
- func (c *Client) CreateDatabase(name string) (*DatabaseInfo, error)
- func (c *Client) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionPolicySpec) (*DatabaseInfo, error)
- func (c *Client) CreateMetaNode(httpAddr, tcpAddr string) (*NodeInfo, error)
- func (c *Client) CreateRetentionPolicy(database string, spec *RetentionPolicySpec, makeDefault bool) (*RetentionPolicyInfo, error)
- func (c *Client) CreateShardGroup(database, rp 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) (User, error)
- func (c *Client) Data() Data
- func (c *Client) DataNode(id uint64) (*NodeInfo, error)
- func (c *Client) DataNodeByHTTPHost(httpAddr string) (*NodeInfo, error)
- func (c *Client) DataNodeByTCPHost(tcpAddr string) (*NodeInfo, error)
- func (c *Client) DataNodes() ([]NodeInfo, error)
- func (c *Client) Database(name string) *DatabaseInfo
- func (c *Client) Databases() []DatabaseInfo
- func (c *Client) DeleteDataNode(id uint64) error
- func (c *Client) DeleteMetaNode(id uint64) error
- func (c *Client) DeleteShardGroup(database, rp 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) *NodeInfo
- func (c *Client) MetaNodes() ([]NodeInfo, error)
- func (c *Client) NodeID() uint64
- func (c *Client) Open() error
- func (c *Client) Ping(checkAllMetaServers bool) 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) SetDefaultRetentionPolicy(database, name string) error
- func (c *Client) SetMetaServers([]string)
- func (c *Client) SetPrivilege(username, database string, p cnosql.Privilege) error
- func (c *Client) ShardGroupsByTimeRange(database, rp string, min, max time.Time) (a []ShardGroupInfo, err error)
- func (c *Client) ShardIDs() []uint64
- func (c *Client) ShardOwner(shardID uint64) (database, rp string, sgi *ShardGroupInfo)
- func (c *Client) ShardsByTimeRange(sources cnosql.Sources, tmin, tmax time.Time) (a []ShardInfo, err error)
- func (c *Client) TruncateShardGroups(t time.Time) error
- func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
- func (c *Client) UpdateShardOwners(shardID uint64, addOwners []uint64, delOwners []uint64) error
- func (c *Client) UpdateUser(name, password string) error
- func (c *Client) User(name string) (User, error)
- func (c *Client) UserCount() int
- func (c *Client) UserPrivilege(username, database string) (*cnosql.Privilege, error)
- func (c *Client) UserPrivileges(username string) (map[string]cnosql.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) AddShardOwner(shardID, nodeID uint64)
- func (data Data) AdminUserExists() bool
- func (data *Data) Clone() *Data
- func (data *Data) CreateContinuousQuery(database, name, query string) error
- func (data *Data) CreateDataNode(host, tcpHost string) error
- func (data *Data) CreateDatabase(name string) error
- func (data *Data) CreateMetaNode(httpAddr, tcpAddr string) error
- func (data *Data) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo, makeDefault bool) error
- func (data *Data) CreateShardGroup(database, rp string, timestamp time.Time) error
- func (data *Data) CreateShardGroupDeprecated(database, rp 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) DataNode(id uint64) *NodeInfo
- func (data *Data) DataNodeByAddr(host string) *NodeInfo
- func (data *Data) DataNodeContainShardsByID(id uint64) []uint64
- func (data *Data) Database(name string) *DatabaseInfo
- func (data *Data) DeleteDataNode(id uint64) error
- func (data *Data) DeleteMetaNode(id uint64) error
- func (data *Data) DeleteShardGroup(database, rp 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) ImportData(other Data, backupDBName, restoreDBName, backupRPName, restoreRPName string) (map[uint64]uint64, []string, error)
- func (data *Data) MarshalBinary() ([]byte, error)
- func (data *Data) MetaNode(id uint64) *NodeInfo
- func (data *Data) RemoveShardOwner(shardID, nodeID uint64)
- func (data *Data) RetentionPolicy(database, name string) (*RetentionPolicyInfo, error)
- func (data *Data) SetAdminPrivilege(name string, admin bool) error
- func (data *Data) SetDefaultRetentionPolicy(database, name string) error
- func (data *Data) SetMetaNode(httpAddr, tcpAddr string) error
- func (data *Data) SetPrivilege(name, database string, p cnosql.Privilege) error
- func (data *Data) ShardDBRetentionAndInfo(id uint64) (string, string, ShardInfo)
- func (data *Data) ShardGroupByTimestamp(database, rp string, timestamp time.Time) (*ShardGroupInfo, error)
- func (data *Data) ShardGroups(database, rp string) ([]ShardGroupInfo, error)
- func (data *Data) ShardGroupsByTimeRange(database, rp string, tmin, tmax time.Time) ([]ShardGroupInfo, error)
- func (data *Data) TruncateShardGroups(t time.Time)
- 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) User
- func (data *Data) UserPrivilege(name, database string) (*cnosql.Privilege, error)
- func (data *Data) UserPrivileges(name string) (map[string]cnosql.Privilege, error)
- type DatabaseInfo
- type ErrAuthorize
- type Handler
- type Lease
- type Leases
- type MetaClient
- type NodeInfo
- type NodeInfos
- type QueryAuthorizer
- type RemoteClient
- func (c *RemoteClient) AcquireLease(name string) (l *Lease, err error)
- func (c *RemoteClient) AdminUserExists() bool
- func (c *RemoteClient) Authenticate(username, password string) (User, error)
- func (c *RemoteClient) Close() error
- func (c *RemoteClient) ClusterID() uint64
- func (c *RemoteClient) CreateContinuousQuery(database, name, query string) error
- func (c *RemoteClient) CreateDataNode(httpAddr, tcpAddr string) (*NodeInfo, error)
- func (c *RemoteClient) CreateDatabase(name string) (*DatabaseInfo, error)
- func (c *RemoteClient) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionPolicySpec) (*DatabaseInfo, error)
- func (c *RemoteClient) CreateMetaNode(httpAddr, tcpAddr string) (*NodeInfo, error)
- func (c *RemoteClient) CreateRetentionPolicy(database string, spec *RetentionPolicySpec, makeDefault bool) (*RetentionPolicyInfo, error)
- func (c *RemoteClient) CreateShardGroup(database, rp string, timestamp time.Time) (*ShardGroupInfo, error)
- func (c *RemoteClient) CreateSubscription(database, rp, name, mode string, destinations []string) error
- func (c *RemoteClient) CreateUser(name, password string, admin bool) (User, error)
- func (c *RemoteClient) Data() Data
- func (c *RemoteClient) DataNode(id uint64) (*NodeInfo, error)
- func (c *RemoteClient) DataNodeByHTTPHost(httpAddr string) (*NodeInfo, error)
- func (c *RemoteClient) DataNodeByTCPHost(tcpAddr string) (*NodeInfo, error)
- func (c *RemoteClient) DataNodes() ([]NodeInfo, error)
- func (c *RemoteClient) Database(name string) *DatabaseInfo
- func (c *RemoteClient) Databases() []DatabaseInfo
- func (c *RemoteClient) DeleteDataNode(id uint64) error
- func (c *RemoteClient) DeleteMetaNode(id uint64) error
- func (c *RemoteClient) DeleteShardGroup(database, rp string, id uint64) error
- func (c *RemoteClient) DropContinuousQuery(database, name string) error
- func (c *RemoteClient) DropDatabase(name string) error
- func (c *RemoteClient) DropRetentionPolicy(database, name string) error
- func (c *RemoteClient) DropShard(id uint64) error
- func (c *RemoteClient) DropSubscription(database, rp, name string) error
- func (c *RemoteClient) DropUser(name string) error
- func (c *RemoteClient) Load() error
- func (c *RemoteClient) MarshalBinary() ([]byte, error)
- func (c *RemoteClient) MetaNodeByAddr(addr string) *NodeInfo
- func (c *RemoteClient) MetaNodes() ([]NodeInfo, error)
- func (c *RemoteClient) NodeID() uint64
- func (c *RemoteClient) Open() error
- func (c *RemoteClient) Ping(checkAllMetaServers bool) error
- func (c *RemoteClient) PrecreateShardGroups(from, to time.Time) error
- func (c *RemoteClient) PruneShardGroups() error
- func (c *RemoteClient) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error)
- func (c *RemoteClient) SetAdminPrivilege(username string, admin bool) error
- func (c *RemoteClient) SetData(data *Data) error
- func (c *RemoteClient) SetDefaultRetentionPolicy(database, name string) error
- func (c *RemoteClient) SetMetaServers(a []string)
- func (c *RemoteClient) SetPrivilege(username, database string, p cnosql.Privilege) error
- func (c *RemoteClient) SetTLS(v bool)
- func (c *RemoteClient) ShardGroupsByTimeRange(database, rp string, min, max time.Time) (a []ShardGroupInfo, err error)
- func (c *RemoteClient) ShardIDs() []uint64
- func (c *RemoteClient) ShardOwner(shardID uint64) (database, rp string, sgi *ShardGroupInfo)
- func (c *RemoteClient) ShardsByTimeRange(sources cnosql.Sources, tmin, tmax time.Time) (a []ShardInfo, err error)
- func (c *RemoteClient) TruncateShardGroups(t time.Time) error
- func (c *RemoteClient) UpdateDataNodeAddr(id uint64, httpAddr, tcpAddr string) error
- func (c *RemoteClient) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
- func (c *RemoteClient) UpdateShardOwners(shardID uint64, addOwners []uint64, delOwners []uint64) error
- func (c *RemoteClient) UpdateUser(name, password string) error
- func (c *RemoteClient) User(name string) (User, error)
- func (c *RemoteClient) UserCount() int
- func (c *RemoteClient) UserPrivilege(username, database string) (*cnosql.Privilege, error)
- func (c *RemoteClient) UserPrivileges(username string) (map[string]cnosql.Privilege, error)
- func (c *RemoteClient) Users() []UserInfo
- func (c *RemoteClient) WaitForDataChanged() chan struct{}
- func (c *RemoteClient) WithLogger(log *zap.Logger)
- type ResponseLogger
- func (l *ResponseLogger) CloseNotify() <-chan bool
- func (l *ResponseLogger) Flush()
- func (l *ResponseLogger) Header() http.Header
- func (l *ResponseLogger) Size() int
- func (l *ResponseLogger) Status() int
- func (l *ResponseLogger) Write(b []byte) (int, error)
- func (l *ResponseLogger) WriteHeader(s int)
- 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 Server
- type ServerConfig
- type ShardGroupInfo
- type ShardGroupInfos
- type ShardInfo
- type ShardOwner
- type SubscriptionInfo
- type User
- type UserInfo
- func (ui *UserInfo) AuthorizeDatabase(privilege cnosql.Privilege, database string) bool
- func (u *UserInfo) AuthorizeSeriesRead(database string, measurement []byte, tags models.Tags) bool
- func (u *UserInfo) AuthorizeSeriesWrite(database string, measurement []byte, tags models.Tags) bool
- func (u *UserInfo) AuthorizeUnrestricted() bool
- func (u *UserInfo) ID() string
- func (u *UserInfo) IsOpen() bool
- 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 ( // 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 retention policy. MinRetentionPolicyDuration = time.Hour // MaxNameLen is the maximum length of a database or retention policy name. // CnosDB uses the name for the directory name on disk. MaxNameLen = 255 )
const ( // DefaultHostname is the default hostname if one is not provided. DefaultHostname = "localhost" // DefaultHTTPBindAddress is the default address to bind the API to. DefaultHTTPBindAddress = ":8091" // 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 // DefaultLeaseDuration is the default duration for leases. DefaultLeaseDuration = 60 * time.Second )
const ( // DefaultLoggingEnabled determines if log messages are printed for the meta service. DefaultLoggingEnabled = true )
const RaftMuxHeader = "raft"
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 ( // 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") )
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") // ErrNameTooLong is returned when attempting to create a database or // retention policy with a name that is too long. ErrNameTooLong = errors.New("name too long") // 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 retention policy. ErrRetentionPolicyExists = errors.New("retention policy already exists") // ErrRetentionPolicyNotFound is returned when an expected retention 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 retention policy was passed. ErrRetentionPolicyRequired = errors.New("retention policy required") // ErrRetentionPolicyNameRequired is returned when creating a retention policy without a name. ErrRetentionPolicyNameRequired = errors.New("retention policy name required") // ErrRetentionPolicyNameExists is returned when renaming a retention policy to // the same name as another existing retention 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 retention policy. ErrRetentionPolicyConflict = errors.New("retention policy conflicts with an existing retention 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 DefaultHost ¶
func ErrInvalidSubscriptionURL ¶
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 NewContextWithUser ¶
NewContextWithUser returns a new context with user added.
func UnmarshalTime ¶
UnmarshalTime converts nanoseconds since epoch to time. A zero value returns a zero time.
func WrapWithGzipResponseWriter ¶
WrapWithGzipResponseWriter determines if the client can accept compressed responses, and encodes accordingly.
func WrapWithRecovery ¶
WrapWithRecovery
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.
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 ¶
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) CreateMetaNode ¶
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, rp string, timestamp time.Time) (*ShardGroupInfo, error)
CreateShardGroup creates a shard group on a database and retention 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 ¶
func (*Client) DataNodeByTCPHost ¶
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) DeleteDataNode ¶
func (*Client) DeleteMetaNode ¶
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 ¶
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) 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) SetDefaultRetentionPolicy ¶
SetDefaultRetentionPolicy sets a database's default retention policy.
func (*Client) SetMetaServers ¶
func (*Client) SetPrivilege ¶
SetPrivilege sets a privilege for the given user on the given database.
func (*Client) ShardGroupsByTimeRange ¶
func (c *Client) ShardGroupsByTimeRange(database, rp string, min, max time.Time) (a []ShardGroupInfo, err error)
ShardGroupsByTimeRange returns a list of all shard groups on a database and retention policy that may contain data for the specified time range. ShardGroups are sorted by start time.
func (*Client) ShardOwner ¶
func (c *Client) ShardOwner(shardID uint64) (database, rp string, sgi *ShardGroupInfo)
ShardOwner returns the owning shard group info for a specific shard.
func (*Client) ShardsByTimeRange ¶
func (c *Client) ShardsByTimeRange(sources cnosql.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) TruncateShardGroups ¶
TruncateShardGroups truncates any shard group that could contain timestamps beyond t.
func (*Client) UpdateRetentionPolicy ¶
func (c *Client) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
UpdateRetentionPolicy updates a retention policy.
func (*Client) UpdateShardOwners ¶ added in v1.0.2
UpdateShardOwners add or delete owners for the given shard id.
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
type Config ¶
type Config struct { Dir string `toml:"dir"` RetentionAutoCreate bool `toml:"retention-autocreate"` Hostname string `toml:"hostname"` HTTPD *ServerConfig Log *logger.Config }
Config represents the meta configuration.
func NewDemoClusterConfig ¶
NewDemoClusterConfig returns the config with meta server config that runs when no config is specified.
func NewDemoConfig ¶
NewDemoConfig returns the config that runs when no config is specified.
func (*Config) ApplyEnvOverrides ¶
ApplyEnvOverrides apply the environment configuration on top of the config.
func (*Config) FromTomlFile ¶
FromTomlFile loads the config from a TOML file.
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 MetaNodes []NodeInfo DataNodes []NodeInfo Databases []DatabaseInfo Users []UserInfo MaxNodeID uint64 MaxShardGroupID uint64 MaxShardID uint64 // contains filtered or unexported fields }
Data represents the top level collection of all metadata.
func (*Data) AddShardOwner ¶ added in v1.0.2
RemoveShardOwner add a owner for the specified shard id.
func (Data) AdminUserExists ¶
AdminUserExists returns true if an admin user exists.
func (*Data) CreateContinuousQuery ¶
CreateContinuousQuery adds a named continuous query to a database.
func (*Data) CreateDataNode ¶
CreateDataNode adds a node to the metadata.
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) CreateMetaNode ¶
CreateMetaNode will add a new meta node to the metastore
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 retention policy for a given timestamp.
func (*Data) CreateShardGroupDeprecated ¶
CreateShardGroup creates a shard group on a database and retention 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) DataNodeByAddr ¶ added in v1.0.2
DataNode returns a node by host.
func (*Data) DataNodeContainShardsByID ¶ added in v1.0.3
func (*Data) Database ¶
func (data *Data) Database(name string) *DatabaseInfo
Database returns a DatabaseInfo by the database name.
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) 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 ¶
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) ImportData ¶
func (data *Data) ImportData(other Data, backupDBName, restoreDBName, backupRPName, restoreRPName string) (map[uint64]uint64, []string, error)
ImportData imports selected data into the current metadata. if non-empty, backupDBName, restoreDBName, backupRPName, restoreRPName can be used to select DB metadata from other, and to assign a new name to the imported data. Returns a map of shard ID's in the old metadata to new shard ID's in the new metadata, along with a list of new databases created, both of which can assist in the import of existing shard data during a database restore.
func (*Data) MarshalBinary ¶
MarshalBinary encodes the metadata to a binary format.
func (*Data) RemoveShardOwner ¶ added in v1.0.2
RemoveShardOwner remove a owner for the specified shard id.
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) SetDefaultRetentionPolicy ¶
SetDefaultRetentionPolicy sets the default retention policy for a database.
func (*Data) SetMetaNode ¶
SetMetaNode will update the information for the single meta node or create a new metanode. If there are more than 1 meta nodes already, an error will be returned
func (*Data) SetPrivilege ¶
SetPrivilege sets a privilege for a user on a database.
func (*Data) ShardDBRetentionAndInfo ¶ added in v1.0.2
ShardDBRetentionAndOwners returns database name RP name and owners for the specified shard id.
func (*Data) ShardGroupByTimestamp ¶
func (data *Data) ShardGroupByTimestamp(database, rp string, timestamp time.Time) (*ShardGroupInfo, error)
ShardGroupByTimestamp returns the shard group on a database and retention policy for a given timestamp.
func (*Data) ShardGroups ¶
func (data *Data) ShardGroups(database, rp 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, rp string, tmin, tmax time.Time) ([]ShardGroupInfo, error)
ShardGroupsByTimeRange returns a list of all shard groups on a database and retention policy that may contain data for the specified time range. ShardGroups are sorted by start time.
func (*Data) TruncateShardGroups ¶
TruncateShardGroups truncates any shard group that could contain timestamps beyond t.
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 ¶
ErrAuthorize represents an authorization error.
func (ErrAuthorize) Error ¶
func (e ErrAuthorize) Error() string
Error returns the text of the error.
type Handler ¶
type Handler struct { Version string // contains filtered or unexported fields }
func (*Handler) AddRoutes ¶
func (h *Handler) AddRoutes(routes ...route)
AddRoutes sets the provided routes on the Handler.
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 MetaClient ¶
type MetaClient interface { Open() error Close() error NodeID() uint64 ClusterID() uint64 Ping(checkAllMetaServers bool) error AcquireLease(name string) (*Lease, error) SetMetaServers([]string) DataNode(id uint64) (*NodeInfo, error) DataNodes() ([]NodeInfo, error) CreateDataNode(httpAddr, tcpAddr string) (*NodeInfo, error) DataNodeByHTTPHost(httpAddr string) (*NodeInfo, error) DataNodeByTCPHost(tcpAddr string) (*NodeInfo, error) DeleteDataNode(id uint64) error MetaNodes() ([]NodeInfo, error) MetaNodeByAddr(addr string) *NodeInfo CreateMetaNode(httpAddr, tcpAddr string) (*NodeInfo, error) DeleteMetaNode(id uint64) error Database(name string) *DatabaseInfo Databases() []DatabaseInfo CreateDatabase(name string) (*DatabaseInfo, error) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionPolicySpec) (*DatabaseInfo, error) DropDatabase(name string) error CreateRetentionPolicy(database string, spec *RetentionPolicySpec, makeDefault bool) (*RetentionPolicyInfo, error) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error) DropRetentionPolicy(database, name string) error SetDefaultRetentionPolicy(database, name string) error UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error Users() []UserInfo UserCount() int User(name string) (User, error) CreateUser(name, password string, admin bool) (User, error) UpdateUser(name, password string) error DropUser(name string) error SetPrivilege(username, database string, p cnosql.Privilege) error SetAdminPrivilege(username string, admin bool) error UserPrivileges(username string) (map[string]cnosql.Privilege, error) UserPrivilege(username, database string) (*cnosql.Privilege, error) AdminUserExists() bool Authenticate(username, password string) (User, error) ShardIDs() []uint64 ShardGroupsByTimeRange(database, rp string, min, max time.Time) (a []ShardGroupInfo, err error) ShardsByTimeRange(sources cnosql.Sources, tmin, tmax time.Time) (a []ShardInfo, err error) DropShard(id uint64) error TruncateShardGroups(t time.Time) error PruneShardGroups() error CreateShardGroup(database, rp string, timestamp time.Time) (*ShardGroupInfo, error) DeleteShardGroup(database, rp string, id uint64) error PrecreateShardGroups(from, to time.Time) error ShardOwner(shardID uint64) (database, rp string, sgi *ShardGroupInfo) CreateContinuousQuery(database, name, query string) error DropContinuousQuery(database, name string) error CreateSubscription(database, rp, name, mode string, destinations []string) error DropSubscription(database, rp, name string) error SetData(data *Data) error Data() Data WaitForDataChanged() chan struct{} UpdateShardOwners(shardID uint64, addOwners []uint64, delOwners []uint64) error Load() error MarshalBinary() ([]byte, error) WithLogger(log *zap.Logger) }
type QueryAuthorizer ¶
type QueryAuthorizer struct {
Client MetaClient
}
QueryAuthorizer determines whether a user is authorized to execute a given query.
func NewQueryAuthorizer ¶
func NewQueryAuthorizer(c MetaClient) *QueryAuthorizer
NewQueryAuthorizer returns a new instance of QueryAuthorizer.
func (*QueryAuthorizer) AuthorizeDatabase ¶
func (*QueryAuthorizer) AuthorizeQuery ¶
func (a *QueryAuthorizer) AuthorizeQuery(u User, q *cnosql.Query, database string) (query.FineAuthorizer, error)
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 RemoteClient ¶
type RemoteClient struct {
// contains filtered or unexported fields
}
func (*RemoteClient) AcquireLease ¶
func (c *RemoteClient) AcquireLease(name string) (l *Lease, err error)
A lease is a logical concept that can be used by anything that needs to limit execution to a single node. E.g., the CQ service on all nodes may ask for the "ContinuousQuery" lease. Only the node that acquires it will run CQs. NOTE: Leases are not managed through the CP system and are not fully consistent. Any actions taken after acquiring a lease must be idempotent.
func (*RemoteClient) AdminUserExists ¶
func (c *RemoteClient) AdminUserExists() bool
func (*RemoteClient) Authenticate ¶
func (c *RemoteClient) Authenticate(username, password string) (User, error)
func (*RemoteClient) Close ¶
func (c *RemoteClient) Close() error
Close the meta service cluster connection.
func (*RemoteClient) ClusterID ¶
func (c *RemoteClient) ClusterID() uint64
ClusterID returns the ID of the cluster it's connected to.
func (*RemoteClient) CreateContinuousQuery ¶
func (c *RemoteClient) CreateContinuousQuery(database, name, query string) error
func (*RemoteClient) CreateDataNode ¶
func (c *RemoteClient) CreateDataNode(httpAddr, tcpAddr string) (*NodeInfo, error)
CreateDataNode will create a new data node in the metastore
func (*RemoteClient) CreateDatabase ¶
func (c *RemoteClient) CreateDatabase(name string) (*DatabaseInfo, error)
CreateDatabase creates a database or returns it if it already exists
func (*RemoteClient) CreateDatabaseWithRetentionPolicy ¶
func (c *RemoteClient) CreateDatabaseWithRetentionPolicy(name string, spec *RetentionPolicySpec) (*DatabaseInfo, error)
CreateDatabaseWithRetentionPolicy creates a database with the specified retention policy.
func (*RemoteClient) CreateMetaNode ¶
func (c *RemoteClient) CreateMetaNode(httpAddr, tcpAddr string) (*NodeInfo, error)
func (*RemoteClient) CreateRetentionPolicy ¶
func (c *RemoteClient) CreateRetentionPolicy(database string, spec *RetentionPolicySpec, makeDefault bool) (*RetentionPolicyInfo, error)
CreateRetentionPolicy creates a retention policy on the specified database.
func (*RemoteClient) CreateShardGroup ¶
func (c *RemoteClient) CreateShardGroup(database, rp string, timestamp time.Time) (*ShardGroupInfo, error)
CreateShardGroup creates a shard group on a database and retention policy for a given timestamp.
func (*RemoteClient) CreateSubscription ¶
func (c *RemoteClient) CreateSubscription(database, rp, name, mode string, destinations []string) error
func (*RemoteClient) CreateUser ¶
func (c *RemoteClient) CreateUser(name, password string, admin bool) (User, error)
func (*RemoteClient) Data ¶
func (c *RemoteClient) Data() Data
Data returns a clone of the underlying data in the meta store.
func (*RemoteClient) DataNode ¶
func (c *RemoteClient) DataNode(id uint64) (*NodeInfo, error)
DataNode returns a node by id.
func (*RemoteClient) DataNodeByHTTPHost ¶
func (c *RemoteClient) DataNodeByHTTPHost(httpAddr string) (*NodeInfo, error)
DataNodeByHTTPHost returns the data node with the give http bind address
func (*RemoteClient) DataNodeByTCPHost ¶
func (c *RemoteClient) DataNodeByTCPHost(tcpAddr string) (*NodeInfo, error)
DataNodeByTCPHost returns the data node with the give http bind address
func (*RemoteClient) DataNodes ¶
func (c *RemoteClient) DataNodes() ([]NodeInfo, error)
DataNodes returns the data nodes' info.
func (*RemoteClient) Database ¶
func (c *RemoteClient) Database(name string) *DatabaseInfo
Database returns info for the requested database.
func (*RemoteClient) Databases ¶
func (c *RemoteClient) Databases() []DatabaseInfo
Databases returns a list of all database infos.
func (*RemoteClient) DeleteDataNode ¶
func (c *RemoteClient) DeleteDataNode(id uint64) error
DeleteDataNode deletes a data node from the cluster.
func (*RemoteClient) DeleteMetaNode ¶
func (c *RemoteClient) DeleteMetaNode(id uint64) error
func (*RemoteClient) DeleteShardGroup ¶
func (c *RemoteClient) DeleteShardGroup(database, rp string, id uint64) error
DeleteShardGroup removes a shard group from a database and retention policy by id.
func (*RemoteClient) DropContinuousQuery ¶
func (c *RemoteClient) DropContinuousQuery(database, name string) error
func (*RemoteClient) DropDatabase ¶
func (c *RemoteClient) DropDatabase(name string) error
DropDatabase deletes a database.
func (*RemoteClient) DropRetentionPolicy ¶
func (c *RemoteClient) DropRetentionPolicy(database, name string) error
DropRetentionPolicy drops a retention policy from a database.
func (*RemoteClient) DropShard ¶
func (c *RemoteClient) DropShard(id uint64) error
DropShard deletes a shard by ID.
func (*RemoteClient) DropSubscription ¶
func (c *RemoteClient) DropSubscription(database, rp, name string) error
func (*RemoteClient) DropUser ¶
func (c *RemoteClient) DropUser(name string) error
func (*RemoteClient) Load ¶
func (c *RemoteClient) Load() error
func (*RemoteClient) MarshalBinary ¶
func (c *RemoteClient) MarshalBinary() ([]byte, error)
MarshalBinary returns a binary representation of the underlying data.
func (*RemoteClient) MetaNodeByAddr ¶
func (c *RemoteClient) MetaNodeByAddr(addr string) *NodeInfo
MetaNodeByAddr returns the meta node's info.
func (*RemoteClient) MetaNodes ¶
func (c *RemoteClient) MetaNodes() ([]NodeInfo, error)
MetaNodes returns the meta nodes' info.
func (*RemoteClient) NodeID ¶
func (c *RemoteClient) NodeID() uint64
NodeID returns the client's node ID.
func (*RemoteClient) Open ¶
func (c *RemoteClient) Open() error
Open a connection to a meta service cluster.
func (*RemoteClient) Ping ¶
func (c *RemoteClient) Ping(checkAllMetaServers bool) error
Ping will hit the ping endpoint for the metaservice and return nil if it returns 200. If checkAllMetaServers is set to true, it will hit the ping endpoint and tell it to verify the health of all meta-servers in the cluster
func (*RemoteClient) PrecreateShardGroups ¶
func (c *RemoteClient) PrecreateShardGroups(from, to time.Time) error
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 (*RemoteClient) PruneShardGroups ¶
func (c *RemoteClient) PruneShardGroups() error
func (*RemoteClient) RetentionPolicy ¶
func (c *RemoteClient) RetentionPolicy(database, name string) (rpi *RetentionPolicyInfo, err error)
RetentionPolicy returns the requested retention policy info.
func (*RemoteClient) SetAdminPrivilege ¶
func (c *RemoteClient) SetAdminPrivilege(username string, admin bool) error
func (*RemoteClient) SetData ¶
func (c *RemoteClient) SetData(data *Data) error
func (*RemoteClient) SetDefaultRetentionPolicy ¶
func (c *RemoteClient) SetDefaultRetentionPolicy(database, name string) error
SetDefaultRetentionPolicy sets a database's default retention policy.
func (*RemoteClient) SetMetaServers ¶
func (c *RemoteClient) SetMetaServers(a []string)
SetMetaServers updates the meta-servers on the
func (*RemoteClient) SetPrivilege ¶
func (c *RemoteClient) SetPrivilege(username, database string, p cnosql.Privilege) error
func (*RemoteClient) SetTLS ¶
func (c *RemoteClient) SetTLS(v bool)
SetTLS sets whether the client should use TLS when connecting. This function is not safe for concurrent use.
func (*RemoteClient) ShardGroupsByTimeRange ¶
func (c *RemoteClient) ShardGroupsByTimeRange(database, rp string, min, max time.Time) (a []ShardGroupInfo, err error)
ShardGroupsByTimeRange returns a list of all shard groups on a database and retention policy that may contain data for the specified time range. ShardGroups are sorted by start time.
func (*RemoteClient) ShardIDs ¶
func (c *RemoteClient) ShardIDs() []uint64
ShardIDs returns a list of all shard ids.
func (*RemoteClient) ShardOwner ¶
func (c *RemoteClient) ShardOwner(shardID uint64) (database, rp string, sgi *ShardGroupInfo)
ShardOwner returns the owning shard group info for a specific shard.
func (*RemoteClient) ShardsByTimeRange ¶
func (c *RemoteClient) ShardsByTimeRange(sources cnosql.Sources, tmin, tmax time.Time) (a []ShardInfo, err error)
ShardsByTimeRange returns a slice of shards that may contain data in the time range.
func (*RemoteClient) TruncateShardGroups ¶
func (c *RemoteClient) TruncateShardGroups(t time.Time) error
func (*RemoteClient) UpdateDataNodeAddr ¶ added in v1.0.3
func (c *RemoteClient) UpdateDataNodeAddr(id uint64, httpAddr, tcpAddr string) error
func (*RemoteClient) UpdateRetentionPolicy ¶
func (c *RemoteClient) UpdateRetentionPolicy(database, name string, rpu *RetentionPolicyUpdate, makeDefault bool) error
UpdateRetentionPolicy updates a retention policy.
func (*RemoteClient) UpdateShardOwners ¶ added in v1.0.2
func (c *RemoteClient) UpdateShardOwners(shardID uint64, addOwners []uint64, delOwners []uint64) error
UpdateShardOwners add or delete owners for the given shard id.
func (*RemoteClient) UpdateUser ¶
func (c *RemoteClient) UpdateUser(name, password string) error
func (*RemoteClient) UserCount ¶
func (c *RemoteClient) UserCount() int
func (*RemoteClient) UserPrivilege ¶
func (c *RemoteClient) UserPrivilege(username, database string) (*cnosql.Privilege, error)
func (*RemoteClient) UserPrivileges ¶
func (*RemoteClient) Users ¶
func (c *RemoteClient) Users() []UserInfo
func (*RemoteClient) WaitForDataChanged ¶
func (c *RemoteClient) WaitForDataChanged() chan struct{}
WaitForDataChanged will return a channel that will get closed when the metastore data has changed
func (*RemoteClient) WithLogger ¶
func (c *RemoteClient) WithLogger(log *zap.Logger)
WithLogger sets the logger for the
type ResponseLogger ¶
type ResponseLogger struct {
// contains filtered or unexported fields
}
ResponseLogger is wrapper of http.ResponseWriter that keeps track of its HTTP status code and body size
func NewResponseLogger ¶
func NewResponseLogger(w http.ResponseWriter) *ResponseLogger
func (*ResponseLogger) CloseNotify ¶
func (l *ResponseLogger) CloseNotify() <-chan bool
func (*ResponseLogger) Flush ¶
func (l *ResponseLogger) Flush()
func (*ResponseLogger) Header ¶
func (l *ResponseLogger) Header() http.Header
func (*ResponseLogger) Size ¶
func (l *ResponseLogger) Size() int
func (*ResponseLogger) Status ¶
func (l *ResponseLogger) Status() int
func (*ResponseLogger) WriteHeader ¶
func (l *ResponseLogger) WriteHeader(s int)
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 ¶
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 ¶
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 ShardGroups which are marked as deleted.
func (*RetentionPolicyInfo) ExpiredShardGroups ¶
func (rpi *RetentionPolicyInfo) ExpiredShardGroups(t time.Time) []*ShardGroupInfo
ExpiredShardGroups returns the ShardGroups which are considered expired, for the given time.
func (*RetentionPolicyInfo) MarshalBinary ¶
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 retention policy that contains the timestamp, or nil if no shard group matches.
func (*RetentionPolicyInfo) UnmarshalBinary ¶
func (rpi *RetentionPolicyInfo) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes rpi from a binary format.
type RetentionPolicySpec ¶
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 ¶
func (s *RetentionPolicySpec) MarshalBinary() ([]byte, error)
MarshalBinary encodes RetentionPolicySpec to a binary format.
func (*RetentionPolicySpec) Matches ¶
func (s *RetentionPolicySpec) Matches(rpi *RetentionPolicyInfo) bool
Matches checks if this retention policy specification matches an existing retention policy.
func (*RetentionPolicySpec) NewRetentionPolicyInfo ¶
func (s *RetentionPolicySpec) NewRetentionPolicyInfo() *RetentionPolicyInfo
NewRetentionPolicyInfo creates a new retention policy info from the specification.
func (*RetentionPolicySpec) UnmarshalBinary ¶
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 ¶
func (rpu *RetentionPolicyUpdate) SetShardGroupDuration(v time.Duration)
SetShardGroupDuration sets the RetentionPolicyUpdate.ShardGroupDuration.
type ServerConfig ¶
type ServerConfig struct { LoggingEnabled bool `toml:"logging-enabled"` Log *log.Config // HTTPBindAddress is the bind address for the metaservice HTTP API HTTPBindAddress string `toml:"http-bind-address"` HTTPSEnabled bool `toml:"https-enabled"` HTTPSCertificate string `toml:"https-certificate"` 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"` ClusterTracing bool `toml:"cluster-tracing"` LeaseDuration toml.Duration `toml:"lease-duration"` TLS *tls.Config `toml:"-"` }
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
NewServerConfig builds a new configuration with default values.
func (ServerConfig) Diagnostics ¶
func (c ServerConfig) Diagnostics() (*diagnostics.Diagnostics, error)
Diagnostics returns a diagnostics representation of a subset of the ServerConfig.
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(t time.Time) bool
Contains returns true iif StartTime ≤ t < EndTime.
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(p hashIDer) ShardInfo
ShardFor returns the ShardInfo for a Point or other hashIDer.
func (*ShardGroupInfo) Truncated ¶
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 // if NodeID is 0 , the Shard is a local shard
}
ShardOwner represents a node that owns a shard.
type SubscriptionInfo ¶
SubscriptionInfo holds the subscription information.
type User ¶
type User interface { query.FineAuthorizer ID() string AuthorizeUnrestricted() bool }
func UserFromContext ¶
UserFromContext returns the User associated with ctx or nil if no user has been assigned.
type UserInfo ¶
type UserInfo struct { // User's name. Name string // Hashed password. Hash string // Whether the user is an admin, i.e. allowed to do everything. Admin bool // Map of database name to granted privilege. Privileges map[string]cnosql.Privilege }
UserInfo represents metadata about a user in the system.
func (*UserInfo) AuthorizeDatabase ¶
AuthorizeDatabase returns true if the user is authorized for the given privilege on the given database.
func (*UserInfo) AuthorizeSeriesRead ¶
AuthorizeSeriesRead is used to limit access per-series (enterprise only)
func (*UserInfo) AuthorizeSeriesWrite ¶
AuthorizeSeriesWrite is used to limit access per-series (enterprise only)
func (*UserInfo) AuthorizeUnrestricted ¶
AuthorizeUnrestricted allows admins to shortcut access checks.
type WriteAuthorizer ¶
type WriteAuthorizer struct {
Client MetaClient
}
WriteAuthorizer determines whether a user is authorized to write to a given database.
func NewWriteAuthorizer ¶
func NewWriteAuthorizer(c MetaClient) *WriteAuthorizer
NewWriteAuthorizer returns a new instance of WriteAuthorizer.
func (WriteAuthorizer) AuthorizeWrite ¶
func (a WriteAuthorizer) AuthorizeWrite(username, database string) error
AuthorizeWrite returns nil if the user has permission to write to the database.