dapr / dapr/components-contrib

Adding an Optional DeleteWithPrefix Method for State Stores to Allow Deletion of Actor State

Open
#3,262 6 comments 1 reaction 0 assignees View on GitHub
P1 pinned
Dominant language
Go
Stars
602
Forks
580
Avg merge
4d 9h
Merged PRs (30d)
6

Description

## Describe the proposal
This proposal stems from the following feature request inside dapr runimte: https://github.com/dapr/dapr/issues/6992
After a discussion with various members of the project, the following solution was proposed: https://github.com/dapr/dapr/issues/6992#issuecomment-1839557004

By adding in an optional interface called 'DeleteWithPrefix', we will allow users to delete an actor's state. The interface is optional since some databases will not be able to implement it as highlighted by ItalyPaleAle, an active contributor for dapr here: https://github.com/dapr/dapr/pull/7223#issuecomment-1823720095

Looking at sqlite as an example, a second migration will be added in order to generate a virtual "prefix" column. This column will contain all the information from the actor state entry up to but not including the key. For example, if the key entry is as follows: `app-id||actor-type||actor-id||key` the new virtual prefix column will contain `app-id||actor-type||actor-id`

New request that would be included in state/requests.go:

```go
type DeleteWithPrefixRequest struct {
Prefix string `json:"prefix"`
}
```

New interface that would be included in state/store.go:

```go
type DeleteWithPrefix interface {
DeleteWithPrefix(ctx context.Context, req DeleteWithPrefixRequest) (DeleteWithPrefixResponse, error)
}
```

List of components that are compatible with this optional method:

- [x] sqlite: https://github.com/dapr/components-contrib/pull/3265
- [ ] mysql
- [ ] Postgres
- [ ] sqlserver
- [ ] oracle

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.