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

engine/sync-manager: add config support #1326

Merged
merged 13 commits into from
Aug 29, 2023

Conversation

gloriousCode
Copy link
Collaborator

PR Description

This is a quick & basic QoL improvement which adds the sync manager config to our config file. No longer do you need to add so many params when running the application to change behaviour. You can still use the running params to override your config.

Also, the sync manager is a pretty trustworthy subsystem now, so I've added the ability to modify what logging events to output. You can toggle whether you want to see:

  • Switch protocol updates
  • Initial sync updates
  • Event updates

Errors, default subsystem logs all still show and Verbose is still a thing.

Please delete options that are not relevant and add an x in [] as item is complete.

  • New feature (non-breaking change which adds functionality)

How has this been tested

  • go test ./... -race
  • golangci-lint run
  • TestGetDefaultSyncManagerConfig()

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on Github Actions/AppVeyor with my changes
  • Any dependent changes have been merged and published in downstream modules

@gloriousCode gloriousCode added the review me This pull request is ready for review label Aug 22, 2023
@gloriousCode gloriousCode requested a review from a team August 22, 2023 06:30
@gloriousCode gloriousCode self-assigned this Aug 22, 2023
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Looks good. Minor nits.

config/config.go Show resolved Hide resolved
log.Warnf(log.ConfigMgr, "invalid sync manager pair format value %v, defaulting to %v\n", c.SyncManagerConfig.PairFormatDisplay, c.CurrencyPairFormat)
c.SyncManagerConfig.PairFormatDisplay = c.CurrencyPairFormat
}
if c.SyncManagerConfig.TimeoutREST <= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if I purge fiat display currency it purges and never comes back and stops the sync manager from working🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well don't do that 😆 Will look into it

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still an issue, when I remove this fiatdisplayCurrency from the config it stops the starting of the syncMnager

FiatDisplayCurrency: bot.Config.Currency.FiatDisplayCurrency,
Verbose: bot.Settings.Verbose,
cfg := bot.Config.SyncManagerConfig
cfg.SynchronizeTicker = bot.Settings.EnableTickerSyncing && cfg.SynchronizeTicker
Copy link
Collaborator

Choose a reason for hiding this comment

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

When ticker sync is enabled in config this pattern used to override if set using flagSet.WithBool functionality in engine.

.\gocryptotrader -orderbooksync=true -tickersync=false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you rephrase that please?

Copy link
Collaborator

Choose a reason for hiding this comment

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

When ticker sync is set to true in config, when I try to set it to false via command line it will not. I don't english well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the inverse if I have both set to false in config and I run this command, it doesn't work:

 .\gocryptotrader --orderbooksync=true --tickersync=true

Copy link
Collaborator Author

@gloriousCode gloriousCode Aug 24, 2023

Choose a reason for hiding this comment

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

Default app param values have now become false to address this. But then that will mean you can't disable it via command line.

I'm thinking to remove them based on what you're after

edit: still reworking

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved, I forgot about the lovely existing helper functions

@gloriousCode gloriousCode added reconstructing Based on PR feedback, this is currently being reworked and is not to be merged and removed review me This pull request is ready for review labels Aug 23, 2023
@gloriousCode gloriousCode added review me This pull request is ready for review and removed reconstructing Based on PR feedback, this is currently being reworked and is not to be merged labels Aug 23, 2023
@gloriousCode gloriousCode requested a review from shazbert August 23, 2023 23:43
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Thanks for changes, just 2 things I noticed.

log.Warnf(log.ConfigMgr, "invalid sync manager pair format value %v, defaulting to %v\n", c.SyncManagerConfig.PairFormatDisplay, c.CurrencyPairFormat)
c.SyncManagerConfig.PairFormatDisplay = c.CurrencyPairFormat
}
if c.SyncManagerConfig.TimeoutREST <= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still an issue, when I remove this fiatdisplayCurrency from the config it stops the starting of the syncMnager

config/config.go Outdated
c.SyncManagerConfig.TimeoutWebsocket = DefaultSyncerTimeoutWebsocket
}
if c.SyncManagerConfig.PairFormatDisplay == nil {
log.Warnf(log.ConfigMgr, "invalid sync manager pair format value %v, using default format eg BTC-USD\n", c.SyncManagerConfig.PairFormatDisplay)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

FiatDisplayCurrency: bot.Config.Currency.FiatDisplayCurrency,
Verbose: bot.Settings.Verbose,
cfg := bot.Config.SyncManagerConfig
cfg.SynchronizeTicker = bot.Settings.EnableTickerSyncing && cfg.SynchronizeTicker
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the inverse if I have both set to false in config and I run this command, it doesn't work:

 .\gocryptotrader --orderbooksync=true --tickersync=true

@gloriousCode gloriousCode requested a review from shazbert August 24, 2023 04:30
@gloriousCode gloriousCode added reconstructing Based on PR feedback, this is currently being reworked and is not to be merged and removed review me This pull request is ready for review labels Aug 24, 2023
@gloriousCode gloriousCode added review me This pull request is ready for review and removed reconstructing Based on PR feedback, this is currently being reworked and is not to be merged labels Aug 24, 2023
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

Nice! Just some minor nitters

config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
engine/sync_manager.go Show resolved Hide resolved
gloriousCode and others added 2 commits August 29, 2023 15:01
@gloriousCode gloriousCode requested a review from thrasher- August 29, 2023 05:13
@thrasher- thrasher- changed the title sync-manager: add config egnine/sync-manager: add config support Aug 29, 2023
Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

Like a glorious beef stroganoff!

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Ch ACK

@thrasher- thrasher- merged commit d3102a0 into thrasher-corp:master Aug 29, 2023
@thrasher- thrasher- changed the title egnine/sync-manager: add config support engine/sync-manager: add config support Aug 29, 2023
shazbert pushed a commit to shazbert/gocryptotrader that referenced this pull request Nov 10, 2023
* allows sync manager customisation for values and logs

* config-example add

* who doesnt like more coverage?

* ensures you can actually disable it via config el oh el

* less ifs, better control

* fix verbose

* sync trades default false

* fix summary being printed when not enabled

* fixes config checker and output

* nits

* I can put this behind me now

* Fixed logCaSiNg

Co-authored-by: Adrian Gallagher <[email protected]>

* combines if statements

---------

Co-authored-by: Adrian Gallagher <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review me This pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants