-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a map of revision parsing functions by engine kind
This will allow calling dispatchers to parse and compare revisions used in dispatch messages
- Loading branch information
1 parent
d74db50
commit 23276c1
Showing
5 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
) | ||
|
||
const ( | ||
Engine = "memory" | ||
defaultWatchBufferLength = 128 | ||
numAttempts = 10 | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package revisionparsing | ||
|
||
import ( | ||
"github.com/authzed/spicedb/internal/datastore/crdb" | ||
"github.com/authzed/spicedb/internal/datastore/memdb" | ||
"github.com/authzed/spicedb/internal/datastore/mysql" | ||
"github.com/authzed/spicedb/internal/datastore/postgres" | ||
"github.com/authzed/spicedb/internal/datastore/spanner" | ||
"github.com/authzed/spicedb/pkg/datastore" | ||
"github.com/authzed/spicedb/pkg/datastore/revision" | ||
) | ||
|
||
// ParsingFunc defines a type representing parsing a revision string into a revision. | ||
type ParsingFunc func(revisionStr string) (rev datastore.Revision, err error) | ||
|
||
// ParseRevisionStringByDatastoreEngineID defines a map from datastore engine ID to its associated | ||
// revision parsing function. | ||
var ParseRevisionStringByDatastoreEngineID = map[string]ParsingFunc{ | ||
memdb.Engine: revision.ParseRevisionString, | ||
crdb.Engine: revision.ParseRevisionString, | ||
postgres.Engine: postgres.ParseRevisionString, | ||
mysql.Engine: revision.ParseRevisionString, | ||
spanner.Engine: revision.ParseRevisionString, | ||
} |