-
Notifications
You must be signed in to change notification settings - Fork 13
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
Executions stored in Database #560
Conversation
this one has some conflicts that needs to be resolved |
I've done some update like splitting the database part (and put it in the database package) and also have the execution package that only manage the business logic related to the execution object. The responsibility to save this execution is done directly in the api package. Waiting more feedbacks on that |
database/execution_db.go
Outdated
// Save an instance of executable in the database | ||
// Returns an error if anything from marshaling to database saving goes wrong | ||
func (db *LevelDBExecutionDB) Save(execution *execution.Execution) (*execution.Execution, error) { | ||
id := fmt.Sprintf("%x", sha1.Sum(structhash.Dump(execution, 1))) |
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.
id shouldn't be generated from hash calculation of execution struct. there is no a specific need for this so we can avoid doing it and use uuid. otherwise while updating something from execution, the ID also needs to be changed for no real reason.
I changed slightly the current implementation, now the hash is not calculated on the execution date but based on an |
I don't get these changes. Why are we complicating unique id generation? To me, we can create and set execution.Execution.ID with a randomly generated uuid inside execution.New() or execution.Save(). Why do we need to generate a hash over execution.Execution data structure? We're not looking for uniqueness of executions. The only thing needed is a random unique id for identifying each execution. |
We actually need "uniqueness of executions". When we have the distributed version of MESG, the execution will be created by one node but all other nodes should be able to reproduce the same id based on the same data to ensure that they are verifying/executing the exact same execution. For now it's not mandatory to use a hash but it will be and it doesn't add much complexity, we already have the exact same principle for services for the same reason. |
execution/execution_test.go
Outdated
hasError bool | ||
}{ | ||
{e.ID, false}, | ||
{"doesn't exists", true}, |
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'm removing this because I think, it's forgotten here.
7b685a4
to
40db360
Compare
40db360
to
572fe63
Compare
5367613
to
99eb632
Compare
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.
manual tests are ok
I've created a database to store all executions. For now it is a leveldb database but this can be changed in the future if needed. The purpose of this PR is really to not store any execution state in memory to avoid huge memory consumption.