@@ -29,6 +29,10 @@ namespace storage {
2929class Storage ;
3030}
3131
32+ namespace pikiwidb {
33+ class Binlog ;
34+ }
35+
3236namespace net {
3337class RedisConn ;
3438}
@@ -38,21 +42,6 @@ class Cmd;
3842namespace pika_raft {
3943
4044// Raft log entry data structure
41- struct RaftLogEntry {
42- std::string cmd_name;
43- std::vector<std::string> args;
44- std::string db_name;
45- int64_t timestamp;
46-
47- RaftLogEntry () : timestamp(0 ) {}
48-
49- // Serialize to string
50- std::string SerializeAsString () const ;
51-
52- // Deserialize from string
53- bool ParseFromString (const std::string& data);
54- };
55-
5645// Write done closure for asynchronous Raft callback
5746class WriteDoneClosure : public braft ::Closure {
5847 public:
@@ -137,9 +126,6 @@ class PikaRaftNode {
137126 // Remove peer from the cluster
138127 pstd::Status RemovePeer (const braft::PeerId& peer);
139128
140- // Apply a command to Raft
141- pstd::Status Apply (const RaftLogEntry& entry);
142-
143129 // Get cluster status information
144130 void GetStatus (std::string* status_str);
145131
@@ -192,23 +178,17 @@ class RaftManager {
192178 // Check if Raft is enabled for a specific DB
193179 bool IsRaftEnabled (const std::string& db_name) const ;
194180
195- // Apply a command through Raft
196- pstd::Status ApplyCommand (const std::string& db_name, const RaftLogEntry& entry);
197-
198181 // Apply binlog to Raft (called by storage callback)
199182 pstd::Status ApplyBinlog (const std::string& db_name,
200- const std::string& binlog_data,
201- WriteDoneClosure* done);
183+ const std::string& binlog_data,
184+ WriteDoneClosure* done);
202185
203- // Submit command to Raft with promise (for synchronous waiting )
204- pstd::Status SubmitCommandWithPromise (const std::string& db_name,
205- const std::string& log_data,
206- std::promise<rocksdb::Status>&& promise);
186+ // Append binlog (pikiwidb_raft 风格,直接接收 Binlog + promise )
187+ void AppendLog (const std::string& db_name,
188+ const ::pikiwidb::Binlog& log,
189+ std::promise<rocksdb::Status>&& promise);
207190
208- // Apply command from Redis protocol (called in on_apply)
209- rocksdb::Status ApplyCommandFromRedisProtocol (const std::string& redis_proto_data,
210- const std::string& db_name);
211-
191+ // Submit command to Raft with promise (for synchronous waiting)
212192 // Get Raft node for a specific DB
213193 std::shared_ptr<PikaRaftNode> GetRaftNode (const std::string& db_name);
214194
@@ -222,7 +202,7 @@ class RaftManager {
222202 bool IsInitialized () const { return initialized_.load (); }
223203
224204 // Apply binlog entry to storage (public for PikaStateMachine to call)
225- void ApplyBinlogEntry (const std::string& binlog_data);
205+ rocksdb::Status ApplyBinlogEntry (const std::string& binlog_data);
226206
227207 private:
228208 std::atomic<bool > initialized_;
0 commit comments