Skip to content

Commit

Permalink
chore: update status code (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun authored Nov 5, 2024
1 parent b0cfed4 commit 8c0b036
Showing 1 changed file with 26 additions and 4 deletions.
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

0 comments on commit 8c0b036

Please sign in to comment.