mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
change "External" DB to "Lookup" DB
This commit is contained in:
parent
c4aad290ed
commit
9bc1b23b7e
7 changed files with 22 additions and 22 deletions
|
|
@ -66,8 +66,8 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
|
|||
flags.StringVar(&srv.Config.Etcd.ClusterURL, "etcd.cluster-url", srv.Config.Etcd.ClusterURL, "Cluster URL to join.")
|
||||
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.ExternalDBDSN, "external-db-dsn", "", "external (postgres) database DSN to use for ExternalLookup calls")
|
||||
// External postgres database for ExternalLookup
|
||||
flags.StringVar(&srv.Config.LookupDBDSN, "lookup-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.")
|
||||
|
|
|
|||
|
|
@ -4007,7 +4007,7 @@ var (
|
|||
)
|
||||
|
||||
func (e *executor) executeExternalLookup(ctx context.Context, qcx *Qcx, index string, c *pql.Call, shards []uint64, opt *execOptions) (res ExtractedTable, err error) {
|
||||
if e.Holder.externalDB == nil {
|
||||
if e.Holder.lookupDB == nil {
|
||||
return ExtractedTable{}, errors.New("external DB connection is not configured")
|
||||
}
|
||||
|
||||
|
|
@ -4057,7 +4057,7 @@ func (e *executor) executeExternalLookup(ctx context.Context, qcx *Qcx, index st
|
|||
arg = argRow.Columns()
|
||||
}
|
||||
|
||||
result, err := e.Holder.externalDB.QueryContext(ctx, query, pq.Array(arg))
|
||||
result, err := e.Holder.lookupDB.QueryContext(ctx, query, pq.Array(arg))
|
||||
if err != nil {
|
||||
return ExtractedTable{}, errors.Wrapf(err, "SQL query failed")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8020,7 +8020,7 @@ func TestExternalLookup(t *testing.T) {
|
|||
}()
|
||||
|
||||
// Start up a Pilosa cluster with access to the DB.
|
||||
c := test.MustRunCluster(t, 3, []server.CommandOption{server.OptCommandServerOptions(pilosa.OptServerExternalDB(dbDSN))})
|
||||
c := test.MustRunCluster(t, 3, []server.CommandOption{server.OptCommandServerOptions(pilosa.OptServerLookupDB(dbDSN))})
|
||||
defer c.Close()
|
||||
|
||||
// Populate a field with some data that can be used in queries.
|
||||
|
|
|
|||
20
holder.go
20
holder.go
|
|
@ -151,7 +151,7 @@ type Holder struct {
|
|||
|
||||
txf *TxFactory
|
||||
|
||||
externalDB *sql.DB
|
||||
lookupDB *sql.DB
|
||||
|
||||
// a separate lock out for indexes, to avoid the deadlock/race dilema
|
||||
// on holding mu.
|
||||
|
|
@ -243,7 +243,7 @@ type HolderConfig struct {
|
|||
RBFConfig *rbfcfg.Config
|
||||
AntiEntropyInterval time.Duration
|
||||
|
||||
ExternalDBDSN string
|
||||
LookupDBDSN string
|
||||
}
|
||||
|
||||
func DefaultHolderConfig() *HolderConfig {
|
||||
|
|
@ -733,15 +733,15 @@ func (h *Holder) Open() error {
|
|||
|
||||
h.txf.blueGreenOnIfRunningBlueGreen()
|
||||
|
||||
if h.cfg.ExternalDBDSN != "" {
|
||||
h.Logger.Printf("connecting to external DB")
|
||||
if h.cfg.LookupDBDSN != "" {
|
||||
h.Logger.Printf("connecting to lookup DB")
|
||||
|
||||
db, err := sql.Open("postgres", h.cfg.ExternalDBDSN)
|
||||
db, err := sql.Open("postgres", h.cfg.LookupDBDSN)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "connecting to external database")
|
||||
return errors.Wrap(err, "connecting to lookup database")
|
||||
}
|
||||
|
||||
h.externalDB = db
|
||||
h.lookupDB = db
|
||||
}
|
||||
|
||||
h.Logger.Printf("open holder: complete")
|
||||
|
|
@ -854,12 +854,12 @@ func (h *Holder) Close() error {
|
|||
h.SnapshotQueue = nil
|
||||
}
|
||||
|
||||
if h.externalDB != nil {
|
||||
err := h.externalDB.Close()
|
||||
if h.lookupDB != nil {
|
||||
err := h.lookupDB.Close()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "closing DB")
|
||||
}
|
||||
h.externalDB = nil
|
||||
h.lookupDB = nil
|
||||
}
|
||||
|
||||
_ = testhook.Closed(h.Auditor, h, nil)
|
||||
|
|
|
|||
|
|
@ -400,10 +400,10 @@ func OptServerDisCo(disCo disco.DisCo,
|
|||
}
|
||||
}
|
||||
|
||||
// OptServerExternalDB configures a connection to an external postgres database.
|
||||
func OptServerExternalDB(dsn string) ServerOption {
|
||||
// OptServerLookupDB configures a connection to an external postgres database for ExternalLookup queries.
|
||||
func OptServerLookupDB(dsn string) ServerOption {
|
||||
return func(s *Server) error {
|
||||
s.holderConfig.ExternalDBDSN = dsn
|
||||
s.holderConfig.LookupDBDSN = dsn
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,8 +223,8 @@ type Config struct {
|
|||
// result combines the history from all nodes.
|
||||
QueryHistoryLength int `toml:"query-history-length"`
|
||||
|
||||
// ExternalDBDSN is an external database to connect to for `ExternalLookup` queries.
|
||||
ExternalDBDSN string `toml:"external-db-dsn"`
|
||||
// LookupDBDSN is an external database to connect to for `ExternalLookup` queries.
|
||||
LookupDBDSN string `toml:"lookup-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.ExternalDBDSN != "" {
|
||||
serverOptions = append(serverOptions, pilosa.OptServerExternalDB(m.Config.ExternalDBDSN))
|
||||
if m.Config.LookupDBDSN != "" {
|
||||
serverOptions = append(serverOptions, pilosa.OptServerLookupDB(m.Config.LookupDBDSN))
|
||||
}
|
||||
|
||||
serverOptions = append(serverOptions, m.serverOptions...)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue