Skip to content

Commit

Permalink
add config doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Feb 13, 2024
1 parent de99a36 commit 19e428b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ In this document, we use the default configuration, which has the following beha

The GraphQL endpoint can be used with a GraphQL client (e.g., Altair) to conveniently perform requests (`query`, `mutation`) and obtain schema introspection.

Read more about the configuration [here](./docs/config.md).

## External port binding

By default the HTTP API and P2P network will use localhost. If you want to expose the ports externally you need to specify the addresses in the config or command line parameters.
Expand Down
22 changes: 11 additions & 11 deletions cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ var configFlags = map[string]string{
"api.privkeypath": "privkeypath",
}

// bindConfigFlags binds the set of cli flags to config values.
func bindConfigFlags(cfg *viper.Viper, flags *pflag.FlagSet) error {
for key, flag := range configFlags {
err := cfg.BindPFlag(key, flags.Lookup(flag))
if err != nil {
return err
}
}
return nil
}

// defaultConfig returns a new config with default values.
func defaultConfig() *viper.Viper {
cfg := viper.New()
Expand Down Expand Up @@ -136,6 +125,17 @@ func loadConfig(rootdir string, flags *pflag.FlagSet) (*viper.Viper, error) {
return cfg, nil
}

// bindConfigFlags binds the set of cli flags to config values.
func bindConfigFlags(cfg *viper.Viper, flags *pflag.FlagSet) error {
for key, flag := range configFlags {
err := cfg.BindPFlag(key, flags.Lookup(flag))
if err != nil {
return err
}
}
return nil
}

// loggingConfig returns a new logging config from the given config.
func loggingConfig(cfg *viper.Viper) logging.Config {
var level int8
Expand Down
64 changes: 64 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# DefraDB configuration (YAML)

The default DefraDB directory is `$HOME/.defradb`. It can be changed via the --rootdir CLI flag.

Relative paths are interpreted as being rooted in the DefraDB directory.

## `datastore.store`

Store can be badger or memory. Defaults to `badger`.

- badger: fast pure Go key-value store optimized for SSDs (https://github.com/dgraph-io/badger)
- memory: in-memory version of badger

## `datastore.maxtxnretries`

Maximum number of times to retry a failed transaction. Defaults to `5`.

## `datastore.badger.path`

The path to the database data file(s). Defaults to `data`.

## `datastore.badger.valuelogfilesize`

Maximum file size of the value log files.

## `api.address`

Address of the HTTP API to listen on or connect to. Defaults to `127.0.0.1:9181`.

## `api.allowed-origins`

The list of origins a cross-domain request can be executed from.

## `api.pubkeypath`

The path to the public key file for TLS / HTTPS.

## `api.privkeypath`

The path to the private key file for TLS / HTTPS.

## `net.p2pdisabled`

Whether P2P networking is disabled. Defaults to `false`.

## `net.p2paddresses`

List of addresses for the P2P network to listen on. Defaults to `/ip4/127.0.0.1/tcp/9171`.

## `net.pubsubenabled`

Whether PubSub is enabled. Defaults to `true`.

## `net.peers`

List of peers to boostrap with, specified as multiaddresses.

https://docs.libp2p.io/concepts/addressing/

## `net.relay`

Enable libp2p's Circuit relay transport protocol. Defaults to `false`.

https://docs.libp2p.io/concepts/circuit-relay/

0 comments on commit 19e428b

Please sign in to comment.