WriteLog writes msg that leader sends replica msg.
(msg []byte)
| 224 | |
| 225 | // WriteLog writes msg that leader sends replica msg. |
| 226 | func (p *partition) WriteLog(msg []byte) error { |
| 227 | if p.closed.Load() { |
| 228 | return constants.ErrPartitionClosed |
| 229 | } |
| 230 | if len(msg) == 0 { |
| 231 | return nil |
| 232 | } |
| 233 | p.statistics.ReceiveWriteSize.Add(float64(len(msg))) |
| 234 | if err := p.log.Queue().Put(msg); err != nil { |
| 235 | p.statistics.WriteWALFailures.Incr() |
| 236 | return err |
| 237 | } |
| 238 | p.statistics.WriteWAL.Incr() |
| 239 | return nil |
| 240 | } |
| 241 | |
| 242 | // BuildReplicaForLeader builds replica relation when handle writeTask connection. |
| 243 | // local replicator: replica node == current node. |