-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1547 from josephschorr/memdb-serialization-error
Add better error messaging and tests for memdb serialization error
- Loading branch information
Showing
4 changed files
with
110 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package memdb | ||
|
||
import ( | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" | ||
|
||
"github.com/authzed/spicedb/pkg/spiceerrors" | ||
) | ||
|
||
// ErrSerializationMaxRetriesReached occurs when a write request has reached its maximum number | ||
// of retries due to serialization errors. | ||
type ErrSerializationMaxRetriesReached struct { | ||
error | ||
} | ||
|
||
// NewSerializationMaxRetriesReachedErr constructs a new max retries reached error. | ||
func NewSerializationMaxRetriesReachedErr(baseErr error) error { | ||
return ErrSerializationMaxRetriesReached{ | ||
error: baseErr, | ||
} | ||
} | ||
|
||
// GRPCStatus implements retrieving the gRPC status for the error. | ||
func (err ErrSerializationMaxRetriesReached) GRPCStatus() *status.Status { | ||
return spiceerrors.WithCodeAndDetails( | ||
err, | ||
codes.DeadlineExceeded, | ||
spiceerrors.ForReason( | ||
v1.ErrorReason_ERROR_REASON_UNSPECIFIED, | ||
map[string]string{ | ||
"details": "too many updates were made to the in-memory datastore at once; this datastore has limited write throughput capability", | ||
}, | ||
), | ||
) | ||
} |
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