Add cli option to specify db shrink policy
This commit is contained in:
parent
d0d1316449
commit
62a1a38449
4 changed files with 20 additions and 14 deletions
|
@ -15,10 +15,11 @@
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
var flags = map[string]string{
|
var flags = map[string]string{
|
||||||
"db": `Database configuration path used for storing data. Available backend stores are memory, file, s3, gcs, rixxdb, or dendrodb. (default "memory").`,
|
"db": `Database configuration path used for storing data. Available backend stores are memory, file, s3, gcs, rixxdb, or dendrodb. (default "memory").`,
|
||||||
"key": `Encryption key to use for intra-cluster communications, and on-disk encryption. For AES-128 encryption use a 16 bit key, for AES-192 encryption use a 24 bit key, and for AES-256 encryption use a 32 bit key.`,
|
"key": `Encryption key to use for intra-cluster communications, and on-disk encryption. For AES-128 encryption use a 16 bit key, for AES-192 encryption use a 24 bit key, and for AES-256 encryption use a 32 bit key.`,
|
||||||
"sync": `A time duration to use when syncing data to persistent storage. To sync data with every write specify '0', otherwise the data will be persisted asynchronously after the specified duration.`,
|
"sync": `A time duration to use when syncing data to persistent storage. To sync data with every write specify '0', otherwise the data will be persisted asynchronously after the specified duration.`,
|
||||||
"join": `A comma-separated list of addresses to use when a new node is joining an existing cluster. For the first node in a cluster, --join should NOT be specified.`,
|
"shrink": `A time duration to use when shrinking data on persistent storage. To shrink data asynchronously after a repeating period of time, specify a duration.`,
|
||||||
|
"join": `A comma-separated list of addresses to use when a new node is joining an existing cluster. For the first node in a cluster, --join should NOT be specified.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
var usage = map[string][]string{
|
var usage = map[string][]string{
|
||||||
|
|
|
@ -94,7 +94,8 @@ func init() {
|
||||||
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Crt, "db-crt", "", "Path to the certificate file used to connect to the remote database.")
|
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Crt, "db-crt", "", "Path to the certificate file used to connect to the remote database.")
|
||||||
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Key, "db-key", "", "Path to the private key file used to connect to the remote database.")
|
startCmd.PersistentFlags().StringVar(&opts.DB.Cert.Key, "db-key", "", "Path to the private key file used to connect to the remote database.")
|
||||||
startCmd.PersistentFlags().StringVar(&opts.DB.Path, "db-path", "", flag("db"))
|
startCmd.PersistentFlags().StringVar(&opts.DB.Path, "db-path", "", flag("db"))
|
||||||
startCmd.PersistentFlags().DurationVar(&opts.DB.Time, "db-sync", 0, flag("sync"))
|
startCmd.PersistentFlags().DurationVar(&opts.DB.Proc.Sync, "db-sync", 0, flag("sync"))
|
||||||
|
startCmd.PersistentFlags().DurationVar(&opts.DB.Proc.Shrink, "db-shrink", 0, flag("shrink"))
|
||||||
|
|
||||||
startCmd.PersistentFlags().StringSliceVarP(&opts.Node.Join, "join", "j", nil, flag("join"))
|
startCmd.PersistentFlags().StringSliceVarP(&opts.Node.Join, "join", "j", nil, flag("join"))
|
||||||
|
|
||||||
|
|
19
cnf/cnf.go
19
cnf/cnf.go
|
@ -76,14 +76,17 @@ type Auth struct {
|
||||||
// Options defines global configuration options
|
// Options defines global configuration options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
DB struct {
|
DB struct {
|
||||||
Key []byte // Data encryption key
|
Key []byte // Data encryption key
|
||||||
Code string // Data encryption key string
|
Code string // Data encryption key string
|
||||||
Path string // Path to store the data file
|
Path string // Path to store the data file
|
||||||
Type string // HTTP scheme type to use
|
Type string // HTTP scheme type to use
|
||||||
Host string // Surreal host to connect to
|
Host string // Surreal host to connect to
|
||||||
Port string // Surreal port to connect to
|
Port string // Surreal port to connect to
|
||||||
Base string // Base key to use in KV stores
|
Base string // Base key to use in KV stores
|
||||||
Time time.Duration // Timeframe for syncing data
|
Proc struct {
|
||||||
|
Sync time.Duration // Timeframe for syncing data
|
||||||
|
Shrink time.Duration // Timeframe for shrinking data
|
||||||
|
}
|
||||||
Cert struct {
|
Cert struct {
|
||||||
CA string
|
CA string
|
||||||
Crt string
|
Crt string
|
||||||
|
|
|
@ -31,7 +31,8 @@ func init() {
|
||||||
path := strings.TrimPrefix(opts.DB.Path, "rixxdb://")
|
path := strings.TrimPrefix(opts.DB.Path, "rixxdb://")
|
||||||
|
|
||||||
pntr, err = rixxdb.Open(path, &rixxdb.Config{
|
pntr, err = rixxdb.Open(path, &rixxdb.Config{
|
||||||
SyncPolicy: opts.DB.Time,
|
SyncPolicy: opts.DB.Proc.Sync,
|
||||||
|
ShrinkPolicy: opts.DB.Proc.Shrink,
|
||||||
EncryptionKey: opts.DB.Key,
|
EncryptionKey: opts.DB.Key,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue