func (c *Config) WithLocalPort(localPort int) *Config {
	if localPort == 0 {
		return c.WithDefaultLocalPort()
	}
	c.LocalPort = localPort
	return c
}
WithLocalPort sets config's local address to the given value or to the default if the given
value is nil.
package server
import (
	"crypto/sha256"
	"fmt"
	"net"
	"os"
	"path/filepath"
	"github.com/drausin/libri/libri/common/ecid"
	"github.com/drausin/libri/libri/common/errors"
	"github.com/drausin/libri/libri/common/parse"
	"github.com/drausin/libri/libri/common/subscribe"
	"github.com/drausin/libri/libri/librarian/server/introduce"
	"github.com/drausin/libri/libri/librarian/server/replicate"
	"github.com/drausin/libri/libri/librarian/server/routing"
	"github.com/drausin/libri/libri/librarian/server/search"
	"github.com/drausin/libri/libri/librarian/server/store"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)
const (
	DefaultPort = 20100
	DefaultMetricsPort = 20200
	DefaultProfilerPort = 20300
	DefaultIP = "localhost"
	DefaultLogLevel = zap.InfoLevel
	DataSubdir = "librarian-data"
	DBSubDir = "db"
)
type Config struct {
	LocalPort int
	LocalMetricsPort int
	LocalProfilerPort int
	PublicAddr *net.TCPAddr
	PublicName string
	OrgID ecid.ID
	DataDir string
	DbDir string
	BootstrapAddrs []*net.TCPAddr
	Routing *routing.Parameters
	Introduce *introduce.Parameters
	Search *search.Parameters
	Store *store.Parameters
	Replicate *replicate.Parameters
	SubscribeTo *subscribe.ToParameters
	SubscribeFrom *subscribe.FromParameters
	ReportMetrics bool
	Profile bool
	LogLevel zapcore.Level
}
func NewDefaultConfig() *Config {
	config := &Config{}
	config.WithDefaultLocalPort()
	config.WithDefaultLocalMetricsPort()
	config.WithDefaultLocalProfilerPort()
	config.WithDefaultPublicAddr()
	config.WithDefaultPublicName()
	config.WithDefaultDataDir()
	config.WithDefaultDBDir()
	config.WithDefaultBootstrapAddrs()
	config.WithDefaultRouting()
	config.WithDefaultIntroduce()
	config.WithDefaultSearch()
	config.WithDefaultStore()
	config.WithDefaultSubscribeTo()
	config.WithDefaultSubscribeFrom()
	config.WithDefaultReplicate()
	config.WithDefaultReportMetrics()
	config.WithDefaultProfile()
	config.WithDefaultLogLevel()
	return config
}