-
Notifications
You must be signed in to change notification settings - Fork 1
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
ingest: service created #14
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a69ca69
Merge main into ingest
daniel-burghardt fb6fe06
ingest: initial commit
daniel-burghardt df08358
tests
daniel-burghardt 94ef4ac
errors using fmt
daniel-burghardt 2a3eeb8
Merge main into ingest
daniel-burghardt c81a985
rework: custom setters for path variables
daniel-burghardt 72a0dbb
rework: ledger-cursor-name made more explicit
daniel-burghardt 30ec11a
rework: log level moved to custom set value
daniel-burghardt 5735693
rework: implement runintransaction wrapper
daniel-burghardt f951c14
rework: payments model
daniel-burghardt 65edfa1
rework: getCaptiveCoreConfig tests
daniel-burghardt eb02874
tests added
daniel-burghardt ac1f46e
test added: processLedger
daniel-burghardt 1a38761
rework: memo made optional
daniel-burghardt 2f04e63
rework: struct name to match db column
daniel-burghardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Visual Studio Code | ||
.vscode | ||
.vscode | ||
captive-core*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package cmd | ||
|
||
import ( | ||
"go/types" | ||
|
||
_ "github.com/lib/pq" | ||
"github.com/spf13/cobra" | ||
"github.com/stellar/go/network" | ||
"github.com/stellar/go/support/config" | ||
"github.com/stellar/go/support/log" | ||
"github.com/stellar/wallet-backend/cmd/utils" | ||
"github.com/stellar/wallet-backend/internal/ingest" | ||
) | ||
|
||
type ingestCmd struct{} | ||
|
||
func (c *ingestCmd) Command() *cobra.Command { | ||
cfg := ingest.Configs{} | ||
cfgOpts := config.ConfigOptions{ | ||
{ | ||
Name: "database-url", | ||
Usage: "Database connection URL.", | ||
OptType: types.String, | ||
ConfigKey: &cfg.DatabaseURL, | ||
FlagDefault: "postgres://postgres@localhost:5432/wallet-backend?sslmode=disable", | ||
Required: true, | ||
}, | ||
{ | ||
Name: "network-passphrase", | ||
Usage: "Stellar Network Passphrase to connect.", | ||
OptType: types.String, | ||
ConfigKey: &cfg.NetworkPassphrase, | ||
FlagDefault: network.TestNetworkPassphrase, | ||
Required: true, | ||
}, | ||
{ | ||
Name: "log-level", | ||
Usage: `The log level used in this project. Options: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", or "PANIC".`, | ||
OptType: types.String, | ||
FlagDefault: "TRACE", | ||
ConfigKey: &cfg.LogLevel, | ||
CustomSetValue: utils.SetConfigOptionLogLevel, | ||
Required: false, | ||
}, | ||
{ | ||
Name: "captive-core-bin-path", | ||
Usage: "Path to Captive Core's binary file.", | ||
OptType: types.String, | ||
CustomSetValue: utils.SetConfigOptionCaptiveCoreBinPath, | ||
ConfigKey: &cfg.CaptiveCoreBinPath, | ||
FlagDefault: "/usr/local/bin/stellar-core", | ||
Required: true, | ||
}, | ||
{ | ||
Name: "captive-core-config-dir", | ||
Usage: "Path to Captive Core's configuration files directory.", | ||
OptType: types.String, | ||
CustomSetValue: utils.SetConfigOptionCaptiveCoreConfigDir, | ||
ConfigKey: &cfg.CaptiveCoreConfigDir, | ||
FlagDefault: "./internal/ingest/config", | ||
Required: true, | ||
}, | ||
{ | ||
Name: "ledger-cursor-name", | ||
Usage: "Name of last synced ledger cursor, used to keep track of the last ledger ingested by the service. When starting up, ingestion will resume from the ledger number stored in this record. It should be an unique name per container as different containers would overwrite the cursor value of its peers when using the same cursor name.", | ||
OptType: types.String, | ||
ConfigKey: &cfg.LedgerCursorName, | ||
Required: true, | ||
}, | ||
{ | ||
Name: "start", | ||
Usage: "Ledger number from which ingestion should start. When not present, ingestion will resume from last synced ledger.", | ||
OptType: types.Int, | ||
ConfigKey: &cfg.StartLedger, | ||
FlagDefault: 0, | ||
Required: false, | ||
}, | ||
{ | ||
Name: "end", | ||
Usage: "Ledger number up to which ingestion should run. When not present, ingestion run indefinitely (live ingestion requires it to be empty).", | ||
OptType: types.Int, | ||
ConfigKey: &cfg.EndLedger, | ||
FlagDefault: 0, | ||
Required: false, | ||
}, | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "ingest", | ||
Short: "Run Ingestion service", | ||
PersistentPreRun: func(_ *cobra.Command, _ []string) { | ||
cfgOpts.Require() | ||
if err := cfgOpts.SetValues(); err != nil { | ||
log.Fatalf("Error setting values of config options: %s", err.Error()) | ||
} | ||
}, | ||
Run: func(_ *cobra.Command, _ []string) { | ||
c.Run(cfg) | ||
}, | ||
} | ||
if err := cfgOpts.Init(cmd); err != nil { | ||
log.Fatalf("Error initializing a config option: %s", err.Error()) | ||
} | ||
return cmd | ||
} | ||
|
||
func (c *ingestCmd) Run(cfg ingest.Configs) { | ||
err := ingest.Ingest(cfg) | ||
if err != nil { | ||
log.Fatalf("Error running Ingest: %s", err.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this name correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, whenever you run captive core it creates a folder named like
captive-core-9f8g7a9f
in the application's root folder to store the ledger files it downloads. The "*" is to capture the random name given to the folder.