Skip to content
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

chore: update status code #53

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions ingester-protocol/src/main/java/io/greptime/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

/**
* Common status code for public API.
* <p>
* Always follow <a href="https://github.com/GreptimeTeam/greptimedb/blob/main/src/common/error/src/status_code.rs">GreptimeDB's STATUS CODE</a>
*/
public enum Status {
// ====== Begin of common status code ==============
Expand All @@ -37,8 +39,12 @@ public enum Status {
Internal(1003, true),
// Invalid arguments.
InvalidArguments(1004),
// / The task is cancelled.
// The task is cancelled.
Cancelled(1005),
// Illegal state.
IllegalState(1006),
// Caused by some error originated from external system.
External(1007),
// ====== End of common status code ================

// ====== Begin of SQL related status code =========
Expand All @@ -56,18 +62,35 @@ public enum Status {
// ====== Begin of catalog related status code =====
// Table already exists.
TableAlreadyExists(4000),
// Table not found.
TableNotFound(4001),
// Table column not found.
TableColumnNotFound(4002),
// Table column already exists.
TableColumnExists(4003),
// Database not found.
DatabaseNotFound(4004),
// Region not found.
RegionNotFound(4005),
// Region already exists.
RegionAlreadyExists(4006),
// Region is read-only in current state.
RegionReadonly(4007),
// Region is not in a proper state to handle specific request.
RegionNotReady(4008),
// Region is temporarily in busy state.
RegionBusy(4009),
// Table is temporarily unable to handle the request.
TableUnavailable(4010),
// Database already exists.
DatabaseAlreadyExists(4011),
// ====== End of catalog related status code =======

// ====== Begin of storage related status code =====
// Storage is temporarily unable to handle the request
StorageUnavailable(5000, true),
// Request is outdated, e.g., version mismatch.
RequestOutdated(5001),
// ====== End of storage related status code =======

// ====== Begin of server related status code =====
Expand All @@ -91,9 +114,8 @@ public enum Status {
// Illegal request to connect catalog-schema
AccessDenied(7005),
// User is not authorized to perform the operation
PermissionDenied(7006),
// ====== End of auth related status code =====
;
PermissionDenied(7006);
// ====== End of auth related status code =====

private static final Map<Integer, Status> DICT = new HashMap<>();

Expand Down