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
|
@ -18,6 +18,7 @@ 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").`,
|
||||
"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.`,
|
||||
"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.`,
|
||||
}
|
||||
|
||||
|
|
|
@ -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.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().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"))
|
||||
|
||||
|
|
|
@ -83,7 +83,10 @@ type Options struct {
|
|||
Host string // Surreal host to connect to
|
||||
Port string // Surreal port to connect to
|
||||
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 {
|
||||
CA string
|
||||
Crt string
|
||||
|
|
|
@ -31,7 +31,8 @@ func init() {
|
|||
path := strings.TrimPrefix(opts.DB.Path, "rixxdb://")
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue