-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add DealStages to track and log Deal status updates #502
Conversation
68ce94b
to
5ef2fe8
Compare
@@ -141,3 +141,37 @@ var DealStates = map[StorageDealStatus]string{ | |||
StorageDealClientTransferRestart: "StorageDealClientTransferRestart", | |||
StorageDealProviderTransferAwaitRestart: "StorageDealProviderTransferAwaitRestart", | |||
} | |||
|
|||
// DealStatesDescriptions maps StorageDealStatus codes to string description for better UX | |||
var DealStatesDescriptions = map[StorageDealStatus]string{ |
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'd merge this with the above map, making it a map[StorageDealStatus]struct{Name: string, Desc: string}
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.
The DealStates map is already used in a lot of places across the code so if you unify the maps, may be a good idea to add an init() function that also recreates the DealStates map
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.
The DealStates map is already used in a lot of places across the code
This was the main reason I created a new map.
I suggest we do that refactor as a next step, as I am sure we will want to adjust messages and descriptions very soon.
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.
There is a Notifier
primitive in go-statemachine/fsm that we could use if we want to move the user friendly messages away from the state machine and into Lotus. Just a thought that came up while discussing with @nonsense today.
https://pkg.go.dev/github.com/filecoin-project/go-statemachine/fsm#Notifier
f0adf33
to
1de66af
Compare
c0390f6
to
6458ab5
Compare
Codecov Report
@@ Coverage Diff @@
## master #502 +/- ##
==========================================
+ Coverage 65.41% 65.83% +0.42%
==========================================
Files 51 51
Lines 3431 3505 +74
==========================================
+ Hits 2244 2307 +63
- Misses 958 969 +11
Partials 229 229
Continue to review full report at Codecov.
|
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.
Looking good, just some suggestions on re-wording the messages
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
Co-authored-by: dirkmc <[email protected]>
58d0bf7
to
a848de8
Compare
From(storagemarket.StorageDealFailing).To(storagemarket.StorageDealError), | ||
From(storagemarket.StorageDealFailing).To(storagemarket.StorageDealError). | ||
Action(func(deal *storagemarket.ClientDeal) error { | ||
deal.AddLog("") |
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 empty string intended?
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, so that we add the given stage with a timestamp to the event log, even if we don't want to add any message.
storagemarket/types_test.go
Outdated
func TestDealStagesNil(t *testing.T) { | ||
var ds *storagemarket.DealStages | ||
ds.GetStage("none") | ||
ds.AddStageLog("MyStage", "desc", "duration", "msg") |
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.
Anything that we want to assert on?
// EXPERIMENTAL; subject to change. | ||
func (ds *DealStages) AddStageLog(stage, description, expectedDuration, msg string) { | ||
if ds == nil { | ||
return |
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.
We don't want to create a DealStages instance here? I guess it would allow us to display partial logs for deals that were in progress before this code got deployed?
if ds == nil {
*ds = DealStages{}
}
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.
Actually, this is not possible. We would need to return the new DealStages
object, similar to how hashicorp/go-multierror.Append works: https://pkg.go.dev/github.com/hashicorp/go-multierror#Append
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.
This is done for backward compatibility with deals that are created with earlier versions - in these cases we just don't want to have to have DealStages
.
Closes #501