-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Introduce
RefLogId
as a reference to a log ID
Existing `LogIdOf<C>` provides a minimal storage implementation for a log ID with essential properties. In contrast, `RefLogId` offers the same information as `LogIdOf<C>` while adding additional system-defined properties. For example, in the future, `LogIdOf<C>` defined by the application will not need to implement `Ord`. However, `RefLogId`, used internally, will provide a system-defined `Ord` implementation. This change updates internal components to return `RefLogId` or accept it as an argument where possible, enabling more flexibility and consistency in handling log IDs. Change: refine the `RaftEntry` trait - The `RaftEntry` trait now requires `AsRef<LogIdOf<C>>` and `AsMut<LogIdOf<C>>`, providing a more standard API for accessing the log ID of a log entry. As a result, the `RaftEntry: RaftLogId` requirement is no longer needed. - A new method, `new_normal()`, has been added to the `RaftEntry` trait to replace the `FromAppData` trait. - Additional utility methods for working with entries are now provided in the `RaftEntryExt` trait. - Part of #1278 Upgrade tips: 1. **For applications using a custom `RaftEntry` implementation** (e.g., declared with `declare_raft_types!(MyTypes: Entry = MyEntry)`): - Update the `RaftEntry` implementation for your custom entry type (`MyEntry`) by adding the `new_normal()` method. - Implement `AsRef<LogId>` and `AsMut<LogId>` for your custom entry type. 2. **For applications using the default `Entry` provided by OpenRaft**: - No changes are required. empty: try to remove log id from RaftTypeConfig
- Loading branch information
1 parent
791dc3e
commit f0fd058
Showing
50 changed files
with
957 additions
and
455 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
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
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
39 changes: 20 additions & 19 deletions
39
examples/raft-kv-memstore-grpc/proto/management_service.proto
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 |
---|---|---|
@@ -1,50 +1,51 @@ | ||
syntax = "proto3"; | ||
import "google/protobuf/empty.proto"; | ||
import "internal_service.proto"; | ||
import "api_service.proto"; | ||
package openraftpb; | ||
|
||
// ManagementService handles Raft cluster management operations | ||
service ManagementService { | ||
// Init initializes a new Raft cluster with the given nodes | ||
rpc Init(InitRequest) returns (RaftReplyString) {} | ||
rpc Init(InitRequest) returns (google.protobuf.Empty) {} | ||
|
||
// AddLearner adds a new learner node to the Raft cluster | ||
rpc AddLearner(AddLearnerRequest) returns (RaftReplyString) {} | ||
rpc AddLearner(AddLearnerRequest) returns (ClientWriteResponse) {} | ||
|
||
// ChangeMembership modifies the cluster membership configuration | ||
rpc ChangeMembership(ChangeMembershipRequest) returns (RaftReplyString) {} | ||
rpc ChangeMembership(ChangeMembershipRequest) returns (ClientWriteResponse) {} | ||
|
||
// Metrics retrieves cluster metrics and status information | ||
rpc Metrics(RaftRequestString) returns (RaftReplyString) {} | ||
rpc Metrics(google.protobuf.Empty) returns (MetricsString) {} | ||
} | ||
|
||
// InitRequest contains the initial set of nodes for cluster initialization | ||
message InitRequest { | ||
repeated Node nodes = 1; // List of initial cluster nodes | ||
} | ||
|
||
// Node represents a single node in the Raft cluster | ||
message Node { | ||
string rpc_addr = 1; // RPC address for node communication | ||
uint64 node_id = 2; // Unique identifier for the node | ||
} | ||
|
||
// AddLearnerRequest specifies parameters for adding a learner node | ||
message AddLearnerRequest { | ||
Node node = 1; // Node to be added as a learner | ||
} | ||
|
||
// RaftRequestString represents a string-based Raft request | ||
message RaftRequestString { | ||
string data = 1; // Request data in string format | ||
} | ||
|
||
// RaftReplyString represents a string-based Raft response | ||
message RaftReplyString { | ||
string data = 1; // Response data | ||
string error = 2; // Error message, if any | ||
message MetricsString { | ||
string data = 1; // Response data in string | ||
} | ||
|
||
// ChangeMembershipRequest specifies parameters for modifying cluster membership | ||
message ChangeMembershipRequest { | ||
repeated uint64 members = 1; // New set of member node IDs | ||
bool retain = 2; // Whether to retain existing configuration | ||
} | ||
|
||
message ClientWriteResponse { | ||
// The log id of the committed log entry. | ||
LogId log_id = 1; | ||
|
||
// If the committed log entry is a normal one. | ||
Response data = 2; | ||
|
||
// If the committed log entry is a change-membership entry. | ||
Membership membership = 3; | ||
} |
Oops, something went wrong.