-
Notifications
You must be signed in to change notification settings - Fork 10
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
Delete tasks endpoint #260
Conversation
add delete method to state. Unfortunately limitations of SQLite forced a division of migrations to alter a constraint.
Add controller endpoint to access delete function on state
lets get rid of the sqlite support rather than adding this much complexity to support it |
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.
A few suggestions, but looks good.
@@ -1078,3 +1083,29 @@ func (s *stateDB) ResetWorkerTasks(ctx context.Context, worker string) error { | |||
} | |||
return nil | |||
} | |||
|
|||
func (s *stateDB) Delete(ctx context.Context, uuid string) error { | |||
task, _, err := s.getWithTag(ctx, uuid) |
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.
It might be better to create a version of this function that is not transaction-wrapped and call to get and delete within the same transaction.
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.
agree.
transaction wrapping should happen in the calling code for a utility function like this, IMHO.
controller/state/statedb_dml.go
Outdated
` | ||
|
||
deleteTaskStatusLedgerSQL = ` | ||
DELETE FROM task_status_ledger WHERE uuid = $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.
It might make sense to combine these into a single query:
deleteTaskAndStatueSQL = `
DELETE FROM tasks WHERE uuid = $1;
DELETE FROM task_status_ledger WHERE uuid = $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.
oh did I not push the fix? you actually can great ride of this with ON DELETE CASCADE
@@ -49,8 +49,8 @@ Dealbot Controller | |||
| graphql | `DEALBOT_GRAPHQL_LISTEN` | exposed `host:port` for external public graphql queries | | |||
| metrics | `DEALBOT_METRICS` | either `prometheus` to expose a `/metrics` api, or `log` to write metrics to stdout | | |||
| identity | `DEALBOT_IDENTITY_KEYPAIR` | filepath of a libp2p identity to sign public records of dealbot activity | | |||
| driver | `DEALBOT_PERSISTENCE_DRIVER` | `sqlite` or `postgres` | | |||
| dbloc | `DEALBOT_PERSISTENCE_CONN` | the file (for sqlite) or db conn string from postgres | | |||
| driver | `DEALBOT_PERSISTENCE_DRIVER` | `postgres` | |
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.
get rid of entirely?
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 thought that was what we decided?
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.
but now that there's only one entry we can get rid of the flag entirely?
use correct cc flag for database
Goals
Be able to cancel either task schedules (not the running instances of scheduled tasks) or unstarted tasks
Implementation
This turned out to be enjoyable difficult, as SQLite apparently does not implement ALTER TABLE ADD/DROP CONSTRAINT. This led after much discussion to the idea to drop SQLite.
Here is the approach used to defaulting to PG:
Otherwise, the implementation is pretty straightforward.