-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jesse Schmidt
committed
Jul 10, 2024
1 parent
9e69a5e
commit 7d69032
Showing
4 changed files
with
233 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
package flags | ||
|
||
const ( | ||
LogLevel = "log-level" | ||
Seeds = "seeds" | ||
Host = "host" | ||
ListenerName = "listener-name" | ||
AuthUser = "user" | ||
AuthPassword = "password" | ||
Name = "name" | ||
NewPassword = "new-password" | ||
Roles = "roles" | ||
Namespace = "namespace" | ||
Sets = "sets" | ||
Yes = "yes" | ||
IndexName = "index-name" | ||
VectorField = "vector-field" | ||
Dimension = "dimension" | ||
DistanceMetric = "distance-metric" | ||
IndexMeta = "index-meta" | ||
Timeout = "timeout" | ||
Verbose = "verbose" | ||
StorageNamespace = "storage-namespace" | ||
StorageSet = "storage-set" | ||
MaxEdges = "hnsw-max-edges" | ||
ConstructionEf = "hnsw-ef-construction" | ||
Ef = "hnsw-ef" | ||
BatchMaxRecords = "hnsw-batch-max-records" | ||
BatchInterval = "hnsw-batch-interval" | ||
TLSProtocols = "tls-protocols" | ||
TLSCaFile = "tls-cafile" | ||
TLSCaPath = "tls-capath" | ||
TLSCertFile = "tls-certfile" | ||
TLSKeyFile = "tls-keyfile" | ||
TLSKeyFilePass = "tls-keyfile-password" //nolint:gosec // Not a credential | ||
LogLevel = "log-level" | ||
Seeds = "seeds" | ||
Host = "host" | ||
ListenerName = "listener-name" | ||
AuthUser = "user" | ||
AuthPassword = "password" | ||
Name = "name" | ||
NewPassword = "new-password" | ||
Roles = "roles" | ||
Namespace = "namespace" | ||
Sets = "sets" | ||
Yes = "yes" | ||
IndexName = "index-name" | ||
VectorField = "vector-field" | ||
Dimension = "dimension" | ||
DistanceMetric = "distance-metric" | ||
IndexMeta = "index-meta" | ||
Timeout = "timeout" | ||
Verbose = "verbose" | ||
StorageNamespace = "storage-namespace" | ||
StorageSet = "storage-set" | ||
MaxEdges = "hnsw-max-edges" | ||
ConstructionEf = "hnsw-ef-construction" | ||
Ef = "hnsw-ef" | ||
HnswMaxMemQueueSize = "hnsw-max-mem-queue-size" | ||
BatchMaxRecords = "hnsw-batch-max-records" | ||
BatchInterval = "hnsw-batch-interval" | ||
HnswCacheMaxEntries = "hnsw-cache-max-entries" | ||
HnswCacheExpiry = "hnsw-cache-expiry" | ||
HnswHealerMaxScanRatePerNode = "hnsw-healer-max-scan-rate-per-node" | ||
HnswHealerMaxScanPageSize = "hnsw-healer-max-scan-page-size" | ||
HnswHealerReindexPercent = "hnsw-healer-reindex-percent" | ||
HnswHealerScheduleDelay = "hnsw-healer-schedule-delay" | ||
HnswHealerParallelism = "hnsw-healer-parallelism" | ||
HnswMergeParallelism = "hnsw-merge-parallelism" | ||
TLSProtocols = "tls-protocols" | ||
TLSCaFile = "tls-cafile" | ||
TLSCaPath = "tls-capath" | ||
TLSCertFile = "tls-certfile" | ||
TLSKeyFile = "tls-keyfile" | ||
TLSKeyFilePass = "tls-keyfile-password" //nolint:gosec // Not a credential | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package flags | ||
|
||
import ( | ||
"log/slog" | ||
|
||
commonFlags "github.com/aerospike/tools-common-go/flags" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
type BatchingFlags struct { | ||
MaxRecords Uint32OptionalFlag | ||
Interval Uint32OptionalFlag | ||
} | ||
|
||
func NewBatchingFlags() *BatchingFlags { | ||
return &BatchingFlags{ | ||
MaxRecords: Uint32OptionalFlag{}, | ||
Interval: Uint32OptionalFlag{}, | ||
} | ||
} | ||
|
||
func (cf *BatchingFlags) NewFlagSet() *pflag.FlagSet { | ||
flagSet := &pflag.FlagSet{} | ||
flagSet.Var(&cf.MaxRecords, BatchMaxRecords, commonFlags.DefaultWrapHelpString("Maximum number of records to fit in a batch. The default value is 10000.")) //nolint:lll // For readability | ||
flagSet.Var(&cf.Interval, BatchInterval, commonFlags.DefaultWrapHelpString("The maximum amount of time in milliseconds to wait before finalizing a batch. The default value is 10000.")) //nolint:lll // For readability | ||
|
||
return flagSet | ||
} | ||
|
||
func (cf *BatchingFlags) NewSLogAttr() []any { | ||
return []any{ | ||
slog.Any(BatchMaxRecords, cf.MaxRecords.Val), | ||
slog.Any(BatchInterval, cf.Interval.Val), | ||
} | ||
} | ||
|
||
type CachingFlags struct { | ||
maxEntries Uint64OptionalFlag | ||
expiry Uint64OptionalFlag | ||
} | ||
|
||
func NewCachingFlags() *CachingFlags { | ||
return &CachingFlags{ | ||
maxEntries: Uint64OptionalFlag{}, | ||
expiry: Uint64OptionalFlag{}, | ||
} | ||
} | ||
|
||
func (cf *CachingFlags) NewFlagSet() *pflag.FlagSet { | ||
flagSet := &pflag.FlagSet{} //nolint:lll // For readability | ||
flagSet.Var(&cf.maxEntries, HnswCacheMaxEntries, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
flagSet.Var(&cf.expiry, HnswCacheExpiry, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
|
||
return flagSet | ||
} | ||
|
||
func (cf *CachingFlags) NewSLogAttr() []any { | ||
return []any{ | ||
slog.Any(HnswCacheMaxEntries, cf.maxEntries.Val), | ||
slog.Any(HnswCacheExpiry, cf.expiry.Val), | ||
} | ||
} | ||
|
||
type HealerFlags struct { | ||
maxScanRatePerNode Uint32OptionalFlag | ||
maxScanPageSize Uint32OptionalFlag | ||
reindexPercent Float32OptionalFlag | ||
scheduleDelay Uint64OptionalFlag | ||
parallelism Uint32OptionalFlag | ||
} | ||
|
||
func NewHealerFlags() *HealerFlags { | ||
return &HealerFlags{ | ||
maxScanRatePerNode: Uint32OptionalFlag{}, | ||
maxScanPageSize: Uint32OptionalFlag{}, | ||
reindexPercent: Float32OptionalFlag{}, | ||
scheduleDelay: Uint64OptionalFlag{}, | ||
parallelism: Uint32OptionalFlag{}, | ||
} | ||
} | ||
|
||
func (cf *HealerFlags) NewFlagSet() *pflag.FlagSet { | ||
flagSet := &pflag.FlagSet{} //nolint:lll // For readability | ||
flagSet.Var(&cf.maxScanRatePerNode, HnswHealerMaxScanRatePerNode, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
flagSet.Var(&cf.maxScanPageSize, HnswHealerMaxScanPageSize, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
flagSet.Var(&cf.reindexPercent, HnswHealerReindexPercent, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
flagSet.Var(&cf.scheduleDelay, HnswHealerScheduleDelay, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
flagSet.Var(&cf.parallelism, HnswHealerParallelism, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
|
||
return flagSet | ||
} | ||
|
||
func (cf *HealerFlags) NewSLogAttr() []any { | ||
return []any{ | ||
slog.Any(HnswHealerMaxScanRatePerNode, cf.maxScanRatePerNode.Val), | ||
slog.Any(HnswHealerMaxScanPageSize, cf.maxScanPageSize.Val), | ||
slog.Any(HnswHealerReindexPercent, cf.reindexPercent.Val), | ||
slog.Any(HnswHealerScheduleDelay, cf.scheduleDelay.Val), | ||
slog.Any(HnswHealerParallelism, cf.parallelism.Val), | ||
} | ||
} | ||
|
||
type MergeFlags struct { | ||
parallelism Uint32OptionalFlag | ||
} | ||
|
||
func NewMergeFlags() *MergeFlags { | ||
return &MergeFlags{ | ||
parallelism: Uint32OptionalFlag{}, | ||
} | ||
} | ||
|
||
func (cf *MergeFlags) NewFlagSet() *pflag.FlagSet { | ||
flagSet := &pflag.FlagSet{} //nolint:lll // For readability | ||
flagSet.Var(&cf.parallelism, HnswMergeParallelism, commonFlags.DefaultWrapHelpString("TODO")) //nolint:lll // For readability | ||
|
||
return flagSet | ||
} | ||
|
||
func (cf *MergeFlags) NewSLogAttr() []any { | ||
return []any{ | ||
slog.Any(HnswMergeParallelism, cf.parallelism.Val), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters