mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 20:37:52 +00:00
address ExternalLookup review comments
This commit is contained in:
parent
e9b92e1cd4
commit
c4aad290ed
6 changed files with 13 additions and 12 deletions
|
|
@ -67,7 +67,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
|
|||
flags.StringVar(&srv.Config.Etcd.InitCluster, "etcd.initial-cluster", srv.Config.Etcd.InitCluster, "Initial cluster name1=apurl1,name2=apurl2")
|
||||
|
||||
// External DB
|
||||
flags.StringVar(&srv.Config.ExternalDB, "externaldb", "", "external (postgres) database DSN to use for ExternalQuery calls")
|
||||
flags.StringVar(&srv.Config.ExternalDBDSN, "external-db-dsn", "", "external (postgres) database DSN to use for ExternalLookup calls")
|
||||
|
||||
// AntiEntropy
|
||||
flags.DurationVar((*time.Duration)(&srv.Config.AntiEntropy.Interval), "anti-entropy.interval", (time.Duration)(srv.Config.AntiEntropy.Interval), "Interval at which to run anti-entropy routine.")
|
||||
|
|
|
|||
|
|
@ -4042,10 +4042,11 @@ func (e *executor) executeExternalLookup(ctx context.Context, qcx *Qcx, index st
|
|||
if err != nil {
|
||||
return ExtractedTable{}, errors.Wrap(err, "translating query result")
|
||||
}
|
||||
argRow := qr[0].(*Row)
|
||||
argRow, ok := qr[0].(*Row)
|
||||
if !ok {
|
||||
return ExtractedTable{}, errors.Errorf("argument call result is a %T but expected a row", qr[0])
|
||||
}
|
||||
if !argRow.Any() {
|
||||
// If we attempt to substitute in an empty slice, the substitution will fail.
|
||||
// Do not attempt to execute the query.
|
||||
return ExtractedTable{}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ type HolderConfig struct {
|
|||
RBFConfig *rbfcfg.Config
|
||||
AntiEntropyInterval time.Duration
|
||||
|
||||
ExternalDB string
|
||||
ExternalDBDSN string
|
||||
}
|
||||
|
||||
func DefaultHolderConfig() *HolderConfig {
|
||||
|
|
@ -733,10 +733,10 @@ func (h *Holder) Open() error {
|
|||
|
||||
h.txf.blueGreenOnIfRunningBlueGreen()
|
||||
|
||||
if h.cfg.ExternalDB != "" {
|
||||
if h.cfg.ExternalDBDSN != "" {
|
||||
h.Logger.Printf("connecting to external DB")
|
||||
|
||||
db, err := sql.Open("postgres", h.cfg.ExternalDB)
|
||||
db, err := sql.Open("postgres", h.cfg.ExternalDBDSN)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "connecting to external database")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ func OptServerDisCo(disCo disco.DisCo,
|
|||
// OptServerExternalDB configures a connection to an external postgres database.
|
||||
func OptServerExternalDB(dsn string) ServerOption {
|
||||
return func(s *Server) error {
|
||||
s.holderConfig.ExternalDB = dsn
|
||||
s.holderConfig.ExternalDBDSN = dsn
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,8 +223,8 @@ type Config struct {
|
|||
// result combines the history from all nodes.
|
||||
QueryHistoryLength int `toml:"query-history-length"`
|
||||
|
||||
// ExternalDB is an external database to connect to for `ExternalLookup` queries.
|
||||
ExternalDB string `toml:"external-db"`
|
||||
// ExternalDBDSN is an external database to connect to for `ExternalLookup` queries.
|
||||
ExternalDBDSN string `toml:"external-db-dsn"`
|
||||
}
|
||||
|
||||
// MustValidate checks that all ports in a Config are unique and not zero.
|
||||
|
|
|
|||
|
|
@ -429,8 +429,8 @@ func (m *Command) SetupServer() error {
|
|||
discoOpt,
|
||||
}
|
||||
|
||||
if m.Config.ExternalDB != "" {
|
||||
serverOptions = append(serverOptions, pilosa.OptServerExternalDB(m.Config.ExternalDB))
|
||||
if m.Config.ExternalDBDSN != "" {
|
||||
serverOptions = append(serverOptions, pilosa.OptServerExternalDB(m.Config.ExternalDBDSN))
|
||||
}
|
||||
|
||||
serverOptions = append(serverOptions, m.serverOptions...)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue