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

services/horizon: Make stellar core database URL optional if captive core is enabled. #3150

Merged
merged 1 commit into from
Oct 22, 2020
Merged
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
7 changes: 3 additions & 4 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func Flags() (*Config, support.ConfigOptions) {
EnvVar: "STELLAR_CORE_DATABASE_URL",
ConfigKey: &config.StellarCoreDatabaseURL,
OptType: types.String,
Required: false,
Usage: "stellar-core postgres database to connect with",
},
&support.ConfigOption{
Expand Down Expand Up @@ -359,10 +360,8 @@ func NewAppFromFlags(config *Config, flags support.ConfigOptions) *App {
if config.StellarCoreURL == "" {
log.Fatalf("flag --%s cannot be empty", StellarCoreURLFlagName)
}
if config.Ingest {
if config.StellarCoreDatabaseURL == "" {
log.Fatalf("flag --%s cannot be empty", StellarCoreDBURLFlagName)
}
if config.Ingest && !config.EnableCaptiveCoreIngestion && config.StellarCoreDatabaseURL == "" {
log.Fatalf("flag --%s cannot be empty", StellarCoreDBURLFlagName)
}
app, err := NewApp(*config)
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions services/horizon/internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ func mustInitHorizonDB(app *App) {

func initExpIngester(app *App) {
var err error
var coreSession *db.Session
if !app.config.EnableCaptiveCoreIngestion {
coreSession = mustNewDBSession(app.config.StellarCoreDatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections)
}
app.ingester, err = ingest.NewSystem(ingest.Config{
CoreSession: mustNewDBSession(
app.config.StellarCoreDatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections,
),
CoreSession: coreSession,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you made sure that nothing breaks when this is nil? (unfortunately successful integration tests don't help at this point because they run without captive core).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2opremio yes, I check the different code paths and we are now only using this value if CaptiveCore is disabled.

HistorySession: mustNewDBSession(
app.config.DatabaseURL, ingest.MaxDBConnections, ingest.MaxDBConnections,
),
Expand Down