Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a run-time start-up switch -s/--store-backend to choose the data store backend #251

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following options are available:
--metrics-address Listening address of the metrics server [=127.0.0.1].
--metrics-port Listening HTTP port of the metrics server [=8008].
-d, --data-dir The directory where codex will store configuration and data..
-s, --store-backend data store backend: fs, sqlite [=fs].
-l, --listen-port Specifies one or more listening ports for the node to listen on. [=0].
-i, --listen-ip The public IP [=0.0.0.0].
--udp-port Specify the discovery (UDP) port [=8090].
Expand Down
12 changes: 11 additions & 1 deletion codex/codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,18 @@ proc new*(T: type CodexServer, config: CodexConf): T =
raise (ref Defect)(
msg: "Unable to create data directory for block store: " & repoDir)

let localStore =
case config.storeBackend
of cachedStore:
notice "Using --cache backend data store"
cache
of FS:
notice "Using FS backend data store"
FSStore.new(repoDir, cache = cache)
of SQLite:
notice "Using SQLite backend data store"
SQLiteStore.new(repoDir, cache = cache)
let
localStore = SQLiteStore.new(repoDir, cache = cache)
peerStore = PeerCtxStore.new()
pendingBlocks = PendingBlocksManager.new()
discovery = DiscoveryEngine.new(localStore, peerStore, network, blockDiscovery, pendingBlocks)
Expand Down
13 changes: 13 additions & 0 deletions codex/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ type
Json = "json"
None = "none"

StoreKind* = enum
cachedStore = "cached"
FS = "fs"
SQLite = "sqlite"

CodexConf* = object
logLevel* {.
defaultValue: LogLevel.INFO
Expand Down Expand Up @@ -80,6 +85,14 @@ type
abbr: "d"
name: "data-dir" }: OutDir

storeBackend* {.
desc: "data store backend: fs, sqlite"
defaultValue: StoreKind.FS
defaultValueDesc: "fs"
abbr: "s"
name: "store-backend"
.}: StoreKind

case cmd* {.
command
defaultValue: noCommand }: StartUpCommand
Expand Down