-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor according to DDD specs #11
Conversation
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.
I would Log the price and the kraken ticker everytime we push an update into the daemon
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.
I tested the feeder against a local tdex-daemon
config.json
{
"daemon_endpoint": "127.0.0.1:9000",
"kraken_ws_endpoint": "ws.kraken.com",
"markets": [
{
"base_asset": "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225",
"quote_asset": "6be29b1596fd3c0424f4b6eadb09d01ffdc1757ff15ea12a48a1535a01906978",
"kraken_ticker": "XBT/USDT",
"interval": 1000
}
]
}
My MarketPrice RPC request/response
{
"market": {
"base_asset": "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225",
"quote_asset": "6be29b1596fd3c0424f4b6eadb09d01ffdc1757ff15ea12a48a1535a01906978"
},
"type": 0,
"amount": 100,
"asset": "5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225"
}
{
"prices": [
{
"price": {
"base_price": 0.0000545214643352665,
"quote_price": 0.0000545214643352665
},
"fee": {
"basis_point": "25"
},
"amount": "0",
"asset": "6be29b1596fd3c0424f4b6eadb09d01ffdc1757ff15ea12a48a1535a01906978"
}
]
}
Gracefully handle the shutdown
|
This PR refactor the feeder code to follow DDD architecture, it keeps the base implementation but adds a layer of abstraction and changes the structure of the code.
Domain
Basically there is three interfaces to understand:
Feed
is a source of market prices information such as Kraken API for instance.Target
represents the thing that will change the market price.TdexFeeder
gets a slice ofFeed
and a slice ofTarget
, it listens for feeds and then replicate data to targets.Ports
The ports package implements external interfaces. For now there is
krakenWebSocket.go
that implements a kraken WS feed andtdexDaemonPriceUpdater.go
that implements the GRPC call ofUpdateMarketPrice
.Application
Application package implements services used by the UI.
FeedService
handles kraken web socket feed.UpdaterService
implements thedomain.Target
interface for the TDexDaemon.FeederService
takes aFeedService
, creates aFeeder
and target anUpdaterService
--> this is the feederd implementation.Adapters
The adapters pacakge only handle the
configService
that manage serialization and deserialization of Config JSON file and create afeederService
depending of data inside it.The PR also adds some unit testing + an integration test for feederd
The problem of Kraken web socket
To be clear: the feeder seems to work but I've some problem with socket reading.
I have taken over the method of the current version : the
ReadMessages
method ofwebsocket
package. This method has one drawback: it does not sort the messages received by Kraken. However, KrakenWS sends several types of messages (subscribe, heartbeat, prices etc...) --> so here, It seems that I receive only one "price" message from Kraken, and then I only receive "Heartbeat". I'm not aware off web sockets so I probably miss something.what I would do: Use go-kraken instead of
websocket
package. This is a go lib that manages all the Kraken web sockets stuffs. What's your opinion about it ?Questions / TO DO
Interval: @francismars you have implemented an interval for each Market --> I do not replicate that because I don't understand why we need an interval for each market ? And why the user should modify it ? Please enlighten me on this.
Daemon macaroon: this was not used. I confess that I haven't done much research on this point but it seems to me that Macaroon is not implemented yet?
Global project structure: I'm note sure of what I did with project structure (all in internal because there is not "exported" packages for me)
DDD: First time that I try DDD alone so be indulgent and do not hesitate to criticize the architecture of what I did --> I would like progress on this.
@sekulicd @tiero @francismars @altafan please review
it closes #10